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

210 lines
7.7 KiB
C++

/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @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/SGCalibrationDataPoint.h"
#include "Runtime/Launch/Resources/Version.h"
#include "SGCoreImpl/SGExportedFunctions.h"
#include "SGInterop/SGIC_FSGCalibrationDataPointImpl.h"
#include "SGInterop/SGIC_FString.h"
#include "SGInterop/SGIC_TArray_FVector.h"
struct USGCalibrationDataPoint::FImpl
{
/************************
* Member variables
************************/
FSGCalibrationDataPointImpl CalibrationDataPointImpl;
/************************
* Owner object
************************/
USGCalibrationDataPoint* Owner;
/************************
* Constructor / Destructor
************************/
explicit FImpl(USGCalibrationDataPoint* InOwner);
~FImpl();
/************************
* Default copy constructor & copy assignment operator
************************/
FImpl(const FImpl& Rhs) = default;
FImpl& operator=(const FImpl& Rhs) = default;
/************************
* Methods
************************/
void SyncUProperties();
void SyncImplObject();
};
USGCalibrationDataPoint* USGCalibrationDataPoint::NewCalibrationDataPoint(
UObject* Outer, const FSGCalibrationDataPointImpl& CalibrationDataPointImpl)
{
USGCalibrationDataPoint* Instance = NewObject<USGCalibrationDataPoint>(Outer);
Instance->SetCalibrationDataPointImpl(CalibrationDataPointImpl);
return Instance;
}
USGCalibrationDataPoint* USGCalibrationDataPoint::NewCalibrationDataPoint(UObject* Outer)
{
FSGIC_FSGCalibrationDataPointImpl OutCalibrationDataPointImplContainer;
SGCoreImpl_FSGCalibrationDataPointImpl_ctor(&OutCalibrationDataPointImplContainer);
return NewCalibrationDataPoint(Outer, MoveTemp(OutCalibrationDataPointImplContainer.CalibrationDataPointImpl));
}
USGCalibrationDataPoint* USGCalibrationDataPoint::NewCalibrationDataPoint(
UObject* Outer, const int32 CurrentStage, const TArray<FVector>& CalibrationValues)
{
FSGIC_FSGCalibrationDataPointImpl OutCalibrationDataPointImplContainer;
FSGIC_TArray_FVector CalibrationValuesContainer{CalibrationValues};
SGCoreImpl_FSGCalibrationDataPointImpl_ctor_CurrentStage_CalibrationValues(
&OutCalibrationDataPointImplContainer, CurrentStage, &CalibrationValuesContainer);
return NewCalibrationDataPoint(Outer, MoveTemp(OutCalibrationDataPointImplContainer.CalibrationDataPointImpl));
}
USGCalibrationDataPoint::USGCalibrationDataPoint()
:
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 )
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
#else
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 ) */
{
FSGIC_FSGCalibrationDataPointImpl OutCalibrationDataPointImplContainer;
SGCoreImpl_FSGCalibrationDataPointImpl_ctor(&OutCalibrationDataPointImplContainer);
Pimpl->CalibrationDataPointImpl = MoveTemp(OutCalibrationDataPointImplContainer.CalibrationDataPointImpl);
Pimpl->SyncUProperties();
}
USGCalibrationDataPoint::USGCalibrationDataPoint(const int32 CurrentStage, const TArray<FVector>& CalibrationValues)
:
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 )
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
#else
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 ) */
{
FSGIC_FSGCalibrationDataPointImpl OutCalibrationDataPointImplContainer;
FSGIC_TArray_FVector CalibrationValuesContainer{CalibrationValues};
SGCoreImpl_FSGCalibrationDataPointImpl_ctor_CurrentStage_CalibrationValues(
&OutCalibrationDataPointImplContainer, CurrentStage, &CalibrationValuesContainer);
Pimpl->CalibrationDataPointImpl = MoveTemp(OutCalibrationDataPointImplContainer.CalibrationDataPointImpl);
Pimpl->SyncUProperties();
}
USGCalibrationDataPoint::USGCalibrationDataPoint(const FSGCalibrationDataPointImpl& CalibrationDataPointImpl)
:
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 )
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
#else
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 ) */
{
SetCalibrationDataPointImpl(CalibrationDataPointImpl);
Pimpl->SyncUProperties();
}
USGCalibrationDataPoint::~USGCalibrationDataPoint() = default;
void USGCalibrationDataPoint::SetCalibrationDataPointImpl(const FSGCalibrationDataPointImpl& CalibrationDataPointImpl)
{
FSGIC_FSGCalibrationDataPointImpl OutCalibrationDataPointContainer;
FSGIC_FSGCalibrationDataPointImpl RhsContainer{CalibrationDataPointImpl};
SGCoreImpl_FSGCalibrationDataPointImpl_ctor_copy(&OutCalibrationDataPointContainer, &RhsContainer);
Pimpl->CalibrationDataPointImpl = MoveTemp(OutCalibrationDataPointContainer.CalibrationDataPointImpl);
}
const FSGCalibrationDataPointImpl& USGCalibrationDataPoint::ToCalibrationDataPointImpl() const
{
Pimpl->SyncImplObject();
return Pimpl->CalibrationDataPointImpl;
}
TArray<FVector> USGCalibrationDataPoint::GetCalibrationValues() const
{
FSGIC_FSGCalibrationDataPointImpl InstanceContainer{ToCalibrationDataPointImpl()};
FSGIC_TArray_FVector OutValuesContainer;
SGCoreImpl_FSGCalibrationDataPointImpl_GetCalibrationValues(&InstanceContainer, &OutValuesContainer);
return MoveTemp(OutValuesContainer.Array);
}
int32 USGCalibrationDataPoint::GetStage() const
{
FSGIC_FSGCalibrationDataPointImpl InstanceContainer{ToCalibrationDataPointImpl()};
return SGCoreImpl_FSGCalibrationDataPointImpl_GetStage(&InstanceContainer);
}
FString USGCalibrationDataPoint::ToLogData(const FString& Delimiter) const
{
FSGIC_FSGCalibrationDataPointImpl InstanceContainer{Pimpl->CalibrationDataPointImpl};
FSGIC_FString DelimiterContainer{Delimiter};
FSGIC_FString OutDataContainer;
SGCoreImpl_FSGCalibrationDataPointImpl_ToLogData(&InstanceContainer, &OutDataContainer, &DelimiterContainer);
return MoveTemp(OutDataContainer.String);
}
USGCalibrationDataPoint::FImpl::FImpl(USGCalibrationDataPoint* InOwner)
: Owner(InOwner)
{
}
USGCalibrationDataPoint::FImpl::~FImpl() = default;
void USGCalibrationDataPoint::FImplDeleter::operator()(const FImpl* P) const
{
delete P;
}
void USGCalibrationDataPoint::FImpl::SyncUProperties()
{
}
void USGCalibrationDataPoint::FImpl::SyncImplObject()
{
}