/** * @file * * @author Mamadou Babaei * * @section LICENSE * * (The MIT License) * * Copyright (c) 2020 - 2023 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() : Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) { } FSGTimedThumpCommandImpl::FSGTimedThumpCommandImpl(const int32 Magnitude, const float DurationSeconds, const float StartTimeSeconds) : Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) { Pimpl->TimedThumpCommand = FTimedThumpCommandType(Magnitude, DurationSeconds, StartTimeSeconds); } FSGTimedThumpCommandImpl::FSGTimedThumpCommandImpl(const FSGThumperCommandImpl& BaseCommand, const float DurationSeconds, const float StartTimeSeconds) : Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) { Pimpl->TimedThumpCommand = FTimedThumpCommandType(BaseCommand.ToThumperCommand(), DurationSeconds, StartTimeSeconds); } FSGTimedThumpCommandImpl::FSGTimedThumpCommandImpl(const FTimedThumpCommandType& SGTimedThumpCommand) : Pimpl(TUniquePtr(new FImpl{this}, PimplDeleter)) { Pimpl->TimedThumpCommand = SGTimedThumpCommand; } FSGTimedThumpCommandImpl::FSGTimedThumpCommandImpl(const FSGTimedThumpCommandImpl& Rhs) : Pimpl(TUniquePtr(new FImpl{*Rhs.Pimpl}, PimplDeleter)) { Pimpl->Owner = this; } FSGTimedThumpCommandImpl::FSGTimedThumpCommandImpl(FSGTimedThumpCommandImpl&& Rhs) SG_NOEXCEPT = default; FSGTimedThumpCommandImpl::~FSGTimedThumpCommandImpl() = default; FSGTimedThumpCommandImpl& FSGTimedThumpCommandImpl::operator=(const FSGTimedThumpCommandImpl& Rhs) { *Pimpl = *Rhs.Pimpl; Pimpl->Owner = this; return *this; } FSGTimedThumpCommandImpl& FSGTimedThumpCommandImpl::operator=(FSGTimedThumpCommandImpl&& Rhs) SG_NOEXCEPT = default; const FSGTimedThumpCommandImpl::FTimedThumpCommandType& FSGTimedThumpCommandImpl::ToTimedThumpCommand() const { return Pimpl->TimedThumpCommand; } int32 FSGTimedThumpCommandImpl::GetMagnitude() const { return Pimpl->TimedThumpCommand.GetMagnitude(); } float FSGTimedThumpCommandImpl::GetDuration() const { return Pimpl->TimedThumpCommand.GetDuration(); } float FSGTimedThumpCommandImpl::GetElapsedTime() const { return Pimpl->TimedThumpCommand.GetElapsedTime(); } 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; }