262 lines
9.1 KiB
C++
262 lines
9.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/SGTimedBuzzCommandImpl.h"
|
|
|
|
#include "SGBuildHacks/SGInclude_Core_TimedBuzzCommand.h"
|
|
#include "SGCoreImpl/SGCoreEnumCast.h"
|
|
#include "SGUtils/SGArrayUtils.h"
|
|
|
|
struct FSGTimedBuzzCommandImpl::FImpl
|
|
{
|
|
/************************
|
|
* Member variables
|
|
************************/
|
|
|
|
|
|
/************************
|
|
* Owner object
|
|
************************/
|
|
|
|
FSGTimedBuzzCommandImpl* Owner;
|
|
|
|
/************************
|
|
* Constructor / Destructor
|
|
************************/
|
|
|
|
explicit FImpl(FSGTimedBuzzCommandImpl* InOwner);
|
|
~FImpl();
|
|
|
|
/************************
|
|
* Default copy constructor & copy assignment operator
|
|
************************/
|
|
|
|
FImpl(const FImpl& Rhs) = default;
|
|
FImpl& operator=(const FImpl& Rhs) = default;
|
|
};
|
|
|
|
FSGTimedBuzzCommandImpl::FSGTimedBuzzCommandImpl()
|
|
: FSGBuzzCommandImpl(MakeShared<FTimedBuzzCommandType>()),
|
|
#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 ) */
|
|
{
|
|
}
|
|
|
|
FSGTimedBuzzCommandImpl::FSGTimedBuzzCommandImpl(const ESGFinger Finger, const int32 Magnitude,
|
|
const float DurationSeconds, const float StartTimeSeconds)
|
|
: FSGBuzzCommandImpl(MakeShared<FTimedBuzzCommandType>(FSGCoreEnumCast::ToEFinger(Finger), Magnitude,
|
|
DurationSeconds, StartTimeSeconds)),
|
|
#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 ) */
|
|
{
|
|
}
|
|
|
|
FSGTimedBuzzCommandImpl::FSGTimedBuzzCommandImpl(const FSGBuzzCommandImpl& BaseCommand,
|
|
const float DurationSeconds, const float StartTimeSeconds)
|
|
: FSGBuzzCommandImpl(MakeShared<FTimedBuzzCommandType>(
|
|
BaseCommand.ToBuzzCommand(), DurationSeconds, StartTimeSeconds)),
|
|
#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 ) */
|
|
{
|
|
}
|
|
|
|
FSGTimedBuzzCommandImpl::FSGTimedBuzzCommandImpl(const FTimedBuzzCommandType& TimedBuzzCommand)
|
|
: FSGBuzzCommandImpl(MakeShared<FTimedBuzzCommandType>(TimedBuzzCommand)),
|
|
#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 ) */
|
|
{
|
|
}
|
|
|
|
FSGTimedBuzzCommandImpl::FSGTimedBuzzCommandImpl(const TSharedRef<FTimedBuzzCommandType> TimedBuzzCommand)
|
|
: FSGBuzzCommandImpl(TimedBuzzCommand),
|
|
#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 ) */
|
|
{
|
|
}
|
|
|
|
FSGTimedBuzzCommandImpl::FSGTimedBuzzCommandImpl(const FSGTimedBuzzCommandImpl& Rhs)
|
|
: FSGBuzzCommandImpl(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;
|
|
}
|
|
|
|
FSGTimedBuzzCommandImpl::FSGTimedBuzzCommandImpl(FSGTimedBuzzCommandImpl&& 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;
|
|
|
|
FSGTimedBuzzCommandImpl::~FSGTimedBuzzCommandImpl() = default;
|
|
|
|
FSGTimedBuzzCommandImpl& FSGTimedBuzzCommandImpl::operator=(const FSGTimedBuzzCommandImpl& Rhs)
|
|
{
|
|
FSGBuzzCommandImpl::operator=(Rhs);
|
|
*Pimpl = *Rhs.Pimpl;
|
|
Pimpl->Owner = this;
|
|
return *this;
|
|
}
|
|
|
|
FSGTimedBuzzCommandImpl& FSGTimedBuzzCommandImpl::operator=(FSGTimedBuzzCommandImpl&& 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 FSGTimedBuzzCommandImpl::FTimedBuzzCommandType& FSGTimedBuzzCommandImpl::ToTimedBuzzCommand() const
|
|
{
|
|
return *StaticCastSharedRef<FTimedBuzzCommandType>(ToBuzzCommandRef());
|
|
}
|
|
|
|
TSharedRef<FSGTimedBuzzCommandImpl::FTimedBuzzCommandType> FSGTimedBuzzCommandImpl::ToTimedBuzzCommandRef() const
|
|
{
|
|
return StaticCastSharedRef<FTimedBuzzCommandType>(ToBuzzCommandRef());
|
|
}
|
|
|
|
FSGTimedBuzzCommandImpl::FTimedBuzzCommandType& FSGTimedBuzzCommandImpl::ToTimedBuzzCommand()
|
|
{
|
|
return *StaticCastSharedRef<FTimedBuzzCommandType>(ToBuzzCommandRef());
|
|
}
|
|
|
|
TSharedRef<FSGTimedBuzzCommandImpl::FTimedBuzzCommandType> FSGTimedBuzzCommandImpl::ToTimedBuzzCommandRef()
|
|
{
|
|
return StaticCastSharedRef<FTimedBuzzCommandType>(ToBuzzCommandRef());
|
|
}
|
|
|
|
FSGBuzzCommandImpl FSGTimedBuzzCommandImpl::Copy() const
|
|
{
|
|
return FSGBuzzCommandImpl{ToTimedBuzzCommandRef()->Copy()};
|
|
}
|
|
|
|
FSGBuzzCommandImpl FSGTimedBuzzCommandImpl::Merge(const FSGBuzzCommandImpl& BuzzCommand) const
|
|
{
|
|
return FSGBuzzCommandImpl{ToTimedBuzzCommandRef()->Merge(BuzzCommand.ToBuzzCommand())};
|
|
}
|
|
|
|
FSGBuzzCommandImpl FSGTimedBuzzCommandImpl::GetBaseCommand() const
|
|
{
|
|
return FSGBuzzCommandImpl{MakeShared<FBuzzCommandType>(ToTimedBuzzCommandRef()->GetBaseCommand())};
|
|
}
|
|
|
|
void FSGTimedBuzzCommandImpl::SetBaseCommand(const FSGBuzzCommandImpl& BaseCommand)
|
|
{
|
|
ToTimedBuzzCommandRef()->SetBaseCommand(BaseCommand.ToBuzzCommand());
|
|
}
|
|
|
|
int32 FSGTimedBuzzCommandImpl::GetMagnitude() const
|
|
{
|
|
return ToTimedBuzzCommandRef()->GetMagnitude();
|
|
}
|
|
|
|
void FSGTimedBuzzCommandImpl::SetMagnitude(const int32 Magnitude)
|
|
{
|
|
ToTimedBuzzCommandRef()->SetMagnitude(Magnitude);
|
|
}
|
|
|
|
float FSGTimedBuzzCommandImpl::GetDuration() const
|
|
{
|
|
return ToTimedBuzzCommandRef()->GetDuration();
|
|
}
|
|
|
|
void FSGTimedBuzzCommandImpl::SetDuration(const float Duration)
|
|
{
|
|
ToTimedBuzzCommandRef()->SetDuration(Duration);
|
|
}
|
|
|
|
float FSGTimedBuzzCommandImpl::GetElapsedTime() const
|
|
{
|
|
return ToTimedBuzzCommandRef()->GetElapsedTime();
|
|
}
|
|
|
|
void FSGTimedBuzzCommandImpl::SetElapsedTime(const float ElapsedTime)
|
|
{
|
|
ToTimedBuzzCommandRef()->SetElapsedTime(ElapsedTime);
|
|
}
|
|
|
|
bool FSGTimedBuzzCommandImpl::HasTimeElapsed() const
|
|
{
|
|
return ToTimedBuzzCommandRef()->HasTimeElapsed();
|
|
}
|
|
|
|
float FSGTimedBuzzCommandImpl::NormalizedTime(const bool bClamp01) const
|
|
{
|
|
return ToTimedBuzzCommandRef()->NormalizedTime(bClamp01);
|
|
}
|
|
|
|
void FSGTimedBuzzCommandImpl::ResetTiming()
|
|
{
|
|
ToTimedBuzzCommandRef()->ResetTiming();
|
|
}
|
|
|
|
void FSGTimedBuzzCommandImpl::UpdateTiming(const float DeltaSeconds)
|
|
{
|
|
ToTimedBuzzCommandRef()->UpdateTiming(DeltaSeconds);
|
|
}
|
|
|
|
FString FSGTimedBuzzCommandImpl::ToString() const
|
|
{
|
|
return UTF8_TO_TCHAR(ToTimedBuzzCommandRef()->ToString().c_str());
|
|
}
|
|
|
|
FSGTimedBuzzCommandImpl::FImpl::FImpl(FSGTimedBuzzCommandImpl* InOwner)
|
|
: Owner(InOwner)
|
|
{
|
|
}
|
|
|
|
FSGTimedBuzzCommandImpl::FImpl::~FImpl() = default;
|
|
|
|
void FSGTimedBuzzCommandImpl::FImplDeleter::operator()(const FSGTimedBuzzCommandImpl::FImpl* P) const
|
|
{
|
|
delete P;
|
|
} |