|
| 1 | +// @ Copyright 2022-2025 Nestor Neto |
| 2 | + |
| 3 | +#ifndef INCLUDE_LIBSERIAL_DEVICE_HPP_ |
| 4 | +#define INCLUDE_LIBSERIAL_DEVICE_HPP_ |
| 5 | + |
| 6 | +#include <string> |
| 7 | +#include <cstdint> |
| 8 | + |
| 9 | +namespace libserial { |
| 10 | + |
| 11 | +/** |
| 12 | + * @brief A class representing a serial device |
| 13 | + * |
| 14 | + * The Device class encapsulates the properties of a serial device, |
| 15 | + * including its name, port path, bus path, and unique identifier. |
| 16 | + * |
| 17 | + * @author Nestor Pereira Neto |
| 18 | + */ |
| 19 | +class Device { |
| 20 | +public: |
| 21 | +/** |
| 22 | + * @brief Default constructor of the Device class |
| 23 | + * |
| 24 | + */ |
| 25 | +Device() = default; |
| 26 | + |
| 27 | +/** |
| 28 | + * @brief Default destructor of the Device class |
| 29 | + * |
| 30 | + */ |
| 31 | +~Device() = default; |
| 32 | + |
| 33 | +/** |
| 34 | + * @brief Parameterized constructor of the Device class |
| 35 | + * |
| 36 | + * @param name The name of the device |
| 37 | + * @param port_path The port path of the device |
| 38 | + * @param bus_path The bus path of the device |
| 39 | + * @param id The unique identifier of the device |
| 40 | + */ |
| 41 | +Device(const std::string& name, |
| 42 | + const std::string& port_path, |
| 43 | + const std::string& bus_path, |
| 44 | + uint16_t id); |
| 45 | + |
| 46 | +/** |
| 47 | + * @brief Retrieves the name of the device |
| 48 | + * |
| 49 | + * @return std::string The name of the device |
| 50 | + */ |
| 51 | +std::string getName() const; |
| 52 | + |
| 53 | +/** |
| 54 | + * @brief Retrieves the port path of the device |
| 55 | + * |
| 56 | + * @return std::string The port path of the device |
| 57 | + */ |
| 58 | +std::string getPortPath() const; |
| 59 | + |
| 60 | +/** |
| 61 | + * @brief Retrieves the bus path of the device |
| 62 | + * |
| 63 | + * @return std::string The bus path of the device |
| 64 | + */ |
| 65 | +std::string getBusPath() const; |
| 66 | + |
| 67 | +/** |
| 68 | + * @brief Retrieves the unique identifier of the device |
| 69 | + * |
| 70 | + * @return uint16_t The unique identifier of the device |
| 71 | + */ |
| 72 | +uint16_t getId() const; |
| 73 | + |
| 74 | +/** |
| 75 | + * @brief Sets the name of the device |
| 76 | + * |
| 77 | + * @param name The name to set |
| 78 | + */ |
| 79 | +void setName(const std::string& name); |
| 80 | + |
| 81 | +/** |
| 82 | + * @brief Sets the port path of the device |
| 83 | + * |
| 84 | + * @param port_path The port path to set |
| 85 | + */ |
| 86 | +void setPortPath(const std::string& port_path); |
| 87 | + |
| 88 | +/** |
| 89 | + * @brief Sets the bus path of the device |
| 90 | + * |
| 91 | + * @param bus_path The bus path to set |
| 92 | + */ |
| 93 | +void setBusPath(const std::string& bus_path); |
| 94 | + |
| 95 | +/** |
| 96 | + * @brief Sets the unique identifier of the device |
| 97 | + * |
| 98 | + * @param id The unique identifier to set |
| 99 | + */ |
| 100 | +void setId(uint16_t id); |
| 101 | + |
| 102 | +private: |
| 103 | +/** |
| 104 | + * @brief The name of the device |
| 105 | + */ |
| 106 | +std::string name_{"unknown"}; |
| 107 | + |
| 108 | +/** |
| 109 | + * @brief The port path of the device |
| 110 | + */ |
| 111 | +std::string port_path_{"unknown"}; |
| 112 | + |
| 113 | +/** |
| 114 | + * @brief The bus path of the device |
| 115 | + */ |
| 116 | +std::string bus_path_{"unknown"}; |
| 117 | + |
| 118 | +/** |
| 119 | + * @brief The unique identifier of the device |
| 120 | + */ |
| 121 | +uint16_t id_{0}; |
| 122 | +}; |
| 123 | +} // namespace libserial |
| 124 | + |
| 125 | +#endif // INCLUDE_LIBSERIAL_DEVICE_HPP_ |
0 commit comments