Range.h
Go to the documentation of this file.
1 /********************************************************************
2  *
3  * Project Artec 3D Scanning SDK
4  *
5  * Purpose: Definition of template range class
6  *
7  * Copyright: Artec Group
8  *
9  ********************************************************************/
10 
11 #ifndef _RANGE_H_
12 #define _RANGE_H_
13 
14 namespace artec { namespace sdk { namespace base
15 {
16 
17 /*
18 * Template class for ranges
19 */
20 
21 template < typename T >
22 struct Range
23 {
24  typedef T value_type;
25 
26  Range() : low(T()), high(T()) {}
27  Range(const T & low, const T & high) : low(low), high(high) {}
28 
29  /// check if range contain that value
30  bool contains(const T & value) const { return value >= low && value <= high; }
31 
32  /// check if the value lie inside the range
33  bool operator()(const T & value) const { return value > low && value < high; }
34  bool operator[](const T & value) const { return value >= low && value <= high; }
35 
36  T low;
37  T high;
38 };
39 
43 
44 } } } // namespace artec::sdk::base
45 
46 #endif //_RANGE_H_
Range(const T &low, const T &high)
Definition: Range.h:27
bool contains(const T &value) const
check if range contain that value
Definition: Range.h:30
Range< float > RangeF
Definition: Range.h:41
bool operator[](const T &value) const
Definition: Range.h:34
Range< int > RangeI
Definition: Range.h:40
bool operator()(const T &value) const
check if the value lie inside the range
Definition: Range.h:33
Range< double > RangeD
Definition: Range.h:42