EduArt Sensor Ring Library 4.0.0
Loading...
Searching...
No Matches
ComInterfaceID.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 EduArt Robotik GmbH
2
9
10#pragma once
11
12#include <ostream>
13#include <string>
14
15#include "sensorring/platform/SensorringExport.hpp"
16
17namespace eduart {
18
19namespace sensorring {
20
21namespace com {
22
27enum class InterfaceType {
28 Undefined,
31};
32
37SENSORRING_EXPORT std::string toString(InterfaceType type) noexcept;
38
45SENSORRING_EXPORT std::ostream& operator<<(std::ostream& os, const InterfaceType type) noexcept;
46
54
56 std::string name = "";
57
59 bool operator==(const ComInterfaceID& other) const;
60
62 bool operator!=(const ComInterfaceID& other) const;
63};
64
65inline bool ComInterfaceID::operator==(const ComInterfaceID& other) const {
66 return type == other.type && name == other.name;
67}
68
69inline bool ComInterfaceID::operator!=(const ComInterfaceID& other) const {
70 return !(type == other.type && name == other.name);
71}
72
73} // namespace com
74
75} // namespace sensorring
76
77} // namespace eduart
78
79#ifndef SWIG
80namespace std {
81
85template <> struct hash<eduart::sensorring::com::ComInterfaceID> {
91 std::size_t operator()(const eduart::sensorring::com::ComInterfaceID& id) const noexcept {
92 auto h1 = std::hash<int>{}(static_cast<int>(id.type));
93 auto h2 = std::hash<std::string>{}(id.name);
94 return h1 ^ (h2 << 1);
95 }
96};
97
98} // namespace std
99#endif // SWIG
SENSORRING_EXPORT std::ostream & operator<<(std::ostream &os, const InterfaceType type) noexcept
Stream interface type as string.
InterfaceType
Type of the communication interface.
Definition ComInterfaceID.hpp:27
@ UsbTingo
USBtingo CAN adapter.
Definition ComInterfaceID.hpp:30
@ SocketCan
Linux SocketCAN interface (e.g. can0).
Definition ComInterfaceID.hpp:29
@ Undefined
Type not yet assigned.
Definition ComInterfaceID.hpp:28
SENSORRING_EXPORT std::string toString(InterfaceType type) noexcept
Format interface type as string.
Uniquely identifies a communication interface by type and name.
Definition ComInterfaceID.hpp:51
InterfaceType type
Type of the communication interface.
Definition ComInterfaceID.hpp:53
bool operator!=(const ComInterfaceID &other) const
Inequality operator for ComInterfaceID.
Definition ComInterfaceID.hpp:69
bool operator==(const ComInterfaceID &other) const
Equality operator for ComInterfaceID.
Definition ComInterfaceID.hpp:65
std::string name
Name of the communication interface.
Definition ComInterfaceID.hpp:56
std::size_t operator()(const eduart::sensorring::com::ComInterfaceID &id) const noexcept
Compute hash value for a ComInterfaceID.
Definition ComInterfaceID.hpp:91