Thermal Camera SDK 11.3.0
SDK for Optris Thermal Cameras
Loading...
Searching...
No Matches
Port.h
Go to the documentation of this file.
1// Copyright (c) 2008-2026 Optris GmbH & Co. KG
2
10
11#pragma once
12
13#include <cstdint>
14#include <string>
15#include <ostream>
16
17#include "otcsdk/Api.h"
18#include "otcsdk/Exceptions.h"
19
20
21namespace optris
22{
23
33class Port
34{
35public:
37 using Number = std::uint16_t;
38
39
45 Port() noexcept;
46
54 Port(Number number) noexcept;
55
63 Port(const std::string& port);
64
65
67 void reset() noexcept;
68
76 void setNumber(Number number) noexcept;
77
85 Number getNumber() const noexcept;
86
94 OTC_SDK_API void setFromString(const std::string& port) noexcept(false);
95
101 OTC_SDK_API std::string toString() const noexcept;
102
103
111 bool operator==(const Port& rhs) const noexcept;
112
120 bool operator!=(const Port& rhs) const noexcept;
121
129 bool operator<(const Port& rhs) const noexcept;
130
131
132private:
134 Number _number;
135};
136
137// Utility functions
146OTC_SDK_API std::ostream& operator<<(std::ostream& out, const Port& port) noexcept;
147
148
149// Inline implementations
150inline Port::Port() noexcept
151 : _number{0}
152{ }
153
154inline Port::Port(Number number) noexcept
155 : _number{number}
156{ }
157
158inline Port::Port(const std::string& port)
159 : _number{0}
160{
161 setFromString(port);
162}
163
164inline void Port::reset() noexcept
165{
166 _number = 0;
167}
168
169inline void Port::setNumber(Number number) noexcept
170{
171 _number = number;
172}
173
174inline Port::Number Port::getNumber() const noexcept
175{
176 return _number;
177}
178
179inline bool Port::operator==(const Port& rhs) const noexcept
180{
181 return _number == rhs._number;
182}
183
184inline bool Port::operator!=(const Port& rhs) const noexcept
185{
186 return _number != rhs._number;
187}
188
189inline bool Port::operator<(const Port& rhs) const noexcept
190{
191 return _number < rhs._number;
192}
193
194} // 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 network port number.
Definition Port.h:34
OTC_SDK_API std::string toString() const noexcept
Returns the port number as a string.
void setNumber(Number number) noexcept
Sets the port number to the given value.
Definition Port.h:169
Port() noexcept
Constructor.
Definition Port.h:150
Number getNumber() const noexcept
Returns the port number.
Definition Port.h:174
bool operator==(const Port &rhs) const noexcept
Returns whether this port equals the provided one.
Definition Port.h:179
bool operator!=(const Port &rhs) const noexcept
Returns whether this port is different from the provided one.
Definition Port.h:184
void reset() noexcept
Resets the port number to 0.
Definition Port.h:164
bool operator<(const Port &rhs) const noexcept
Returns whether this port number is smaller than the provided one.
Definition Port.h:189
OTC_SDK_API void setFromString(const std::string &port) noexcept(false)
Sets the port number from the given string.
std::uint16_t Number
Type used to store the port number.
Definition Port.h:37
Main SDK namespace.
Definition AlarmChannel.h:21