Thermal Camera SDK 10.0.1
SDK for Optris Thermal Cameras
Loading...
Searching...
No Matches
Port.h
Go to the documentation of this file.
1// Copyright (c) 2025 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
105 bool operator==(const Port& rhs) const noexcept;
107 bool operator!=(const Port& rhs) const noexcept;
109 bool operator<(const Port& rhs) const noexcept;
110
111
112private:
114 Number _number;
115};
116
117// Utility functions
126OTC_SDK_API std::ostream& operator<<(std::ostream& out, const Port& port) noexcept;
127
128
129// Inline implementations
130inline Port::Port() noexcept
131 : _number{0}
132{ }
133
134inline Port::Port(Number number) noexcept
135 : _number{number}
136{ }
137
138inline Port::Port(const std::string& port)
139{
140 setFromString(port);
141}
142
143inline void Port::reset() noexcept
144{
145 _number = 0;
146}
147
148inline void Port::setNumber(Number number) noexcept
149{
150 _number = number;
151}
152
153inline Port::Number Port::getNumber() const noexcept
154{
155 return _number;
156}
157
158inline bool Port::operator==(const Port& rhs) const noexcept
159{
160 return _number == rhs._number;
161}
162
163inline bool Port::operator!=(const Port& rhs) const noexcept
164{
165 return _number != rhs._number;
166}
167
168inline bool Port::operator<(const Port& rhs) const noexcept
169{
170 return _number < rhs._number;
171}
172
173} // 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:148
Port() noexcept
Constructor.
Definition Port.h:130
Number getNumber() const noexcept
Returns the port number.
Definition Port.h:153
bool operator==(const Port &rhs) const noexcept
Equality operator.
Definition Port.h:158
bool operator!=(const Port &rhs) const noexcept
Unequality operator.
Definition Port.h:163
void reset() noexcept
Resets the port number to 0.
Definition Port.h:143
bool operator<(const Port &rhs) const noexcept
Less than operator.
Definition Port.h:168
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 DeviceInfo.h:23