Range.hh
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Range.hh
*
* Created on: 20 nov. 2013
* Author: CS
*/
#ifndef RANGE_HH_
#define RANGE_HH_
#include <utility>
#include <cmath>
#include <string>
#include <ostream>
namespace plot {
class Range {
public:
Range() :
_extend(true), _range(nan(""), nan("")) {
}
Range(double min, double max) :
_extend(true), _range(min, max) {
}
Range(const Range& pRange) :
_extend(pRange._extend), _range(pRange._range) {
}
virtual ~Range() {
}
double getMin() const {
return _range.first;
}
double getMax() const {
return _range.second;
}
void setMin(double min) {
_range.first = min;
}
void setMax(double max) {
_range.second = max;
}
bool isSet() {
return !std::isnan(_range.first) || !std::isnan(_range.second);
}
void dump(std::ostream& out, std::string& prefix) {
out << prefix << "range.min=" << getMin() << std::endl;
out << prefix << "range.max=" << getMax() << std::endl;
}
bool _extend;
private:
std::pair<double, double> _range;
};
inline std::ostream& operator <<(std::ostream& out, const Range& range) {
out << "[" << range.getMin() << ", " << range.getMax() << "]" << std::endl;
return out;
}
double extend2UpperValue(double lValue);
double extend2LowerValue(double lValue);
Range extendRange(Range pRange);
} /* namespace plot */
#endif /* RANGE_HH_ */