Files
Plugin/Source/SenseGloveCoreImpl/Public/SGCoreImpl/SGDeviceImpl.h
T

182 lines
4.5 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
*
*
*/
#pragma once
#include <memory>
#include <vector>
#include "Containers/UnrealString.h"
#include "Templates/SharedPointer.h"
#include "Templates/UniquePtr.h"
#include "SGTypes/SGCoreTypes.h"
namespace SGCore
{
class SGDevice;
}
class FSGBetaDeviceImpl;
class FSGHapticGloveImpl;
class FSGNovaGloveImpl;
class FSGSenseGloveImpl;
class SENSEGLOVECOREIMPL_API FSGDeviceImpl : public TSharedFromThis<FSGDeviceImpl>
{
public:
typedef SGCore::SGDevice FSGDeviceType;
typedef std::shared_ptr<FSGDeviceType> FSGDevicePtrType;
typedef std::vector<FSGDevicePtrType> 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<FImpl, FImplDeleter> 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) noexcept;
public:
/**
* The destructor.
*/
virtual ~FSGDeviceImpl();
public:
/**
* The copy assignment operator.
*/
FSGDeviceImpl& operator=(const FSGDeviceImpl& Rhs);
/**
* The move assignment operator.
*/
FSGDeviceImpl& operator=(FSGDeviceImpl&& Rhs) 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<FSGDeviceImpl> type method.
*/
TSharedRef<FSGDeviceImpl> ToSGDeviceImplRef();
/**
* The cast to derived TSharedRef<FSGBetaDeviceImpl> type method.
*/
TSharedRef<FSGBetaDeviceImpl> ToBetaDeviceImplRef();
/**
* The cast to derived TSharedRef<FSGHapticGloveImpl> type method.
*/
TSharedRef<FSGHapticGloveImpl> ToHapticGloveImplRef();
/**
* The cast to derived TSharedRef<FSGNovaGloveImpl> type method.
*/
TSharedRef<FSGNovaGloveImpl> ToNovaGloveImplRef();
/**
* The cast to derived TSharedRef<FSGSenseGloveImpl> type method.
*/
TSharedRef<FSGSenseGloveImpl> 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;
};