Files
Plugin/Source/SenseGloveCoreImpl/Private/SGCoreImpl/SGThumperCommandImpl.cpp
T

182 lines
5.9 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 "SGCoreImpl/SGThumperCommandImpl.h"
#include "Runtime/Launch/Resources/Version.h"
#include "SGBuildHacks/SGInclude_Core_ThumperCommand.h"
struct FSGThumperCommandImpl::FImpl
{
/************************
* Member variables
************************/
FThumperCommandType ThumperCommand;
/************************
* Owner object
************************/
FSGThumperCommandImpl* Owner;
/************************
* Constructor / Destructor
************************/
explicit FImpl(FSGThumperCommandImpl* InOwner);
~FImpl();
/************************
* Default copy constructor & copy assignment operator
************************/
FImpl(const FImpl& Rhs) = default;
FImpl& operator=(const FImpl& Rhs) = default;
};
const FSGThumperCommandImpl& FSGThumperCommandImpl::Off()
{
static const FSGThumperCommandImpl OffCmd(0);
return OffCmd;
}
FSGThumperCommandImpl::FSGThumperCommandImpl()
:
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
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 > 24 ) */
{
}
FSGThumperCommandImpl::FSGThumperCommandImpl(const int32 Magnitude)
:
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
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 > 24 ) */
{
Pimpl->ThumperCommand = FThumperCommandType(Magnitude);
}
FSGThumperCommandImpl::FSGThumperCommandImpl(const FThumperCommandType& ThumperCommand)
:
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
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 > 24 ) */
{
Pimpl->ThumperCommand = ThumperCommand;
}
FSGThumperCommandImpl::FSGThumperCommandImpl(const FSGThumperCommandImpl& Rhs)
:
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{*Rhs.Pimpl}, PimplDeleter))
#else
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{*Rhs.Pimpl}))
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
{
Pimpl->Owner = this;
}
FSGThumperCommandImpl::FSGThumperCommandImpl(FSGThumperCommandImpl&& Rhs)
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
noexcept
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
= default;
FSGThumperCommandImpl::~FSGThumperCommandImpl() = default;
FSGThumperCommandImpl& FSGThumperCommandImpl::operator=(const FSGThumperCommandImpl& Rhs)
{
*Pimpl = *Rhs.Pimpl;
Pimpl->Owner = this;
return *this;
}
FSGThumperCommandImpl& FSGThumperCommandImpl::operator=(FSGThumperCommandImpl&& Rhs)
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
noexcept
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
= default;
const FSGThumperCommandImpl::FThumperCommandType& FSGThumperCommandImpl::ToThumperCommand() const
{
return Pimpl->ThumperCommand;
}
int32 FSGThumperCommandImpl::GetMagnitude() const
{
return Pimpl->ThumperCommand.GetMagnitude();
}
void FSGThumperCommandImpl::SetMagnitude(const int32 Magnitude)
{
Pimpl->ThumperCommand.SetMagnitude(Magnitude);
}
FSGThumperCommandImpl FSGThumperCommandImpl::Copy() const
{
return FSGThumperCommandImpl(Pimpl->ThumperCommand.Copy());
}
FSGThumperCommandImpl FSGThumperCommandImpl::Merge(const FSGThumperCommandImpl& ThumperCommandImpl) const
{
return FSGThumperCommandImpl(Pimpl->ThumperCommand.Merge(ThumperCommandImpl.ToThumperCommand()));
}
bool FSGThumperCommandImpl::Equals(const FSGThumperCommandImpl& ThumperCommandImpl) const
{
return Pimpl->ThumperCommand.Equals(ThumperCommandImpl.ToThumperCommand());
}
FSGThumperCommandImpl::FImpl::FImpl(FSGThumperCommandImpl* InOwner)
: ThumperCommand(0),
Owner(InOwner)
{
}
FSGThumperCommandImpl::FImpl::~FImpl() = default;
void FSGThumperCommandImpl::FImplDeleter::operator()(const FSGThumperCommandImpl::FImpl* P) const
{
delete P;
}