JeVois  1.20
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
jevois::StepRange< T > Class Template Reference

#include <jevois/Types/StepRange.H>

template<typename T>
class jevois::StepRange< T >

A generic range class with a step.

The StepRange class is used to represent a range from [min .. (step) .. max]

Valid values are min, min+step, min+2*step, min+3*step, ... max. Note that max is a valid value even if it is not equal to min+N*step for some integer N. Note that T must be a numeric type (can be cast to double). Throws if step is not a positive or zero number.

Because StepRange is typically only used for limited specific purposes (e.g., defining paremeters for controls in video4linux framegrabbers), the interface provided is minimal (much more limited than that of jevois::Range).

Definition at line 69 of file StepRange.H.

Public Member Functions

 StepRange ()
 Default constructor, range is [0 .. (0) .. 0]. More...
 
 StepRange (T const mini, T const stepi, T const maxi)
 Constructor. More...
 
 StepRange (StepRange< T > const &other)=default
 Copy constructor. More...
 
 StepRange (StepRange< T > &&other)=default
 Move constructor. More...
 
template<typename U >
 StepRange (StepRange< U > const &other)
 Copy-conversion constructor, uses jevois::clamped_convert<T,U> internally. More...
 
StepRange< T > & operator= (StepRange< T > const &other)=default
 Assignment. More...
 
StepRange< T > & operator= (StepRange< T > &&other)=default
 Move assignment. More...
 
const T & min () const
 Return the minimum value. More...
 
const T & step () const
 Return the step value. More...
 
const T & max () const
 Return the maximum value. More...
 
bool empty () const
 Return whether min() == max() More...
 
bool isValueValid (T const val) const
 Return true if a value is valid (i.e., it is min, min+step, min+step*2, ... or max) More...
 

Related Functions

(Note that these are not member functions.)

template<typename T >
std::ostream & operator<< (std::ostream &out, StepRange< T > const &r)
 Stream out as "min...(step)...max". More...
 
template<typename T >
std::istream & operator>> (std::istream &in, StepRange< T > &r)
 Stream in as "min...(step)...max". More...
 
template<class T >
void paramValToString (StepRange< T > const &val, std::string &result)
 Machine-readable output to a string, for use in jevois::Parameter: outputs min...step...max. More...
 
template<class T >
void paramStringToVal (std::string const &valstring, StepRange< T > &result)
 Machine-readable input from a string, for use in jevois::Parameter: reads min...step...max. More...
 
template<typename T >
bool operator== (StepRange< T > const &range1, StepRange< T > const &range2)
 Equality test: StepRange<T> == StepRange<T> More...
 
template<typename T >
bool operator!= (StepRange< T > const &range1, StepRange< T > const &range2)
 Inequality test: StepRange<T> != StepRange<T> More...
 

Constructor & Destructor Documentation

◆ StepRange() [1/5]

template<typename T >
jevois::StepRange< T >::StepRange ( )
explicit

Default constructor, range is [0 .. (0) .. 0].

◆ StepRange() [2/5]

template<typename T >
jevois::StepRange< T >::StepRange ( T const  mini,
T const  stepi,
T const  maxi 
)
explicit

Constructor.

◆ StepRange() [3/5]

template<typename T >
jevois::StepRange< T >::StepRange ( StepRange< T > const &  other)
default

Copy constructor.

◆ StepRange() [4/5]

template<typename T >
jevois::StepRange< T >::StepRange ( StepRange< T > &&  other)
default

Move constructor.

◆ StepRange() [5/5]

template<typename T >
template<typename U >
jevois::StepRange< T >::StepRange ( StepRange< U > const &  other)
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:

void myFunc(jevois::StepRange<float> const & rng) { ... }
jevois::StepRange<int> r1(0, 5, 100);
jevois::StepRange<float> r2(r1); // ok, explicit constructor call
myFunc(r2); // ok, no conversion necessary
//myFunc(r1) // NO: passing StepRange<int> to function that takes a StepRange<float> arg fails to compile
myFunc(jevois::StepRange<float>(r1)); // ok, nice and explicit; and you can think about whether r1 should
// have been a StepRange<float> in the first place so you don't waste CPU
// doing this conversion (as opposed to just not being aware of the wasting)

Member Function Documentation

◆ empty()

template<typename T >
bool jevois::StepRange< T >::empty ( ) const

Return whether min() == max()

◆ isValueValid()

template<typename T >
bool jevois::StepRange< T >::isValueValid ( T const  val) const

Return true if a value is valid (i.e., it is min, min+step, min+step*2, ... or max)

◆ max()

template<typename T >
const T& jevois::StepRange< T >::max ( ) const

Return the maximum value.

◆ min()

template<typename T >
const T& jevois::StepRange< T >::min ( ) const

Return the minimum value.

◆ operator=() [1/2]

template<typename T >
StepRange<T>& jevois::StepRange< T >::operator= ( StepRange< T > &&  other)
default

Move assignment.

◆ operator=() [2/2]

template<typename T >
StepRange<T>& jevois::StepRange< T >::operator= ( StepRange< T > const &  other)
default

Assignment.

◆ step()

template<typename T >
const T& jevois::StepRange< T >::step ( ) const

Return the step value.

Friends And Related Function Documentation

◆ operator!=()

template<typename T >
bool operator!= ( StepRange< T > const &  range1,
StepRange< T > const &  range2 
)
related

Inequality test: StepRange<T> != StepRange<T>

◆ operator<<()

template<typename T >
std::ostream & operator<< ( std::ostream &  out,
StepRange< T > const &  r 
)
related

Stream out as "min...(step)...max".

◆ operator==()

template<typename T >
bool operator== ( StepRange< T > const &  range1,
StepRange< T > const &  range2 
)
related

Equality test: StepRange<T> == StepRange<T>

◆ operator>>()

template<typename T >
std::istream & operator>> ( std::istream &  in,
StepRange< T > &  r 
)
related

Stream in as "min...(step)...max".

◆ paramStringToVal()

template<class T >
void paramStringToVal ( std::string const &  valstring,
StepRange< T > &  result 
)
related

Machine-readable input from a string, for use in jevois::Parameter: reads min...step...max.

◆ paramValToString()

template<class T >
void paramValToString ( StepRange< T > const &  val,
std::string &  result 
)
related

Machine-readable output to a string, for use in jevois::Parameter: outputs min...step...max.


The documentation for this class was generated from the following file:
jevois::StepRange
A generic range class with a step.
Definition: StepRange.H:69