/** * @file * * @author Max Lammers * @author Mamadou Babaei * * @section LICENSE * * Copyright (c) 2020 - 2023 SenseGlove * * @section DESCRIPTION * * Data class to pass around, contains connection info. * Placed in a separate class because we do not want to pass around structs from * the serial library. * (otherwise projects using SGConnect will need to link serial as well). */ #pragma once #include #include #include "Platform.hpp" namespace SGConnect { /// Connection Type that helps us identify which connection to build, and if this connection is wireless. enum class EConnectionType : int8_t { /// No data available, most likely becuase it is an invalid connection. Unknown = -1, /// A normal hardware serial port. Serial = 0, /// A serial port created by a bluetooth connection. BluetoothSerial, /// Indicator reserved for Android-Bluetooth connection BluetoothAndroid, }; struct PortInfo; } /// Data class containing connection info. struct SGConnect::PortInfo { private: struct Impl; std::unique_ptr Pimpl; public: PortInfo(); /// Create a new instance of the PortInfo. PortInfo(const std::string& address, const std::string& pidVid, EConnectionType connectionType); /** * The copy constructor. */ PortInfo(const PortInfo& rhs); /** * The move constructor. */ PortInfo(PortInfo&& rhs) noexcept; /// Default Destructor virtual ~PortInfo(); public: /** * The copy assignment operator. */ PortInfo& operator=(const PortInfo& rhs); /** * The move assignment operator. */ PortInfo& operator=(PortInfo&& rhs) noexcept; public: /// The Mac/Serial address of the connected device. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ const std::string& GetAddress() const; /// The PID/VID of the connected device. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ const std::string& GetPidVid() const; /// The type of connection of this port. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ EConnectionType GetConnectionType() const; public: /// Returns true is this port has the same address as another. #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ bool SameAddress(const PortInfo& other) const; #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ bool Equals(const PortInfo& other) const; //Optional: public static ToConnection(), which converts this port back into a connection based on its ConnectionType? #if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) [[nodiscard]] #endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */ std::string ToString() const; };