/** * @file * * @author Mamadou Babaei * * @section LICENSE * * (The MIT License) * * Copyright (c) 2020 - 2024 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/SGInterpolationSet.h" #include "SGCoreImpl/SGExportedFunctions.h" #include "SGCoreImpl/SGInterpolationSetImpl.h" #include "SGInterop/SGIC_FSGInterpolationSetImpl.h" #include "SGInterop/SGIC_FString.h" struct USGInterpolationSet::FImpl { /************************ * Member variables ************************/ FSGInterpolationSetImpl InterpolationSetImpl; /************************ * Owner object ************************/ USGInterpolationSet* Owner; /************************ * Constructor / Destructor ************************/ explicit FImpl(USGInterpolationSet* InOwner); ~FImpl(); /************************ * Default copy constructor & copy assignment operator ************************/ FImpl(const FImpl& Rhs) = default; FImpl& operator=(const FImpl& Rhs) = default; }; USGInterpolationSet* USGInterpolationSet::NewInterpolationSet(UObject* Outer, const FSGInterpolationSetImpl& InterpolationSetImpl) { USGInterpolationSet* Instance = NewObject(Outer); Instance->SetInterpolationSetImpl(InterpolationSetImpl); return Instance; } USGInterpolationSet* USGInterpolationSet::NewInterpolationSet(UObject* Outer) { FSGIC_FSGInterpolationSetImpl OutInterpolationSetImplContainer; SGCoreImpl_FSGInterpolationSetImpl_ctor(&OutInterpolationSetImplContainer); return NewInterpolationSet(Outer, MoveTemp(OutInterpolationSetImplContainer.InterpolationSetImpl)); } USGInterpolationSet* USGInterpolationSet::NewInterpolationSet( UObject* Outer, const float From1, const float From2, const float To1, const float To2) { FSGIC_FSGInterpolationSetImpl OutInterpolationSetImplContainer; SGCoreImpl_FSGInterpolationSetImpl_ctor_From1_From2_To1_To2(&OutInterpolationSetImplContainer, From1, From2, To1, To2); return NewInterpolationSet(Outer, MoveTemp(OutInterpolationSetImplContainer.InterpolationSetImpl)); } USGInterpolationSet* USGInterpolationSet::NewInterpolationSet( UObject* Outer, const float From1, const float From2, const float To1, const float To2, const float Min, const float Max) { FSGIC_FSGInterpolationSetImpl OutInterpolationSetImplContainer; SGCoreImpl_FSGInterpolationSetImpl_ctor_From1_From2_To1_To2_Min_Max(&OutInterpolationSetImplContainer, From1, From2, To1, To2, Min, Max); return NewInterpolationSet(Outer, MoveTemp(OutInterpolationSetImplContainer.InterpolationSetImpl)); } USGInterpolationSet* USGInterpolationSet::Deserialize(UObject* Outer, const FString& SerializedString) { FSGIC_FSGInterpolationSetImpl OutInterpolationSetImplContainer; FSGIC_FString SerializedStringContainer{SerializedString}; SGCoreImpl_FSGInterpolationSetImpl_Deserialize(&OutInterpolationSetImplContainer, &SerializedStringContainer); return NewInterpolationSet(Outer, MoveTemp(OutInterpolationSetImplContainer.InterpolationSetImpl)); } USGInterpolationSet::USGInterpolationSet() : Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) { FSGIC_FSGInterpolationSetImpl OutInterpolationSetImplContainer; SGCoreImpl_FSGInterpolationSetImpl_ctor(&OutInterpolationSetImplContainer); Pimpl->InterpolationSetImpl = MoveTemp(OutInterpolationSetImplContainer.InterpolationSetImpl); } USGInterpolationSet::USGInterpolationSet(const float From1, const float From2, const float To1, const float To2) : Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) { FSGIC_FSGInterpolationSetImpl OutInterpolationSetImplContainer; SGCoreImpl_FSGInterpolationSetImpl_ctor_From1_From2_To1_To2(&OutInterpolationSetImplContainer, From1, From2, To1, To2); Pimpl->InterpolationSetImpl = MoveTemp(OutInterpolationSetImplContainer.InterpolationSetImpl); } USGInterpolationSet::USGInterpolationSet(const float From1, const float From2, const float To1, const float To2, const float Min, const float Max) : Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) { FSGIC_FSGInterpolationSetImpl OutInterpolationSetImplContainer; SGCoreImpl_FSGInterpolationSetImpl_ctor_From1_From2_To1_To2_Min_Max(&OutInterpolationSetImplContainer, From1, From2, To1, To2, Min, Max); Pimpl->InterpolationSetImpl = MoveTemp(OutInterpolationSetImplContainer.InterpolationSetImpl); } USGInterpolationSet::USGInterpolationSet(const FSGInterpolationSetImpl& InterpolationSetImpl) : Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) { SetInterpolationSetImpl(InterpolationSetImpl); } USGInterpolationSet::~USGInterpolationSet() = default; void USGInterpolationSet::SetInterpolationSetImpl(const FSGInterpolationSetImpl& InterpolationSetImpl) { FSGIC_FSGInterpolationSetImpl OutInterpolationSetContainer; FSGIC_FSGInterpolationSetImpl RhsContainer{InterpolationSetImpl}; SGCoreImpl_FSGInterpolationSetImpl_ctor_copy(&OutInterpolationSetContainer, &RhsContainer); Pimpl->InterpolationSetImpl = MoveTemp(OutInterpolationSetContainer.InterpolationSetImpl); } const FSGInterpolationSetImpl& USGInterpolationSet::ToInterpolationSetImpl() const { return Pimpl->InterpolationSetImpl; } float USGInterpolationSet::GetX0() const { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; return SGCoreImpl_FSGInterpolationSetImpl_GetX0(&InstanceContainer); } void USGInterpolationSet::SetX0(const float X0) { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; SGCoreImpl_FSGInterpolationSetImpl_SetX0(&InstanceContainer, X0); } float USGInterpolationSet::GetX1() const { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; return SGCoreImpl_FSGInterpolationSetImpl_GetX1(&InstanceContainer); } void USGInterpolationSet::SetX1(const float X1) { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; SGCoreImpl_FSGInterpolationSetImpl_SetX1(&InstanceContainer, X1); } float USGInterpolationSet::GetY0() const { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; return SGCoreImpl_FSGInterpolationSetImpl_GetY0(&InstanceContainer); } void USGInterpolationSet::SetY0(const float Y0) { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; SGCoreImpl_FSGInterpolationSetImpl_SetY0(&InstanceContainer, Y0); } float USGInterpolationSet::GetY1() const { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; return SGCoreImpl_FSGInterpolationSetImpl_GetY1(&InstanceContainer); } void USGInterpolationSet::SetY1(const float Y1) { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; SGCoreImpl_FSGInterpolationSetImpl_SetY1(&InstanceContainer, Y1); } float USGInterpolationSet::GetMin() const { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; return SGCoreImpl_FSGInterpolationSetImpl_GetMin(&InstanceContainer); } void USGInterpolationSet::SetMin(const float Min) { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; SGCoreImpl_FSGInterpolationSetImpl_SetMin(&InstanceContainer, Min); } float USGInterpolationSet::GetMax() const { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; return SGCoreImpl_FSGInterpolationSetImpl_GetMax(&InstanceContainer); } void USGInterpolationSet::SetMax(const float Max) { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; SGCoreImpl_FSGInterpolationSetImpl_SetMax(&InstanceContainer, Max); } float USGInterpolationSet::Get(const float Value, const bool bLimit, const bool bNormalizeAngle) const { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; return SGCoreImpl_FSGInterpolationSetImpl_Get(&InstanceContainer, Value, bLimit, bNormalizeAngle); } bool USGInterpolationSet::Equals(const USGInterpolationSet* InterpolationSet) const { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; FSGIC_FSGInterpolationSetImpl InterpolationSetContainer{InterpolationSet->ToInterpolationSetImpl()}; return SGCoreImpl_FSGInterpolationSetImpl_Equals(&InstanceContainer, &InterpolationSetContainer); } FString USGInterpolationSet::ToString() const { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; FSGIC_FString OutStringContainer; SGCoreImpl_FSGInterpolationSetImpl_ToString(&InstanceContainer, &OutStringContainer); return MoveTemp(OutStringContainer.String); } FString USGInterpolationSet::ToString(const bool bLimits) const { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; FSGIC_FString OutStringContainer; SGCoreImpl_FSGInterpolationSetImpl_ToString_bLimits(&InstanceContainer, &OutStringContainer, bLimits); return MoveTemp(OutStringContainer.String); } FString USGInterpolationSet::SGSerialize() const { FSGIC_FSGInterpolationSetImpl InstanceContainer{ToInterpolationSetImpl()}; FSGIC_FString OutStringContainer; SGCoreImpl_FSGInterpolationSetImpl_Serialize(&InstanceContainer, &OutStringContainer); return MoveTemp(OutStringContainer.String); } USGInterpolationSet::FImpl::FImpl(USGInterpolationSet* InOwner) : Owner(InOwner) { } USGInterpolationSet::FImpl::~FImpl() = default; void USGInterpolationSet::FImplDeleter::operator()(const FImpl* P) const { delete P; }