118 lines
3.5 KiBLFS
C++
118 lines
3.5 KiBLFS
C++
/**
|
|
* @file
|
|
*
|
|
* @author Max Lammers <max@senseglove.com>
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @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 <memory>
|
|
#include <string>
|
|
|
|
#include "Platform.hpp"
|
|
|
|
namespace SGConnect
|
|
{
|
|
///<summary> Connection Type that helps us identify which connection to build, and if this connection is wireless. </summary>
|
|
enum class EConnectionType : int8_t
|
|
{
|
|
///<summary> No data available, most likely becuase it is an invalid connection. </summary>
|
|
Unknown = -1,
|
|
///<summary> A normal hardware serial port. </summary>
|
|
Serial = 0,
|
|
///<summary> A serial port created by a bluetooth connection. </summary>
|
|
BluetoothSerial,
|
|
/// <summary> Indicator reserved for Android-Bluetooth connection </summary>
|
|
BluetoothAndroid,
|
|
};
|
|
|
|
struct PortInfo;
|
|
}
|
|
|
|
/// <summary> Data class containing connection info. </summary>
|
|
struct SGConnect::PortInfo
|
|
{
|
|
private:
|
|
struct Impl;
|
|
std::unique_ptr<Impl> Pimpl;
|
|
|
|
public:
|
|
PortInfo();
|
|
|
|
///<summary> Create a new instance of the PortInfo. </summary>
|
|
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;
|
|
|
|
///<summary> Default Destructor </summary>
|
|
virtual ~PortInfo();
|
|
|
|
public:
|
|
/**
|
|
* The copy assignment operator.
|
|
*/
|
|
PortInfo& operator=(const PortInfo& rhs);
|
|
|
|
/**
|
|
* The move assignment operator.
|
|
*/
|
|
PortInfo& operator=(PortInfo&& rhs) noexcept;
|
|
|
|
public:
|
|
///<summary> The Mac/Serial address of the connected device. </summary>
|
|
#if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN )
|
|
[[nodiscard]]
|
|
#endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */
|
|
const std::string& GetAddress() const;
|
|
|
|
///<summary> The PID/VID of the connected device. </summary>
|
|
#if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN )
|
|
[[nodiscard]]
|
|
#endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */
|
|
const std::string& GetPidVid() const;
|
|
|
|
///<summary> The type of connection of this port. </summary>
|
|
#if !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN )
|
|
[[nodiscard]]
|
|
#endif /* !defined ( SENSEGLOVE_UNREAL_ENGINE_PLUGIN ) */
|
|
EConnectionType GetConnectionType() const;
|
|
|
|
public:
|
|
///<summary> Returns true is this port has the same address as another. </summary>
|
|
#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;
|
|
}; |