CCIMXDesktop
 
Loading...
Searching...
No Matches
ValueLimiter< MIN, MAX > Class Template Reference

Runtime-configurable value limiter with compile-time defaults. More...

#include <ValueLimiter.hpp>

Public Member Functions

 ValueLimiter ()=default
 Default constructor using template bounds.
 
constexpr ValueLimiter (ValueLimitType runtime_min, ValueLimitType runtime_max)
 Construct with runtime-specified bounds.
 
constexpr ValueLimitType getMin () const noexcept
 Gets the current minimum bound.
 
constexpr ValueLimitType getMax () const noexcept
 Gets the current maximum bound.
 
void setMin (ValueLimitType v)
 Sets the minimum bound.
 
void setMax (ValueLimitType v)
 Sets the maximum bound.
 
constexpr ValueLimitType boundValue (ValueLimitType value) const
 Clamps a value to the current bounds.
 

Static Public Attributes

static constexpr ValueLimitType compileMin = MIN
 
static constexpr ValueLimitType compileMax = MAX
 

Detailed Description

template<ValueLimitType MIN = 0, ValueLimitType MAX = 100>
class ValueLimiter< MIN, MAX >

Runtime-configurable value limiter with compile-time defaults.

Template Parameters
MINDefault minimum bound (default 0)
MAXDefault maximum bound (default 100)

Constructor & Destructor Documentation

◆ ValueLimiter()

template<ValueLimitType MIN = 0, ValueLimitType MAX = 100>
constexpr ValueLimiter< MIN, MAX >::ValueLimiter ( ValueLimitType  runtime_min,
ValueLimitType  runtime_max 
)
inlineconstexpr

Construct with runtime-specified bounds.

Parameters
runtime_minThe minimum bound
runtime_maxThe maximum bound

Member Function Documentation

◆ boundValue()

template<ValueLimitType MIN = 0, ValueLimitType MAX = 100>
constexpr ValueLimitType ValueLimiter< MIN, MAX >::boundValue ( ValueLimitType  value) const
inlineconstexpr

Clamps a value to the current bounds.

Parameters
valueThe value to clamp
Returns
The clamped value

◆ getMax()

template<ValueLimitType MIN = 0, ValueLimitType MAX = 100>
constexpr ValueLimitType ValueLimiter< MIN, MAX >::getMax ( ) const
inlineconstexprnoexcept

Gets the current maximum bound.

Returns
The maximum bound value

◆ getMin()

template<ValueLimitType MIN = 0, ValueLimitType MAX = 100>
constexpr ValueLimitType ValueLimiter< MIN, MAX >::getMin ( ) const
inlineconstexprnoexcept

Gets the current minimum bound.

Returns
The minimum bound value

◆ setMax()

template<ValueLimitType MIN = 0, ValueLimitType MAX = 100>
void ValueLimiter< MIN, MAX >::setMax ( ValueLimitType  v)
inline

Sets the maximum bound.

Parameters
vThe new maximum value
Note
Automatically adjusts if new max would be less than current min

◆ setMin()

template<ValueLimitType MIN = 0, ValueLimitType MAX = 100>
void ValueLimiter< MIN, MAX >::setMin ( ValueLimitType  v)
inline

Sets the minimum bound.

Parameters
vThe new minimum value
Note
Automatically adjusts if new min would exceed current max

Member Data Documentation

◆ compileMax

template<ValueLimitType MIN = 0, ValueLimitType MAX = 100>
constexpr ValueLimitType ValueLimiter< MIN, MAX >::compileMax = MAX
staticconstexpr

Compile-time maximum bound

◆ compileMin

template<ValueLimitType MIN = 0, ValueLimitType MAX = 100>
constexpr ValueLimitType ValueLimiter< MIN, MAX >::compileMin = MIN
staticconstexpr

Compile-time minimum bound


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