/** * @file * * @author Mamadou Babaei * * @section LICENSE * * (The MIT License) * * Copyright (c) 2020 - 2022 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/SGFingerCommand.h" #include "Runtime/Launch/Resources/Version.h" #include "SGCoreImpl/SGExportedFunctions.h" #include "SGInterop/SGIC_FSGBuzzCommandImpl.h" #include "SGInterop/SGIC_FSGFingerCommandImpl.h" #include "SGInterop/SGIC_FSGForceFeedbackCommandImpl.h" #include "SGInterop/SGIC_FSGTimedBuzzCommandImpl.h" #include "SGInterop/SGIC_FString.h" #include "SGInterop/SGIC_TArray_int32.h" #include "SGInterop/SGIC_TSharedPtr_FSGBuzzCommandImpl.h" #include "SGInterop/SGIC_TSharedPtr_FSGFingerCommandImpl.h" #include "SGInterop/SGIC_TSharedPtr_FSGForceFeedbackCommandImpl.h" #include "SGInterop/SGIC_TSharedPtr_FSGTimedBuzzCommandImpl.h" struct USGFingerCommand::FImpl { /************************ * Member variables ************************/ TSharedPtr FingerCommandImpl; /************************ * Owner object ************************/ USGFingerCommand* Owner; /************************ * Constructor / Destructor ************************/ explicit FImpl(USGFingerCommand* InOwner); ~FImpl(); /************************ * Default copy constructor & copy assignment operator ************************/ FImpl(const FImpl& Rhs) = default; FImpl& operator=(const FImpl& Rhs) = default; /************************ * Methods ************************/ void SyncUProperties(); void SyncImplObject(); }; USGFingerCommand::USGFingerCommand() : #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { FSGIC_TSharedPtr_FSGFingerCommandImpl OutSharedPtrContainer; SGCoreImpl_FSGFingerCommandImpl_ctor_MakeShared(&OutSharedPtrContainer); Pimpl->FingerCommandImpl = MoveTemp(OutSharedPtrContainer.Ptr); Pimpl->SyncUProperties(); } USGFingerCommand::USGFingerCommand(const TArray& InLevels) : #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { FSGIC_TSharedPtr_FSGFingerCommandImpl OutSharedPtrContainer; FSGIC_TArray_int32 LevelsContainer{InLevels}; SGCoreImpl_FSGFingerCommandImpl_ctor_Levels_MakeShared(&OutSharedPtrContainer, &LevelsContainer); Pimpl->FingerCommandImpl = MoveTemp(OutSharedPtrContainer.Ptr); Pimpl->SyncUProperties(); } USGFingerCommand::USGFingerCommand(const FSGFingerCommandImpl& FingerCommandImpl) : #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { FSGIC_TSharedPtr_FSGFingerCommandImpl OutSharedPtrContainer; FSGIC_FSGFingerCommandImpl RhsContainer{FingerCommandImpl}; SGCoreImpl_FSGFingerCommandImpl_ctor_copy_MakeShared( &OutSharedPtrContainer, &RhsContainer); Pimpl->FingerCommandImpl = MoveTemp(OutSharedPtrContainer.Ptr); Pimpl->SyncUProperties(); } USGFingerCommand::USGFingerCommand(const FSGBuzzCommandImpl& BuzzCommandImpl) : #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { FSGIC_TSharedPtr_FSGBuzzCommandImpl OutSharedPtrContainer; FSGIC_FSGBuzzCommandImpl RhsContainer{BuzzCommandImpl}; SGCoreImpl_FSGBuzzCommandImpl_ctor_copy_MakeShared( &OutSharedPtrContainer, &RhsContainer); Pimpl->FingerCommandImpl = MoveTemp(OutSharedPtrContainer.Ptr); Pimpl->SyncUProperties(); } USGFingerCommand::USGFingerCommand(const FSGForceFeedbackCommandImpl& ForceFeedbackCommandImpl) : #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { FSGIC_TSharedPtr_FSGForceFeedbackCommandImpl OutSharedPtrContainer; FSGIC_FSGForceFeedbackCommandImpl RhsContainer{ForceFeedbackCommandImpl}; SGCoreImpl_FSGForceFeedbackCommandImpl_ctor_copy_MakeShared( &OutSharedPtrContainer, &RhsContainer); Pimpl->FingerCommandImpl = MoveTemp(OutSharedPtrContainer.Ptr); Pimpl->SyncUProperties(); } USGFingerCommand::USGFingerCommand(const FSGTimedBuzzCommandImpl& TimedBuzzCommandImpl) : #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl OutSharedPtrContainer; FSGIC_FSGTimedBuzzCommandImpl RhsContainer{TimedBuzzCommandImpl}; SGCoreImpl_FSGTimedBuzzCommandImpl_ctor_copy_MakeShared( &OutSharedPtrContainer, &RhsContainer); Pimpl->FingerCommandImpl = MoveTemp(OutSharedPtrContainer.Ptr); Pimpl->SyncUProperties(); } USGFingerCommand::USGFingerCommand(TSharedRef FingerCommandImpl) : #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { Pimpl->FingerCommandImpl = MoveTemp(FingerCommandImpl); Pimpl->SyncUProperties(); } USGFingerCommand::USGFingerCommand(TSharedRef BuzzCommandImpl) : #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { Pimpl->FingerCommandImpl = MoveTemp(BuzzCommandImpl); Pimpl->SyncUProperties(); } USGFingerCommand::USGFingerCommand(TSharedRef ForceFeedbackCommandImpl) : #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { Pimpl->FingerCommandImpl = MoveTemp(ForceFeedbackCommandImpl); Pimpl->SyncUProperties(); } USGFingerCommand::USGFingerCommand(TSharedRef TimedBuzzCommandImpl) : #if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */ { Pimpl->FingerCommandImpl = MoveTemp(TimedBuzzCommandImpl); Pimpl->SyncUProperties(); } USGFingerCommand::~USGFingerCommand() = default; void USGFingerCommand::SetFingerCommandImpl(const FSGFingerCommandImpl& FingerCommandImpl) { FSGIC_TSharedPtr_FSGFingerCommandImpl OutSharedPtrContainer; FSGIC_FSGFingerCommandImpl RhsContainer{FingerCommandImpl}; SGCoreImpl_FSGFingerCommandImpl_ctor_copy_MakeShared(&OutSharedPtrContainer, &RhsContainer); Pimpl->FingerCommandImpl = MoveTemp(OutSharedPtrContainer.Ptr); } void USGFingerCommand::SetFingerCommandImpl(const FSGBuzzCommandImpl& BuzzCommandImpl) { FSGIC_TSharedPtr_FSGBuzzCommandImpl OutSharedPtrContainer; FSGIC_FSGBuzzCommandImpl RhsContainer{BuzzCommandImpl}; SGCoreImpl_FSGBuzzCommandImpl_ctor_copy_MakeShared(&OutSharedPtrContainer, &RhsContainer); Pimpl->FingerCommandImpl = MoveTemp(OutSharedPtrContainer.Ptr); } void USGFingerCommand::SetFingerCommandImpl(const FSGForceFeedbackCommandImpl& ForceFeedbackCommandImpl) { FSGIC_TSharedPtr_FSGForceFeedbackCommandImpl OutSharedPtrContainer; FSGIC_FSGForceFeedbackCommandImpl RhsContainer{ForceFeedbackCommandImpl}; SGCoreImpl_FSGForceFeedbackCommandImpl_ctor_copy_MakeShared(&OutSharedPtrContainer, &RhsContainer); Pimpl->FingerCommandImpl = MoveTemp(OutSharedPtrContainer.Ptr); } void USGFingerCommand::SetFingerCommandImpl(const FSGTimedBuzzCommandImpl& TimedBuzzCommandImpl) { FSGIC_TSharedPtr_FSGTimedBuzzCommandImpl OutSharedPtrContainer; FSGIC_FSGTimedBuzzCommandImpl RhsContainer{TimedBuzzCommandImpl}; SGCoreImpl_FSGTimedBuzzCommandImpl_ctor_copy_MakeShared(&OutSharedPtrContainer, &RhsContainer); Pimpl->FingerCommandImpl = MoveTemp(OutSharedPtrContainer.Ptr); } void USGFingerCommand::SetFingerCommandImpl(TSharedRef FingerCommandImpl) { Pimpl->FingerCommandImpl = MoveTemp(FingerCommandImpl); } void USGFingerCommand::SetFingerCommandImpl(TSharedRef BuzzCommandImpl) { Pimpl->FingerCommandImpl = MoveTemp(BuzzCommandImpl); } void USGFingerCommand::SetFingerCommandImpl(TSharedRef ForceFeedbackCommandImpl) { Pimpl->FingerCommandImpl = MoveTemp(ForceFeedbackCommandImpl); } void USGFingerCommand::SetFingerCommandImpl(TSharedRef TimedBuzzCommandImpl) { Pimpl->FingerCommandImpl = MoveTemp(TimedBuzzCommandImpl); } TSharedRef USGFingerCommand::ToFingerCommandImpl() const { SyncImplObject(); return Pimpl->FingerCommandImpl.ToSharedRef(); } void USGFingerCommand::SyncImplObject() const { Pimpl->SyncImplObject(); } void USGFingerCommand::SyncUProperties() { Pimpl->SyncUProperties(); } TArray USGFingerCommand::GetLevels() const { FSGIC_TSharedPtr_FSGFingerCommandImpl InstanceContainer{ToFingerCommandImpl()}; FSGIC_TArray_int32 OutLevelsContainer; SGCoreImpl_FSGFingerCommandImpl_GetLevels(&InstanceContainer, &OutLevelsContainer); return MoveTemp(OutLevelsContainer.Array); } int32 USGFingerCommand::GetLevel(const int32 Finger) const { SyncImplObject(); FSGIC_TSharedPtr_FSGFingerCommandImpl InstanceContainer{ToFingerCommandImpl()}; const int32 Level = SGCoreImpl_FSGFingerCommandImpl_GetLevel(&InstanceContainer, Finger); return Level; } void USGFingerCommand::SetLevel(const int32 Finger, const int32 Value) { SyncImplObject(); FSGIC_TSharedPtr_FSGFingerCommandImpl InstanceContainer{ToFingerCommandImpl()}; SGCoreImpl_FSGFingerCommandImpl_SetLevel(&InstanceContainer, Finger, Value); SyncUProperties(); } bool USGFingerCommand::Equals(const USGFingerCommand* FingerCommand) const { SyncImplObject(); FSGIC_TSharedPtr_FSGFingerCommandImpl InstanceContainer{ToFingerCommandImpl()}; FSGIC_FSGFingerCommandImpl FingerCommandImplContainer{FingerCommand->ToFingerCommandImpl().Get()}; const bool bEquals = SGCoreImpl_FSGFingerCommandImpl_Equals(&InstanceContainer, &FingerCommandImplContainer); return bEquals; } FString USGFingerCommand::ToString() const { SyncImplObject(); FSGIC_TSharedPtr_FSGFingerCommandImpl InstanceContainer{ToFingerCommandImpl()}; FSGIC_FString OutStringContainer; SGCoreImpl_FSGFingerCommandImpl_ToString(&InstanceContainer, &OutStringContainer); return MoveTemp(OutStringContainer.String); } USGFingerCommand::FImpl::FImpl(USGFingerCommand* InOwner) : Owner(InOwner) { } USGFingerCommand::FImpl::~FImpl() = default; void USGFingerCommand::FImplDeleter::operator()(const FImpl* P) const { delete P; } void USGFingerCommand::FImpl::SyncUProperties() { } void USGFingerCommand::FImpl::SyncImplObject() { }