IDS peak AFL v2.1.0
Loading...
Searching...
No Matches
RangeT< T > Class Template Reference

Represents a numeric range with defined boundaries and a fixed increment. More...

#include <peak_common/types/peak_common_range.hpp>

Inheritance diagram for RangeT< T >:
IntervalT< T >

Public Member Functions

constexpr RangeT (T minimum, T maximum, T increment)
 Constructs a range with specified minimum, maximum, and increment values.
constexpr T GetIncrement () const
 Retrieves the increment value associated with this range.
constexpr T Constrain (T value) const
 Returns a value that is constrained to this range.
constexpr bool operator== (const RangeT &rhs) const
 Compares this range with another for equality.
constexpr bool operator!= (const RangeT &rhs) const
 Compares this range with another for inequality.
std::string ToString () const
 Returns a string representation of the range.
Public Member Functions inherited from IntervalT< T >
constexpr IntervalT (T minimum, T maximum)
 Constructs an interval with the given lower and upper bounds.
constexpr T GetMinimum () const
 Returns the lower boundary of the interval.
constexpr T GetMaximum () const
 Returns the upper boundary of the interval.
constexpr T Clamp (T value) const
 Clamps a value to the bounds of this interval.
template<typename H>
constexpr bool operator== (const IntervalT< H > &rhs) const
 Compares two intervals for equality (integral types).
template<typename H>
constexpr bool operator== (const IntervalT< H > &rhs) const
 Compares two intervals for approximate equality (floating-point types).
constexpr bool operator!= (const IntervalT &rhs) const
 Inequality comparison operator.
std::string ToString () const
 Returns a string representation of the interval.

Friends

std::ostream & operator<< (std::ostream &os, RangeT range)
 Outputs the range as a human-readable string to a stream.

Detailed Description

template<typename T>
class peak::common::detail::RangeT< T >

Represents a numeric range with defined boundaries and a fixed increment.

A RangeT models a continuous sequence of values starting from a minimum value, ending at a maximum value, and progressing in steps defined by an increment. It supports arithmetic types such as integers and floating-point numbers.

This class ensures that the increment does not exceed the total span between the minimum and maximum bounds. The range is inclusive of its boundary values.

Template Parameters
TThe numeric type used for the range values. Must be an arithmetic type (e.g., int, float).
Since
ids_peak_common 1.0

Constructor & Destructor Documentation

◆ RangeT()

template<typename T>
RangeT ( T minimum,
T maximum,
T increment )
inlineconstexpr

Constructs a range with specified minimum, maximum, and increment values.

Parameters
minimumThe inclusive starting (lower) boundary of the range.
maximumThe inclusive ending (upper) boundary of the range.
incrementThe step size or increment between values within the range.
Exceptions
InvalidParameterExceptionIf minimum is greater than maximum, or if increment exceeds the total range span.
Since
ids_peak_common 1.0

Member Function Documentation

◆ Constrain()

template<typename T>
T Constrain ( T value) const
inlineconstexpr

Returns a value that is constrained to this range.

The value is adjusted to the nearest valid increment and clamped between the minimum and maximum boundaries of this range.

Parameters
valueThe value to constrain.
Returns
The constrained value.
Since
ids_peak_common 2.1

◆ GetIncrement()

template<typename T>
T GetIncrement ( ) const
inlineconstexpr

Retrieves the increment value associated with this range.

Returns
The increment step.
Since
ids_peak_common 1.0

◆ operator!=()

template<typename T>
bool operator!= ( const RangeT< T > & rhs) const
inlineconstexpr

Compares this range with another for inequality.

Parameters
rhsThe other range to compare with.
Returns
True if the ranges are not equal; otherwise, false.
Since
ids_peak_common 1.0

◆ operator==()

template<typename T>
bool operator== ( const RangeT< T > & rhs) const
inlineconstexpr

Compares this range with another for equality.

Two ranges are equal if their boundaries and increments are the same.

Parameters
rhsThe other range to compare with.
Returns
True if the ranges are equal; otherwise, false.
Since
ids_peak_common 1.0

◆ ToString()

template<typename T>
std::string ToString ( ) const
inline

Returns a string representation of the range.

Returns
A formatted string showing the minimum, maximum and increment values.
Since
ids_peak_common 1.3

◆ operator<<

template<typename T>
std::ostream & operator<< ( std::ostream & os,
RangeT< T > range )
friend

Outputs the range as a human-readable string to a stream.

Parameters
osThe output stream.
rangeThe range to print.
Returns
Reference to the stream.
Since
ids_peak_common 1.3

The documentation for this class was generated from the following file: