214 lines
7.1 KiB
C++
214 lines
7.1 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/SGTimedThumpCommandImpl.h"
|
|
|
|
#include "Containers/StringConv.h"
|
|
#include "Runtime/Launch/Resources/Version.h"
|
|
|
|
#include "SGBuildHacks/SGInclude_Core_TimedThumpCommand.h"
|
|
#include "SGCoreImpl/SGThumperCommandImpl.h"
|
|
|
|
struct FSGTimedThumpCommandImpl::FImpl
|
|
{
|
|
/************************
|
|
* Member variables
|
|
************************/
|
|
|
|
FTimedThumpCommandType TimedThumpCommand;
|
|
|
|
/************************
|
|
* Owner object
|
|
************************/
|
|
|
|
FSGTimedThumpCommandImpl* Owner;
|
|
|
|
/************************
|
|
* Constructor / Destructor
|
|
************************/
|
|
|
|
explicit FImpl(FSGTimedThumpCommandImpl* InOwner);
|
|
~FImpl();
|
|
|
|
/************************
|
|
* Default copy constructor & copy assignment operator
|
|
************************/
|
|
|
|
FImpl(const FImpl& Rhs) = default;
|
|
FImpl& operator=(const FImpl& Rhs) = default;
|
|
};
|
|
|
|
FSGTimedThumpCommandImpl::FSGTimedThumpCommandImpl()
|
|
:
|
|
#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 ) */
|
|
{
|
|
}
|
|
|
|
FSGTimedThumpCommandImpl::FSGTimedThumpCommandImpl(const int32 Magnitude,
|
|
const float DurationSeconds, const float StartTimeSeconds)
|
|
:
|
|
#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 ) */
|
|
{
|
|
Pimpl->TimedThumpCommand = FTimedThumpCommandType(Magnitude, DurationSeconds, StartTimeSeconds);
|
|
}
|
|
|
|
FSGTimedThumpCommandImpl::FSGTimedThumpCommandImpl(const FSGThumperCommandImpl& BaseCommand,
|
|
const float DurationSeconds, const float StartTimeSeconds)
|
|
:
|
|
#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 ) */
|
|
{
|
|
Pimpl->TimedThumpCommand = FTimedThumpCommandType(BaseCommand.ToThumperCommand(), DurationSeconds,
|
|
StartTimeSeconds);
|
|
}
|
|
|
|
FSGTimedThumpCommandImpl::FSGTimedThumpCommandImpl(const FTimedThumpCommandType& SGTimedThumpCommand)
|
|
:
|
|
#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 ) */
|
|
{
|
|
Pimpl->TimedThumpCommand = SGTimedThumpCommand;
|
|
}
|
|
|
|
FSGTimedThumpCommandImpl::FSGTimedThumpCommandImpl(const FSGTimedThumpCommandImpl& Rhs)
|
|
:
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 )
|
|
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 > 22 ) */
|
|
{
|
|
Pimpl->Owner = this;
|
|
}
|
|
|
|
FSGTimedThumpCommandImpl::FSGTimedThumpCommandImpl(FSGTimedThumpCommandImpl&& Rhs) noexcept = default;
|
|
|
|
FSGTimedThumpCommandImpl::~FSGTimedThumpCommandImpl() = default;
|
|
|
|
FSGTimedThumpCommandImpl& FSGTimedThumpCommandImpl::operator=(const FSGTimedThumpCommandImpl& Rhs)
|
|
{
|
|
*Pimpl = *Rhs.Pimpl;
|
|
Pimpl->Owner = this;
|
|
return *this;
|
|
}
|
|
|
|
FSGTimedThumpCommandImpl& FSGTimedThumpCommandImpl::operator=(FSGTimedThumpCommandImpl&& Rhs) noexcept = default;
|
|
|
|
const FSGTimedThumpCommandImpl::FTimedThumpCommandType& FSGTimedThumpCommandImpl::ToTimedThumpCommand() const
|
|
{
|
|
return Pimpl->TimedThumpCommand;
|
|
}
|
|
|
|
int32 FSGTimedThumpCommandImpl::GetMagnitude() const
|
|
{
|
|
return Pimpl->TimedThumpCommand.GetMagnitude();
|
|
}
|
|
|
|
void FSGTimedThumpCommandImpl::SetMagnitude(const int32 Magnitude)
|
|
{
|
|
Pimpl->TimedThumpCommand.SetMagnitude(Magnitude);
|
|
}
|
|
|
|
float FSGTimedThumpCommandImpl::GetDuration() const
|
|
{
|
|
return Pimpl->TimedThumpCommand.GetDuration();
|
|
}
|
|
|
|
void FSGTimedThumpCommandImpl::SetDuration(const float Duration)
|
|
{
|
|
Pimpl->TimedThumpCommand.SetDuration(Duration);
|
|
}
|
|
|
|
float FSGTimedThumpCommandImpl::GetElapsedTime() const
|
|
{
|
|
return Pimpl->TimedThumpCommand.GetElapsedTime();
|
|
}
|
|
|
|
void FSGTimedThumpCommandImpl::SetElapsedTime(const float ElapsedTime)
|
|
{
|
|
Pimpl->TimedThumpCommand.SetElapsedTime(ElapsedTime);
|
|
}
|
|
|
|
bool FSGTimedThumpCommandImpl::HasTimeElapsed() const
|
|
{
|
|
return Pimpl->TimedThumpCommand.HasTimeElapsed();
|
|
}
|
|
|
|
FSGTimedThumpCommandImpl FSGTimedThumpCommandImpl::Copy(const bool bCopyElapsed) const
|
|
{
|
|
return FSGTimedThumpCommandImpl(Pimpl->TimedThumpCommand.Copy(bCopyElapsed));
|
|
}
|
|
|
|
void FSGTimedThumpCommandImpl::Update(const float DeltaSeconds)
|
|
{
|
|
Pimpl->TimedThumpCommand.Update(DeltaSeconds);
|
|
}
|
|
|
|
bool FSGTimedThumpCommandImpl::Equals(const FSGThumperCommandImpl& SGThumperCommandImpl) const
|
|
{
|
|
return Pimpl->TimedThumpCommand.Equals(SGThumperCommandImpl.ToThumperCommand());
|
|
}
|
|
|
|
FString FSGTimedThumpCommandImpl::ToString() const
|
|
{
|
|
return UTF8_TO_TCHAR(Pimpl->TimedThumpCommand.ToString().c_str());
|
|
}
|
|
|
|
FSGTimedThumpCommandImpl::FImpl::FImpl(FSGTimedThumpCommandImpl* InOwner)
|
|
: TimedThumpCommand(),
|
|
Owner(InOwner)
|
|
{
|
|
}
|
|
|
|
FSGTimedThumpCommandImpl::FImpl::~FImpl() = default;
|
|
|
|
void FSGTimedThumpCommandImpl::FImplDeleter::operator()(const FSGTimedThumpCommandImpl::FImpl* P) const
|
|
{
|
|
delete P;
|
|
} |