/** * @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 "SGCoreImpl/SGCalibrationDataPointImpl.h" #include #include #include "Containers/StringConv.h" #include "Runtime/Launch/Resources/Version.h" #include "SGBuildHacks/SGInclude_Core_CalibrationDataPoint.h" #include "SGBuildHacks/SGInclude_Core_Vect3D.h" #include "SGCoreImpl/SGVect3DImpl.h" #include "SGUtils/SGArrayUtils.h" struct FSGCalibrationDataPointImpl::FImpl { /************************ * Member variables ************************/ FCalibrationDataPointType CalibrationDataPoint; /************************ * Owner object ************************/ FSGCalibrationDataPointImpl* Owner; /************************ * Constructor / Destructor ************************/ explicit FImpl(FSGCalibrationDataPointImpl* InOwner); ~FImpl(); /************************ * Default copy constructor & copy assignment operator ************************/ FImpl(const FImpl& Rhs) = default; FImpl& operator=(const FImpl& Rhs) = default; }; FSGCalibrationDataPointImpl::FSGCalibrationDataPointImpl() : #if SG_CPP17 Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* SG_CPP17 */ { } FSGCalibrationDataPointImpl::FSGCalibrationDataPointImpl(const int32 CurrentStage, const TArray& CalibrationValues) : #if SG_CPP17 Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* SG_CPP17 */ { std::vector Values( FSGArrayUtils::ToStdVector( CalibrationValues)); Pimpl->CalibrationDataPoint = FCalibrationDataPointType(CurrentStage, MoveTemp(Values)); } FSGCalibrationDataPointImpl::FSGCalibrationDataPointImpl(const FCalibrationDataPointType& CalibrationDataPoint) : #if SG_CPP17 Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{this})) #endif /* SG_CPP17 */ { Pimpl->CalibrationDataPoint = CalibrationDataPoint; } FSGCalibrationDataPointImpl::FSGCalibrationDataPointImpl(const FSGCalibrationDataPointImpl& Rhs) : #if SG_CPP17 Pimpl(TUniquePtr(new FImpl{*Rhs.Pimpl}, PimplDeleter)) #else Pimpl(TUniquePtr(new FImpl{*Rhs.Pimpl})) #endif /* SG_CPP17 */ { Pimpl->Owner = this; } FSGCalibrationDataPointImpl::FSGCalibrationDataPointImpl(FSGCalibrationDataPointImpl&& Rhs) #if SG_CPP17 noexcept #endif /* SG_CPP17 */ = default; FSGCalibrationDataPointImpl::~FSGCalibrationDataPointImpl() = default; FSGCalibrationDataPointImpl& FSGCalibrationDataPointImpl::operator=(const FSGCalibrationDataPointImpl& Rhs) { *Pimpl = *Rhs.Pimpl; Pimpl->Owner = this; return *this; } FSGCalibrationDataPointImpl& FSGCalibrationDataPointImpl::operator=(FSGCalibrationDataPointImpl&& Rhs) #if SG_CPP17 noexcept #endif /* SG_CPP17 */ = default; const FSGCalibrationDataPointImpl::FCalibrationDataPointType& FSGCalibrationDataPointImpl::ToCalibrationDataPoint() const { return Pimpl->CalibrationDataPoint; } TArray FSGCalibrationDataPointImpl::GetCalibrationValues() const { std::vector Values(Pimpl->CalibrationDataPoint.GetCalibrationValues()); TArray CalibrationValues{ FSGArrayUtils::FromStdVector( MoveTemp(Values)) }; return CalibrationValues; } void FSGCalibrationDataPointImpl::SetCalibrationValues(const TArray& CalibrationValues) { std::vector CalibrationValuesVector{ FSGArrayUtils::ToStdVector( CalibrationValues) }; Pimpl->CalibrationDataPoint.SetCalibrationValues(MoveTemp(CalibrationValuesVector)); } int32 FSGCalibrationDataPointImpl::GetStage() const { return Pimpl->CalibrationDataPoint.GetStage(); } void FSGCalibrationDataPointImpl::SetStage(const int32 Stage) { Pimpl->CalibrationDataPoint.SetStage(Stage); } FString FSGCalibrationDataPointImpl::ToLogData(const FString& Delimiter) const { std::string DelimiterString(TCHAR_TO_UTF8(*Delimiter)); FString LogData(UTF8_TO_TCHAR(Pimpl->CalibrationDataPoint.ToLogData(MoveTemp(DelimiterString)).c_str())); return LogData; } FSGCalibrationDataPointImpl::FImpl::FImpl(FSGCalibrationDataPointImpl* InOwner) : Owner(InOwner) { } FSGCalibrationDataPointImpl::FImpl::~FImpl() = default; void FSGCalibrationDataPointImpl::FImplDeleter::operator()(const FImpl* P) const { delete P; }