JeVois
1.22
JeVois Smart Embedded Machine Vision Toolkit
|
|
#include <jevois/Types/Range.H>
A generic range class.
The Range class is used to represent a range from [min .. max]
Note that the operators of Range do not use type promotions. This is to minimize template burden and also possible programmer confusion. For example, while in principle one could define Range<int> + float and return a Range<float>, here we do not define such an operator. The same result can be achieved by first converting the range and then adding the constant:
Operators on Range use range checking and clamping internally. Thus, be careful if using Range<byte>. For example:
Public Member Functions | |
Range () | |
Default constructor, range is [0 .. 0]. | |
Range (T const mini, T const maxi) | |
Constructor. | |
Range (Range< T > const &other)=default | |
Copy constructor. | |
Range (Range< T > &&other)=default | |
Move constructor. | |
template<typename U > | |
Range (Range< U > const &other) | |
Copy-conversion constructor, uses jevois::clamped_convert<T,U> internally. | |
Range< T > & | operator= (Range< T > const &other)=default |
Assignment. | |
Range< T > & | operator= (Range< T > &&other)=default |
Move assignment. | |
T const & | min () const |
Return the minimum value. | |
T const & | max () const |
Return the maximum value. | |
bool | empty () const |
Return whether min() == max() | |
void | extend (T const val) |
Extend the range, if needed, so that it includes val. | |
bool | contains (T const &val) const |
Return true if val is within [min ... max]. | |
Related Symbols | |
(Note that these are not member symbols.) | |
template<typename T > | |
Range< T > | merge (Range< T > const &r1, Range< T > const &r2) |
Merge two ranges. | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &out, Range< T > const &r) |
Stream out as "[min ... max]". | |
template<typename T > | |
std::istream & | operator>> (std::istream &in, Range< T > &r) |
Stream in as "[min ... max]". | |
template<class T > | |
void | paramValToString (Range< T > const &val, std::string &result) |
Machine-readable output to a string, for use in jevois::Parameter: outputs min ...max (e.g., 0...100) | |
template<class T > | |
void | paramStringToVal (std::string const &valstring, Range< T > &result) |
Machine-readable input from a string, for use in jevois::Parameter: reads min ...max (e.g., 0...100) | |
template<typename T > | |
bool | operator== (Range< T > const &range1, Range< T > const &range2) |
Equality test: Range<T> == Range<T> | |
template<typename T > | |
bool | operator!= (Range< T > const &range1, Range< T > const &range2) |
Inequality test: Range<T> != Range<T> | |
template<typename T > | |
Range< T > | operator+ (Range< T > const &range, T const &scalar) |
Add constant to both ends of a range: Range<T> + T. | |
template<typename T > | |
Range< T > | operator+ (T const &scalar, Range< T > const &range) |
Add constant to both ends of a range: T + Range<T> | |
template<typename T > | |
Range< T > | operator- (Range< T > const &range, T const &scalar) |
Subtract constant from both ends of a range: Range<T> - T. | |
template<typename T > | |
Range< T > | operator- (T const &scalar, Range< T > const &range) |
Subtract constant from both ends of a range: T - Range<T> | |
template<typename T > | |
Range< T > | operator/ (Range< T > const &range, T const &scalar) |
Divide both ends of a range by a factor: Range<T> / T. | |
template<typename T > | |
Range< T > | operator/ (T const &scalar, Range< T > const &range) |
Divide a factor by both ends of a range: T / Range<T> | |
template<typename T > | |
Range< T > | operator* (Range< T > const &range, T const &scalar) |
Multiply both ends of a range by a factor: Range<T> * T. | |
template<typename T > | |
Range< T > | operator* (T const &scalar, Range< T > const &range) |
Multiply a factor by both ends of a range: T * Range<T> | |
template<typename T > | |
Range< T > & | operator+= (Range< T > &range, T const &scalar) |
Add constant to both ends of a range: Range<T> += T. | |
template<typename T > | |
Range< T > & | operator-= (Range< T > &range, T const &scalar) |
Subtract constant from both ends of a range: Range<T> -= T. | |
template<typename T > | |
Range< T > & | operator*= (Range< T > &range, T const &scalar) |
Multiply both ends of a range by a factor: Range<T> *= T. | |
template<typename T > | |
Range< T > & | operator/= (Range< T > &range, T const &scalar) |
Divide both ends of a range by a factor: Range<T> /= T. | |
|
explicit |
Default constructor, range is [0 .. 0].
|
explicit |
Constructor.
|
default |
Copy constructor.
|
default |
Move constructor.
|
explicit |
Copy-conversion constructor, uses jevois::clamped_convert<T,U> internally.
Note that this constructor is explicit, i.e., you need to explicitly mention it. This is to avoid conversions to happen without a programmer being aware of it. For example:
bool jevois::Range< T >::contains | ( | T const & | val | ) | const |
Return true if val is within [min ... max].
bool jevois::Range< T >::empty | ( | ) | const |
void jevois::Range< T >::extend | ( | T const | val | ) |
Extend the range, if needed, so that it includes val.
T const & jevois::Range< T >::max | ( | ) | const |
Return the maximum value.
Referenced by jevois::GUIhelper::drawParameters().
T const & jevois::Range< T >::min | ( | ) | const |
Return the minimum value.
Referenced by jevois::GUIhelper::drawParameters().
|
default |
Move assignment.
|
default |
Assignment.
Merge two ranges.
|
related |
Inequality test: Range<T> != Range<T>
Multiply both ends of a range by a factor: Range<T> * T.
Multiply a factor by both ends of a range: T * Range<T>
Multiply both ends of a range by a factor: Range<T> *= T.
Add constant to both ends of a range: Range<T> + T.
Add constant to both ends of a range: T + Range<T>
Add constant to both ends of a range: Range<T> += T.
Subtract constant from both ends of a range: Range<T> - T.
Subtract constant from both ends of a range: T - Range<T>
Subtract constant from both ends of a range: Range<T> -= T.
Divide both ends of a range by a factor: Range<T> / T.
Divide a factor by both ends of a range: T / Range<T>
Divide both ends of a range by a factor: Range<T> /= T.
|
related |
Stream out as "[min ... max]".
|
related |
Equality test: Range<T> == Range<T>
|
related |
Stream in as "[min ... max]".
|
related |
Machine-readable input from a string, for use in jevois::Parameter: reads min
...max (e.g., 0...100)
|
related |
Machine-readable output to a string, for use in jevois::Parameter: outputs min
...max (e.g., 0...100)