/** * @file * * @author Max Lammers * @author Mamadou Babaei * * @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 #include #include #include "Platform.hpp" namespace SGCore { /// Base class containing the minimum amount of data for device models. class SGCORE_API DeviceModel; }// namespace SGCore /// Base class containing the minimum amount of data for device models. class SGCORE_API SGCore::DeviceModel { public: /// Parse a 32-bit integer value into a set of booleans (010010011) that indicate which (optional) functions this device has. static std::vector ParseFunctions(int32_t value, int32_t size); /// /// /// /// static void ParseFirmware(const std::string& rawFirmware, int32_t& out_mainVersion, int32_t& out_subVersion); private: struct Impl; std::unique_ptr 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: /// Retrieve the Unique identifier of this device. #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 */ /// Unique identifier of this device. void SetDeviceId(const std::string& id); public: /// Retrieve the Hardware (sub) version of this Sense Glove Device. #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 */ /// Hardware (sub) version of this Sense Glove Device. void SetHardwareVersion(const std::string& version); public: /// Firmware version running on the device's MicroController. (as v4.12, this is the 4). #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 */ /// Firmware version running on the device's MicroController. void SetFirmwareVersion(int32_t version); public: /// Sub firmware version running on the device's microcontroller (as v4.12, this is the 12). /// #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 */ /// Sub-Firmware version running on the device's MicroController. void SetSubFirmwareVersion(int32_t version); };