SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ValueTimeLine< T > Class Template Reference

#include <ValueTimeLine.h>

Collaboration diagram for ValueTimeLine< T >:
Collaboration graph

Public Member Functions

void add (SUMOReal begin, SUMOReal end, T value)
 Adds a value for a time interval into the container. More...
 
bool describesTime (SUMOReal time) const
 Returns whether a value for the given time is known. More...
 
void fillGaps (T value, bool extendOverBoundaries=false)
 Sets a default value for all unset intervals. More...
 
SUMOReal getSplitTime (SUMOReal low, SUMOReal high) const
 Returns the time point at which the value changes. More...
 
getValue (SUMOReal time) const
 Returns the value for the given time. More...
 
 ValueTimeLine ()
 Constructor. More...
 
 ~ValueTimeLine ()
 Destructor. More...
 

Private Types

typedef std::map< SUMOReal,
ValidValue
TimedValueMap
 Sorted map from start of intervals to values. More...
 
typedef std::pair< bool, T > ValidValue
 Value of time line, indicating validity. More...
 

Private Attributes

TimedValueMap myValues
 The list of time periods (with values) More...
 

Detailed Description

template<typename T>
class ValueTimeLine< T >

A time line being a sorted container of non-overlapping time-ranges with assigned values. The container is sorted by the first value of the time-range while being filled. Every new inserted time range may overwrite or split one or multiple earlier intervals.

Definition at line 53 of file ValueTimeLine.h.

Member Typedef Documentation

template<typename T>
typedef std::map<SUMOReal, ValidValue> ValueTimeLine< T >::TimedValueMap
private

Sorted map from start of intervals to values.

Definition at line 176 of file ValueTimeLine.h.

template<typename T>
typedef std::pair<bool, T> ValueTimeLine< T >::ValidValue
private

Value of time line, indicating validity.

Definition at line 173 of file ValueTimeLine.h.

Constructor & Destructor Documentation

template<typename T>
ValueTimeLine< T >::ValueTimeLine ( )
inline

Constructor.

Definition at line 56 of file ValueTimeLine.h.

template<typename T>
ValueTimeLine< T >::~ValueTimeLine ( )
inline

Destructor.

Definition at line 59 of file ValueTimeLine.h.

Member Function Documentation

template<typename T>
void ValueTimeLine< T >::add ( SUMOReal  begin,
SUMOReal  end,
value 
)
inline

Adds a value for a time interval into the container.

Make sure that begin >= 0 and begin < end.

Parameters
[in]beginthe start time of the time range (inclusive)
[in]endthe end time of the time range (exclusive)
[in]valuethe value to store

Definition at line 69 of file ValueTimeLine.h.

Referenced by ROEdge::addEffort(), ROEdge::addTravelTime(), ROMAEdge::setFlow(), and ROMAEdge::setHelpFlow().

template<typename T>
bool ValueTimeLine< T >::describesTime ( SUMOReal  time) const
inline

Returns whether a value for the given time is known.

This method implements the bounds checking. It returns true if and only if an explicit value was set for the given time using add. Default values stemming from fillGaps are not considered valid.

Parameters
[in]thetime for which the value should be retrieved
Returns
whether a valid value was set

Definition at line 121 of file ValueTimeLine.h.

Referenced by ROEdge::getStoredEffort(), ROEdge::getTravelTime(), ROEdge::hasLoadedTravelTime(), MSEdgeWeightsStorage::retrieveExistingEffort(), and MSEdgeWeightsStorage::retrieveExistingTravelTime().

template<typename T>
void ValueTimeLine< T >::fillGaps ( value,
bool  extendOverBoundaries = false 
)
inline

Sets a default value for all unset intervals.

Parameters
[in]valuethe value to store
[in]extendOverBoundarieswhether the first/last value should be valid for later / earlier times as well

Definition at line 155 of file ValueTimeLine.h.

Referenced by ROEdge::buildTimeLines().

template<typename T>
SUMOReal ValueTimeLine< T >::getSplitTime ( SUMOReal  low,
SUMOReal  high 
) const
inline

Returns the time point at which the value changes.

If the two input parameters lie in two consecutive time intervals, this method returns the point at which the interval changes. In any other case -1 is returned.

Parameters
[in]lowthe time in the first interval
[in]highthe time in the second interval
Returns
the split point

Definition at line 140 of file ValueTimeLine.h.

Referenced by ROEdge::getStoredEffort(), and ROEdge::getTravelTime().

template<typename T>
T ValueTimeLine< T >::getValue ( SUMOReal  time) const
inline

Returns the value for the given time.

There is no bounds checking applied! If there was no value set, the return value is undefined, the method may even segfault.

Parameters
[in]thetime for which the value should be retrieved
Returns
the value for the time

Definition at line 103 of file ValueTimeLine.h.

Referenced by ROMAEdge::getFlow(), ROMAEdge::getHelpFlow(), ROEdge::getStoredEffort(), ROEdge::getTravelTime(), MSEdgeWeightsStorage::retrieveExistingEffort(), and MSEdgeWeightsStorage::retrieveExistingTravelTime().

Field Documentation


The documentation for this class was generated from the following file: