21 #ifndef ValueTimeLine_h 22 #define ValueTimeLine_h 68 void add(
double begin,
double end, T value) {
74 myValues[begin] = std::make_pair(
true, value);
75 myValues[end] = std::make_pair(
false, value);
79 typename TimedValueMap::iterator endIt =
myValues.find(end);
82 myValues[begin] = std::make_pair(
true, value);
90 myValues[begin] = std::make_pair(
true, value);
104 typename TimedValueMap::const_iterator it =
myValues.upper_bound(time);
107 return it->second.second;
121 typename TimedValueMap::const_iterator afterIt =
myValues.upper_bound(time);
126 return afterIt->second.first;
140 typename TimedValueMap::const_iterator afterLow =
myValues.upper_bound(low);
141 typename TimedValueMap::const_iterator afterHigh =
myValues.upper_bound(high);
143 if (afterLow == afterHigh) {
144 return afterLow->first;
154 void fillGaps(T value,
bool extendOverBoundaries =
false) {
155 for (
typename TimedValueMap::iterator it =
myValues.begin(); it !=
myValues.end(); ++it) {
156 if (!it->second.first) {
157 it->second.second = value;
160 if (extendOverBoundaries && !
myValues.empty()) {
161 typename TimedValueMap::iterator it = --
myValues.end();
162 if (!it->second.first) {
165 value =
myValues.begin()->second.second;
167 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.