/** * @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 * * A command for five fingers that can be sent to a Sense Glove device. */ #pragma once #include "Containers/Array.h" #include "Containers/UnrealString.h" #include "Templates/SharedPointer.h" #include "Templates/UniquePtr.h" #include "UObject/Object.h" #include "UObject/ObjectMacros.h" #include "SGFingerCommand.generated.h" class FSGBuzzCommandImpl; class FSGFingerCommandImpl; class FSGForceFeedbackCommandImpl; class FSGTimedBuzzCommandImpl; /** * A command that contains values (levels) for five fingers. */ UCLASS(Abstract, BlueprintType) class SENSEGLOVECORE_API USGFingerCommand : public UObject { GENERATED_BODY() private: struct FImpl; struct FImplDeleter { void operator()(const FImpl* P) const; }; TUniquePtr Pimpl; FImplDeleter PimplDeleter; protected: /** * */ USGFingerCommand(); /** * */ explicit USGFingerCommand(const TArray& InLevels); public: /** * The cast from underlying type constructor. */ explicit USGFingerCommand(const FSGFingerCommandImpl& FingerCommandImpl); /** * The cast from underlying child type constructor. */ explicit USGFingerCommand(const FSGBuzzCommandImpl& BuzzCommandImpl); /** * The cast from underlying child type constructor. */ explicit USGFingerCommand(const FSGForceFeedbackCommandImpl& ForceFeedbackCommandImpl); /** * The cast from underlying child type constructor. */ explicit USGFingerCommand(const FSGTimedBuzzCommandImpl& TimedBuzzCommandImpl); protected: /** * The cast from underlying pointer type constructor. */ explicit USGFingerCommand(TSharedRef FingerCommandImpl); /** * The cast from underlying child pointer type constructor. */ explicit USGFingerCommand(TSharedRef BuzzCommandImpl); /** * The cast from underlying child pointer type constructor. */ explicit USGFingerCommand(TSharedRef ForceFeedbackCommandImpl); /** * The cast from underlying child pointer type constructor. */ explicit USGFingerCommand(TSharedRef TimedBuzzCommandImpl); public: /** * The destructor. */ virtual ~USGFingerCommand() override; protected: /** * Allows the child classes to set the underlying object after construction. */ void SetFingerCommandImpl(const FSGFingerCommandImpl& FingerCommandImpl); /** * Allows the child classes to set the underlying object after construction. */ void SetFingerCommandImpl(const FSGBuzzCommandImpl& BuzzCommandImpl); /** * Allows the child classes to set the underlying object after construction. */ void SetFingerCommandImpl(const FSGForceFeedbackCommandImpl& ForceFeedbackCommandImpl); /** * Allows the child classes to set the underlying object after construction. */ void SetFingerCommandImpl(const FSGTimedBuzzCommandImpl& TimedBuzzCommandImpl); /** * Allows the child classes to set the underlying object after construction. */ void SetFingerCommandImpl(TSharedRef FingerCommandImpl); /** * Allows the child classes to set the underlying object after construction. */ void SetFingerCommandImpl(TSharedRef BuzzCommandImpl); /** * Allows the child classes to set the underlying object after construction. */ void SetFingerCommandImpl(TSharedRef ForceFeedbackCommandImpl); /** * Allows the child classes to set the underlying object after construction. */ void SetFingerCommandImpl(TSharedRef TimedBuzzCommandImpl); public: /** * The cast to underlying type method. */ TSharedRef ToFingerCommandImpl() const; protected: /** * Allows the child classes to synchronize the parent's underlying object at any time. */ virtual void SyncImplObject() const; /** * Allows the child classes to synchronize the parent's uproperties at any time. */ virtual void SyncUProperties(); public: /** * */ TArray GetLevels() const; public: /** * */ int32 GetLevel(int32 Finger) const; /** * */ void SetLevel(int32 Finger, int32 Value); /** * Check if this command contains the same values as another. */ bool Equals(const USGFingerCommand* FingerCommand) const; /** * Create a string representation of this finger command. */ FString ToString() const; };