Thermal Camera SDK 10.1.1
SDK for Optris Thermal Cameras
Loading...
Searching...
No Matches
MacAddress.h
Go to the documentation of this file.
1// Copyright (c) 2008-2025 Optris GmbH & Co. KG
2
10
11#pragma once
12
13#include <cstdint>
14#include <string>
15#include <array>
16#include <ostream>
17
18#include "otcsdk/Api.h"
19#include "otcsdk/Exceptions.h"
20
21
22namespace optris
23{
24
34{
35public:
42
50 OTC_SDK_API MacAddress(std::uint64_t mac);
51
59 OTC_SDK_API MacAddress(const std::string& mac);
60
71 OTC_SDK_API MacAddress(std::uint8_t a, std::uint8_t b, std::uint8_t c, std::uint8_t d, std::uint8_t e, std::uint8_t f) noexcept;
72
73
75 OTC_SDK_API void reset() noexcept;
76
84 OTC_SDK_API void setFromUInt64(std::uint64_t mac);
85
91 OTC_SDK_API std::uint64_t toUInt64() const noexcept;
92
100 OTC_SDK_API void setFromString(const std::string& mac);
101
107 OTC_SDK_API std::string toString() const noexcept;
108
117 OTC_SDK_API void setByte(int index, std::uint8_t value);
118
128 OTC_SDK_API std::uint8_t getByte(int index) const;
129
130
132 bool operator==(const MacAddress& rhs) const noexcept;
134 bool operator==(const std::uint64_t& rhs) const;
136 bool operator!=(const MacAddress& rhs) const noexcept;
137
138
139private:
141 std::array<std::uint8_t, 6> _bytes;
142};
143
144// Utility functions
153OTC_SDK_API std::ostream& operator<<(std::ostream& out, const MacAddress& mac) noexcept;
154
155
156// Inline implementations
157inline bool MacAddress::operator==(const MacAddress& rhs) const noexcept
158{
159 return _bytes == rhs._bytes;
160}
161
162inline bool MacAddress::operator==(const std::uint64_t& rhs) const
163{
164 return toUInt64() == rhs;
165}
166
167inline bool MacAddress::operator!=(const MacAddress& rhs) const noexcept
168{
169 return !(_bytes == rhs._bytes);
170}
171
172} // namespace optris
Contains defines controlling the Windows DLL export and import of symbols.
#define OTC_SDK_API
Only needed when working with Windows DLLs.
Definition Api.h:65
Contains the exceptions raised by the SDK.
Encapsulates a media access control address (MAC address).
Definition MacAddress.h:34
OTC_SDK_API void reset() noexcept
Resets all the bytes of the MAC address to 0 (0:0:0:0:0:0).
bool operator==(const MacAddress &rhs) const noexcept
Equality operator.
Definition MacAddress.h:157
OTC_SDK_API std::uint64_t toUInt64() const noexcept
Returns the MAC address as an unsigned 64 bit integer.
OTC_SDK_API void setFromUInt64(std::uint64_t mac)
Sets the MAC address from an unsigned 64 bit integer.
bool operator!=(const MacAddress &rhs) const noexcept
Unequality operator.
Definition MacAddress.h:167
OTC_SDK_API void setFromString(const std::string &mac)
Sets the MAC address from the given string.
OTC_SDK_API std::string toString() const noexcept
Returns the MAC address as a string in colon notation (a:b:c:d:e:f).
OTC_SDK_API std::uint8_t getByte(int index) const
Returns the value of the byte with the given index.
OTC_SDK_API MacAddress() noexcept
Constructor.
OTC_SDK_API void setByte(int index, std::uint8_t value)
Sets the value of the byte with the given index.
Main SDK namespace.
Definition DeviceInfo.h:24