Thermal Camera SDK 11.3.0
SDK for Optris Thermal Cameras
Loading...
Searching...
No Matches
Range.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 <ostream>
14
15#include "otcsdk/Exceptions.h"
16
17
18namespace optris
19{
20
26template<typename T>
27struct Range
28{
30 using ComponentType = T;
31
33 T min;
35 T max;
36
37
45 static void validate(const Range<T>& range);
46};
47
52
53
54// Inline implementations
55template<typename T>
56inline void Range<T>::validate(const Range<T>& range)
57{
58 if (range.min > range.max)
59 {
60 throw SDKException{"Invalid range: minimum value is greater than maximum value."};
61 }
62}
63
64// Utility functions
73template<typename T>
74inline bool operator==(const Range<T>& lhs, const Range<T>& rhs) noexcept
75{
76 return lhs.min == rhs.min && lhs.max == rhs.max;
77}
78
87template<typename T>
88inline bool operator!=(const Range<T>& lhs, const Range<T>& rhs) noexcept
89{
90 return lhs.min != rhs.min || lhs.max != rhs.max;
91}
92
101template<typename T>
102inline bool isIn(const T& value, const Range<T>& range) noexcept
103{
104 return value >= range.min && value <= range.max;
105}
106
115template<typename T>
116std::ostream& operator<<(std::ostream& out, const Range<T>& range) noexcept
117{
118 return (out << "[" << range.min << ", " << range.max << "]");
119}
120
121} // namespace optris
Contains the exceptions raised by the SDK.
Exception raised by the SDK.
Definition Exceptions.h:23
Main SDK namespace.
Definition AlarmChannel.h:21
OTC_SDK_API std::ostream & operator<<(std::ostream &out, const AlarmChannelConfig &config) noexcept
Output stream operator for alarm channel configurations.
Range< int > RangeI
Alias for a range with integer components.
Definition Range.h:51
bool isIn(const T &value, const Range< T > &range) noexcept
Checks if a value is within a given range.
Definition Range.h:102
bool operator!=(const RadiationParameters &lhs, const RadiationParameters &rhs) noexcept
Checks if two radiation parameter sets are unequal.
bool operator==(const RadiationParameters &lhs, const RadiationParameters &rhs) noexcept
Checks if two radiation parameter sets are equal.
Range< float > RangeF
Alias for a range with float components.
Definition Range.h:49
Generic range structure.
Definition Range.h:28
static void validate(const Range< T > &range)
Validates the range.
Definition Range.h:56
float max
Definition Range.h:35
T ComponentType
Type of the range components.
Definition Range.h:30
float min
Definition Range.h:33