libdrmconf  0.12.0
A library to program DMR radios.
ranges.hh
1 #ifndef RANGES_HH
2 #define RANGES_HH
3 
4 #include <initializer_list>
5 #include "interval.hh"
6 #include "frequency.hh"
7 
12 template <class T>
13 class Range
14 {
15 public:
17  inline T map(const T &n) const {
18  if (n < lower)
19  return lower;
20  if (upper < n)
21  return upper;
22  return n;
23  }
24 
26  inline bool contains(const T &n) const {
27  return ((lower<n) || (lower==n)) && ((n<upper) || (n==upper));
28  }
29 
30 public:
31  T lower;
32  T upper;
33 };
34 
35 
42 
43 #endif // RANGES_HH
Simple range class representing some range in some data type.
Definition: ranges.hh:14
T upper
Specifies the upper bound.
Definition: ranges.hh:32
T lower
Specifies the lower bound.
Definition: ranges.hh:31
bool contains(const T &n) const
Checks, if the given value lays within the range.
Definition: ranges.hh:26
T map(const T &n) const
Maps a given value onto the range.
Definition: ranges.hh:17