19 #ifndef ValueTimeLine_h 20 #define ValueTimeLine_h 61 void add(
double begin,
double end, T value) {
67 myValues[begin] = std::make_pair(
true, value);
68 myValues[end] = std::make_pair(
false, value);
72 typename TimedValueMap::iterator endIt =
myValues.find(end);
75 myValues[begin] = std::make_pair(
true, value);
83 myValues[begin] = std::make_pair(
true, value);
97 typename TimedValueMap::const_iterator it =
myValues.upper_bound(time);
100 return it->second.second;
114 typename TimedValueMap::const_iterator afterIt =
myValues.upper_bound(time);
119 return afterIt->second.first;
133 typename TimedValueMap::const_iterator afterLow =
myValues.upper_bound(low);
134 typename TimedValueMap::const_iterator afterHigh =
myValues.upper_bound(high);
136 if (afterLow == afterHigh) {
137 return afterLow->first;
147 void fillGaps(T value,
bool extendOverBoundaries =
false) {
148 for (
typename TimedValueMap::iterator it =
myValues.begin(); it !=
myValues.end(); ++it) {
149 if (!it->second.first) {
150 it->second.second = value;
153 if (extendOverBoundaries && !
myValues.empty()) {
154 typename TimedValueMap::iterator it = --
myValues.end();
155 if (!it->second.first) {
158 value =
myValues.begin()->second.second;
160 myValues[-1] = std::make_pair(
false, value);
void fillGaps(T value, bool extendOverBoundaries=false)
Sets a default value for all unset intervals.
double getSplitTime(double low, double high) const
Returns the time point at which the value changes.
~ValueTimeLine()
Destructor.
bool describesTime(double time) const
Returns whether a value for the given time is known.
void add(double begin, double end, T value)
Adds a value for a time interval into the container.
std::map< double, ValidValue > TimedValueMap
Sorted map from start of intervals to values.
T getValue(double time) const
Returns the value for the given time.
std::pair< bool, double > ValidValue
Value of time line, indicating validity.
TimedValueMap myValues
The list of time periods (with values)
ValueTimeLine()
Constructor.