OSVR-Core
Public Types | Public Member Functions | Static Public Member Functions | List of all members
osvr::util::ValueOrRange< ValueType > Class Template Reference

Class providing a unified container-like interface to either a single value or a range of integers. More...

#include <ValueOrRange.h>

Public Types

typedef ValueType value_type
 
typedef detail::ValueOrRangeIterator< ValueType > const_iterator
 
typedef const_iterator iterator
 
typedef ValueType size_type
 

Public Member Functions

 ValueOrRange ()
 Default constructor: an empty range.
 
template<typename T >
bool contains (T val) const
 Determine if the range contains the given value (treating a value instance of this object as essentially a single-element range)
 
ValueType getMin () const
 Get minimum value - closed lower bound. More...
 
ValueType getMax () const
 Get maximum value - closed upper bound. More...
 
bool isValue () const
 Has the object been assigned a single value (range of size 1)
 
bool isNonEmptyRange () const
 Has the object been assigned a range of size > 1?
 
bool empty () const
 Is the object an empty range? (default constructor, or setting to a range with max < min)
 
size_type size () const
 
value_type getValue () const
 
void setValue (ValueType val)
 Assign a single value to this object.
 
void setEmpty ()
 Assign an empty range to this object.
 
void setRangeMaxMin (ValueType maxVal, ValueType minVal=0)
 Assign a range of values to this object. More...
 
ValueOrRange getIntersection (ValueOrRange other) const
 Gets the (possibly empty) intersection of the ranges/values.
 
void extendRangeToMax (ValueType maxVal)
 If this is an initialized range, extend it as needed such that the given maxVal is included. More...
 
const_iterator begin () const
 Get a "begin" iterator pointing to the first value in the range (or value)
 
const_iterator end () const
 Get a "past-the-end" iterator pointing to one more than the max value)
 

Static Public Member Functions

static ValueOrRange SingleValue (ValueType val)
 Factory method for creating a single-value range.
 
static ValueOrRange RangeZeroTo (ValueType maxVal)
 Factory method for creating a range from zero.
 
static ValueOrRange RangeMaxMin (ValueType maxVal, ValueType minVal)
 Factory method for creating a range from zero.
 

Detailed Description

template<typename ValueType>
class osvr::util::ValueOrRange< ValueType >

Class providing a unified container-like interface to either a single value or a range of integers.

Member Function Documentation

§ extendRangeToMax()

template<typename ValueType>
void osvr::util::ValueOrRange< ValueType >::extendRangeToMax ( ValueType  maxVal)
inline

If this is an initialized range, extend it as needed such that the given maxVal is included.

§ getMax()

template<typename ValueType>
ValueType osvr::util::ValueOrRange< ValueType >::getMax ( ) const
inline

Get maximum value - closed upper bound.

Only valid if not empty()!

§ getMin()

template<typename ValueType>
ValueType osvr::util::ValueOrRange< ValueType >::getMin ( ) const
inline

Get minimum value - closed lower bound.

Only valid if not empty()!

§ setRangeMaxMin()

template<typename ValueType>
void osvr::util::ValueOrRange< ValueType >::setRangeMaxMin ( ValueType  maxVal,
ValueType  minVal = 0 
)
inline

Assign a range of values to this object.

Note the order of parameters to make minimum (0) optional.

Giving a range of size == 1 is the same as calling setValue(). Giving a range where min is greater than max sets the range to be empty, discarding your provided max and min values for sentinel values.


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