Files
Plugin/Source/ThirdParty/include/SenseGlove/Core/DeviceModel.hpp
T

138 lines
4.2 KiBLFS
C++

/**
* @file
*
* @author Max Lammers <max@senseglove.com>
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* Copyright (c) 2020 - 2023 SenseGlove
*
* @section DESCRIPTION
*
* Base class for Device Models containing the minimum amount of data gathered
* through Communications Protocol. Used for shared functionality.
*/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "Platform.hpp"
namespace SGCore
{
/// <summary> Base class containing the minimum amount of data for device models. </summary>
class SGCORE_API DeviceModel;
}// namespace SGCore
/// <summary> Base class containing the minimum amount of data for device models. </summary>
class SGCORE_API SGCore::DeviceModel
{
public:
///<summary> Parse a 32-bit integer value into a set of booleans (010010011) that indicate which (optional) functions this device has. </summary>
static std::vector<bool> ParseFunctions(int32_t value, int32_t size);
/// <summary> </summary>
/// <param name="rawFW"></param>
/// <param name="mainVer"></param>
/// <param name="subVer"></param>
static void ParseFirmware(const std::string& rawFirmware, int32_t& out_mainVersion, int32_t& out_subVersion);
private:
struct Impl;
std::unique_ptr<Impl> Pimpl;
public:
DeviceModel();// empty constructor to be used by child classes.
DeviceModel(const std::string& id,
const std::string& hardwareVersion, int32_t firmwareVersion, int32_t subFirmwareVersion);
/**
* The copy constructor.
*/
DeviceModel(const DeviceModel& rhs);
/**
* The move constructor.
*/
DeviceModel(DeviceModel&& rhs) noexcept;
virtual ~DeviceModel();
public:
/**
* The copy assignment operator.
*/
DeviceModel& operator=(const DeviceModel& rhs);
/**
* The move assignment operator.
*/
DeviceModel& operator=(DeviceModel&& rhs) noexcept;
public:
/// <summary> Retrieve the Unique identifier of this device. </summary>
#if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN )
[[nodiscard]]
#endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */
std::string GetDeviceId() const;
#if SENSEGLOVE_UNREAL_ENGINE_PLUGIN
public:
#else /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */
protected:
#endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */
/// <summary> Unique identifier of this device. </summary>
void SetDeviceId(const std::string& id);
public:
/// <summary> Retrieve the Hardware (sub) version of this Sense Glove Device. </summary>
#if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN )
[[nodiscard]]
#endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */
std::string GetHardwareVersion() const;
#if SENSEGLOVE_UNREAL_ENGINE_PLUGIN
public:
#else /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */
protected:
#endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */
/// <summary> Hardware (sub) version of this Sense Glove Device. </summary>
void SetHardwareVersion(const std::string& version);
public:
/// <summary> Firmware version running on the device's MicroController. (as v4.12, this is the 4). </summary>
#if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN )
[[nodiscard]]
#endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */
int32_t GetFirmwareVersion() const;
#if SENSEGLOVE_UNREAL_ENGINE_PLUGIN
public:
#else /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */
protected:
#endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */
/// <summary> Firmware version running on the device's MicroController. </summary>
void SetFirmwareVersion(int32_t version);
public:
/// <summary> Sub firmware version running on the device's microcontroller (as v4.12, this is the 12). </summary>
/// <returns></returns>
#if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN )
[[nodiscard]]
#endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */
int32_t GetSubFirmwareVersion() const;
#if SENSEGLOVE_UNREAL_ENGINE_PLUGIN
public:
#else /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */
protected:
#endif /* SENSEGLOVE_UNREAL_ENGINE_PLUGIN */
/// <summary> Sub-Firmware version running on the device's MicroController. </summary>
void SetSubFirmwareVersion(int32_t version);
};