Files
Plugin/Source/SenseGloveCore/Private/SGCore/SGBuzzCommand.cpp
T

180 lines
6.8 KiB
C++

/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2023 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#include "SGCore/SGBuzzCommand.h"
#include "SGFingerCommandImplCast.h"
#include "SGCoreImpl/SGExportedFunctions.h"
#include "SGInterop/SGIC_ESGFinger.h"
#include "SGInterop/SGIC_FSGBuzzCommandImpl.h"
#include "SGInterop/SGIC_FSGFingerCommandImpl.h"
#include "SGInterop/SGIC_FString.h"
#include "SGInterop/SGIC_TArray_int32.h"
#include "SGInterop/SGIC_TSharedPtr_FSGBuzzCommandImpl.h"
USGBuzzCommand* USGBuzzCommand::NewBuzzCommand(UObject* Outer, const FSGBuzzCommandImpl& BuzzCommandImpl)
{
USGBuzzCommand* Instance = NewObject<USGBuzzCommand>(Outer);
Instance->SetFingerCommandImpl(BuzzCommandImpl);
return Instance;
}
USGBuzzCommand* USGBuzzCommand::NewBuzzCommand(UObject* Outer, TSharedRef<FSGBuzzCommandImpl> BuzzCommandImpl)
{
USGBuzzCommand* Instance = NewObject<USGBuzzCommand>(Outer);
Instance->SetFingerCommandImpl(MoveTemp(BuzzCommandImpl));
return Instance;
}
USGBuzzCommand* USGBuzzCommand::NewBuzzCommand(UObject* Outer)
{
FSGIC_TSharedPtr_FSGBuzzCommandImpl OutSharedPtrContainer;
SGCoreImpl_FSGBuzzCommandImpl_ctor_MakeShared(&OutSharedPtrContainer);
return NewBuzzCommand(Outer, OutSharedPtrContainer.Ptr.ToSharedRef());
}
USGBuzzCommand* USGBuzzCommand::NewBuzzCommand(UObject* Outer, const TArray<int32>& BuzzLevels)
{
FSGIC_TSharedPtr_FSGBuzzCommandImpl OutSharedPtrContainer;
FSGIC_TArray_int32 BuzzLevelsContainer{BuzzLevels};
SGCoreImpl_FSGBuzzCommandImpl_ctor_BuzzLevels_MakeShared(
&OutSharedPtrContainer, &BuzzLevelsContainer);
return NewBuzzCommand(Outer, OutSharedPtrContainer.Ptr.ToSharedRef());
}
USGBuzzCommand* USGBuzzCommand::NewBuzzCommand(UObject* Outer, const int32 Thumb, const int32 Index, const int32 Middle,
const int32 Ring, const int32 Pinky)
{
FSGIC_TSharedPtr_FSGBuzzCommandImpl OutSharedPtrContainer;
SGCoreImpl_FSGBuzzCommandImpl_ctor_Thumb_Index_Middle_Ring_Pinky_MakeShared(
&OutSharedPtrContainer, Thumb, Index, Middle, Ring, Pinky);
return NewBuzzCommand(Outer, OutSharedPtrContainer.Ptr.ToSharedRef());
}
USGBuzzCommand* USGBuzzCommand::NewBuzzCommand(UObject* Outer, const ESGFinger Finger, const int32 BuzzLevel)
{
FSGIC_TSharedPtr_FSGBuzzCommandImpl OutSharedPtrContainer;
FSGIC_ESGFinger FingerContainer{Finger};
SGCoreImpl_FSGBuzzCommandImpl_ctor_Finger_BuzzLevel_MakeShared(
&OutSharedPtrContainer, &FingerContainer, BuzzLevel);
return NewBuzzCommand(Outer, OutSharedPtrContainer.Ptr.ToSharedRef());
}
USGBuzzCommand* USGBuzzCommand::Off(UObject* Outer)
{
FSGIC_FSGBuzzCommandImpl OutContainer;
SGCoreImpl_FSGBuzzCommandImpl_Off(&OutContainer);
return NewBuzzCommand(Outer, OutContainer.BuzzCommandImpl);
}
USGBuzzCommand::USGBuzzCommand()
: USGFingerCommand()
{
FSGIC_TSharedPtr_FSGBuzzCommandImpl OutSharedPtrContainer;
SGCoreImpl_FSGBuzzCommandImpl_ctor_MakeShared(&OutSharedPtrContainer);
SetFingerCommandImpl(OutSharedPtrContainer.Ptr.ToSharedRef());
}
USGBuzzCommand::USGBuzzCommand(const TArray<int32>& BuzzLevels)
: USGFingerCommand(BuzzLevels)
{
FSGIC_TSharedPtr_FSGBuzzCommandImpl OutSharedPtrContainer;
FSGIC_TArray_int32 BuzzLevelsContainer{BuzzLevels};
SGCoreImpl_FSGBuzzCommandImpl_ctor_BuzzLevels_MakeShared(
&OutSharedPtrContainer, &BuzzLevelsContainer);
SetFingerCommandImpl(OutSharedPtrContainer.Ptr.ToSharedRef());
}
USGBuzzCommand::USGBuzzCommand(
const int32 Thumb, const int32 Index, const int32 Middle, const int32 Ring, const int32 Pinky)
: USGFingerCommand()
{
FSGIC_TSharedPtr_FSGBuzzCommandImpl OutSharedPtrContainer;
SGCoreImpl_FSGBuzzCommandImpl_ctor_Thumb_Index_Middle_Ring_Pinky_MakeShared(
&OutSharedPtrContainer, Thumb, Index, Middle, Ring, Pinky);
SetFingerCommandImpl(OutSharedPtrContainer.Ptr.ToSharedRef());
}
USGBuzzCommand::USGBuzzCommand(const ESGFinger Finger, const int32 BuzzLevel)
: USGFingerCommand()
{
FSGIC_TSharedPtr_FSGBuzzCommandImpl OutSharedPtrContainer;
FSGIC_ESGFinger FingerContainer{Finger};
SGCoreImpl_FSGBuzzCommandImpl_ctor_Finger_BuzzLevel_MakeShared(
&OutSharedPtrContainer, &FingerContainer, BuzzLevel);
SetFingerCommandImpl(OutSharedPtrContainer.Ptr.ToSharedRef());
}
USGBuzzCommand::USGBuzzCommand(const FSGBuzzCommandImpl& BuzzCommandImpl)
: USGFingerCommand(BuzzCommandImpl)
{
}
USGBuzzCommand::USGBuzzCommand(TSharedRef<FSGBuzzCommandImpl> BuzzCommandImpl)
: USGFingerCommand(MoveTemp(BuzzCommandImpl))
{
}
USGBuzzCommand::~USGBuzzCommand() = default;
TSharedRef<FSGBuzzCommandImpl> USGBuzzCommand::ToBuzzCommandImpl() const
{
return FSGFingerCommandImplCast::ToBuzzCommandImpl(ToFingerCommandImpl());
}
USGBuzzCommand* USGBuzzCommand::Copy(UObject* Outer) const
{
FSGIC_TSharedPtr_FSGBuzzCommandImpl InstanceContainer{ToBuzzCommandImpl()};
FSGIC_FSGBuzzCommandImpl OutBuzzCommandImplContainer;
SGCoreImpl_FSGBuzzCommandImpl_Copy(&InstanceContainer, &OutBuzzCommandImplContainer);
return NewBuzzCommand(Outer, MoveTemp(OutBuzzCommandImplContainer.BuzzCommandImpl));
}
USGBuzzCommand* USGBuzzCommand::Merge(UObject* Outer, const USGBuzzCommand* BuzzCommand) const
{
FSGIC_TSharedPtr_FSGBuzzCommandImpl InstanceContainer{ToBuzzCommandImpl()};
FSGIC_FSGBuzzCommandImpl BuzzCommandImplContainer{BuzzCommand->ToBuzzCommandImpl().Get()};
FSGIC_FSGBuzzCommandImpl OutBuzzCommandImplContainer;
SGCoreImpl_FSGBuzzCommandImpl_Merge(&InstanceContainer, &OutBuzzCommandImplContainer, &BuzzCommandImplContainer);
return NewBuzzCommand(Outer, MoveTemp(OutBuzzCommandImplContainer.BuzzCommandImpl));
}