Files
Plugin/Source/SenseGloveCore/Public/SGCore/SGBetaDevice.h
T

177 lines
4.9 KiB
C++

/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2026 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
*
* Represents a Sense Glove Device that has no specific class within the API.
* Used to test different iterations of the same product before integrating it
* into the Core API.
* Allows access to raw sensor values and commands of such a device.
*/
#pragma once
#include "Containers/UnrealString.h"
#include "HAL/Platform.h"
#include "Templates/UniquePtr.h"
#include "UObject/Object.h"
#include "UObject/ObjectMacros.h"
#include "SGCore/SGDevice.h"
#include "SGTypes/SGCoreTypes.h"
#include "SGBetaDevice.generated.h"
class FSGDeviceImpl;
class FSGBetaDeviceImpl;
/**
* A Device that adheres to the SenseGlove communications protocol, but which has no implementation in this API.
*/
UCLASS(BlueprintType)
class SENSEGLOVECORE_API USGBetaDevice final : public USGDevice
{
GENERATED_BODY()
public:
static USGBetaDevice* NewBetaDevice(UObject* Outer, const FSGBetaDeviceImpl& BetaDeviceImpl);
static USGBetaDevice* NewBetaDevice(UObject* Outer, TSharedRef<FSGBetaDeviceImpl> BetaDeviceImpl);
public:
/**
* The basic class constructor.
*/
static USGBetaDevice* NewBetaDevice(UObject* Outer);
/**
* Creates a new instance of a Beta Device.
*/
static USGBetaDevice* NewBetaDevice(
UObject* Outer,
const FString& ConstantsString, const FString& DeviceId,
const FString& HardwareVersion, int32 FirmwareVersion, int32 SubFirmwareVersion);
public:
/**
* Deserialize a beta device from its basic constants string. Returns nullptr if unsuccessful.
*/
static USGBetaDevice* Parse(UObject* Outer, const FString& String);
public:
/**
* The basic class constructor.
*/
USGBetaDevice();
/**
* Creates a new instance of a Beta Device.
*/
USGBetaDevice(const FString& ConstantsString, const FString& DeviceId,
const FString& HardwareVersion, int32 FirmwareVersion, int32 SubFirmwareVersion);
public:
/**
* The cast from underlying type constructor.
*/
explicit USGBetaDevice(const FSGBetaDeviceImpl& BetaDeviceImpl);
protected:
/**
* The cast from underlying pointer type constructor.
*/
explicit USGBetaDevice(TSharedRef<FSGBetaDeviceImpl> BetaDeviceImpl);
public:
/**
* The destructor.
*/
virtual ~USGBetaDevice() override;
protected:
/**
* The cast to underlying type method.
*/
TSharedRef<FSGBetaDeviceImpl> ToBetaDeviceImpl() const;
public:
/**
* Get the DeviceType enumerator of this SenseGlove, used in DeviceList enumeration.
*/
virtual ESGDeviceType GetDeviceType() const override;
/**
* Get the unique identifier of this device.
*/
virtual FString GetDeviceId() const override;
/**
* Retrieve this device's hardware version.
*/
virtual FString GetHardwareVersion() const override;
/**
* Retrieve this device's firmware version.
*/
virtual int32 GetFirmwareVersion() const override;
/**
* Retrieve this device's sub-firmware version.
*/
virtual int32 GetSubFirmwareVersion() const override;
public:
/**
* Retrieve the constants string for additional processing.
*/
FString GetConstantsString() const;
/**
* Retrieve a raw sensor string from this Beta Device.
*/
FString GetSensorData() const;
/**
* Retrieve the last command retrieved from this Beta Device.
*/
FString GetLastCommand() const;
public:
/**
* Send a raw string command to this device.
*/
bool SendHaptics(const FString& Command) const;
public:
/**
* Create a string representation of this device for reporting purposes.
*/
virtual FString ToString() const override;
};