/** * @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 * * */ #pragma once #include #include #include "Containers/UnrealString.h" #include "Runtime/Launch/Resources/Version.h" #include "Templates/SharedPointer.h" #include "Templates/UniquePtr.h" #include "SGCoreImpl/SGPlatform.h" #include "SGTypes/SGCoreTypes.h" namespace SGCore { class SGDevice; } class FSGBetaDeviceImpl; class FSGHapticGloveImpl; class FSGNovaGloveImpl; class FSGSenseGloveImpl; class SENSEGLOVECOREIMPL_API FSGDeviceImpl : public TSharedFromThis { public: typedef SGCore::SGDevice FSGDeviceType; typedef std::shared_ptr FSGDevicePtrType; typedef std::vector FSGDevicePtrVectorType; public: static void ParseFirmware(const FString& RawFirmware, int32& OutMainVersion, int32& OutSubVersion); static FString ToString(ESGDeviceType DeviceType); private: struct FImpl; struct FImplDeleter { void operator()(const FImpl* P) const; }; TUniquePtr Pimpl; FImplDeleter PimplDeleter; public: FSGDeviceImpl(); public: /** * The cast from underlying pointer type constructor. */ explicit FSGDeviceImpl(const FSGDevicePtrType SGDevice); public: /** * The copy constructor. */ FSGDeviceImpl(const FSGDeviceImpl& Rhs); /** * The move constructor. */ FSGDeviceImpl(FSGDeviceImpl&& Rhs) SG_NOEXCEPT; public: /** * The destructor. */ virtual ~FSGDeviceImpl(); public: /** * The copy assignment operator. */ FSGDeviceImpl& operator=(const FSGDeviceImpl& Rhs); /** * The move assignment operator. */ FSGDeviceImpl& operator=(FSGDeviceImpl&& Rhs) SG_NOEXCEPT; public: /** * The cast to underlying pointer type method. */ FSGDevicePtrType ToSGDevicePtr() const; /** * The checked cast to underlying pointer type method. */ FSGDevicePtrType ToSGDevicePtrChecked() const; public: /** * The cast to base TSharedRef type method. */ TSharedRef ToSGDeviceImplRef(); /** * The cast to derived TSharedRef type method. */ TSharedRef ToBetaDeviceImplRef(); /** * The cast to derived TSharedRef type method. */ TSharedRef ToHapticGloveImplRef(); /** * The cast to derived TSharedRef type method. */ TSharedRef ToNovaGloveImplRef(); /** * The cast to derived TSharedRef type method. */ TSharedRef ToSenseGloveImplRef(); public: virtual ESGDeviceType GetDeviceType() const; virtual FString GetDeviceId() const; virtual FString GetHardwareVersion() const; virtual int32 GetFirmwareVersion() const; virtual int32 GetSubFirmwareVersion() const; virtual FString GetFirmwareString() const; FString GetAddress() const; bool IsConnected() const; ESGConnectionType GetConnectionType() const; int32 PacketsPerSecondReceived() const; int32 PacketsPerSecondSent() const; int32 GetDeviceIndex() const; void SetDeviceIndex(int32 NewIndex); virtual bool IsWireless() const; virtual bool HasBattery() const; virtual bool IsCharging(); virtual bool GetBatteryLevel(float& OutLevel); virtual FString ToString() const; };