Template Class Schedule

Inheritance Relationships

Base Type

  • public std::map< boost::posix_time::ptime, T >

Class Documentation

template<typename T>
class Schedule : public std::map<boost::posix_time::ptime, T>

A template class that represents a schedule with time points as keys.

This class stores values of type T, indexed by time, and provides methods to add, generate, accumulate, extrapolate, and scatter values.

Public Functions

inline bool add(const boost::posix_time::ptime &t, const T &v)

Add a value at a specific time point.

Parameters:
  • t – The time point at which the value is added.

  • v – The value to be added.

Returns:

True if the value was added successfully, false otherwise.

inline void generate(const boost::posix_time::ptime &start, const boost::posix_time::ptime &end, const boost::posix_time::time_duration &gap, const T &value)

Generate values at regular intervals between a start and end time.

Parameters:
  • start – The start time.

  • end – The end time.

  • gap – The time gap between each value.

  • value – The value to be assigned to each time point.

inline T accumulate(const boost::posix_time::ptime &begin, const boost::posix_time::ptime &end, const T &init) const

Accumulate the values in the schedule over a specified time range.

Parameters:
  • begin – The start time of the range.

  • end – The end time of the range.

  • init – The initial value to start the accumulation.

Returns:

The accumulated value over the specified time range.

inline void extrapolate(const boost::posix_time::ptime &end, const boost::posix_time::time_duration &gap, const T &value)

Extrapolate values to a specified end time using a given gap.

Parameters:
  • end – The end time to extrapolate to.

  • gap – The time gap between each extrapolated value.

  • value – The value to be assigned to the extrapolated time points.

inline void extrapolate(const boost::posix_time::ptime &end)

Extrapolate values to a specified end time using median gap.

If the schedule contains multiple time points, it calculates the median gap and uses it to extrapolate the values.

Parameters:

end – The end time to extrapolate to.

inline void scatter(const boost::posix_time::ptime &reference_time, const TenorCalculator *f, Scatter<T> &out) const

Scatter values based on a reference time using a tenor calculator.

This method calculates the tenor between the reference time and each time point, adding the corresponding value to the output scatter.

Parameters:
  • reference_time – The reference time used to calculate tenor.

  • f – The tenor calculator.

  • out – The scatter object where the results are stored.

inline std::map<boost::posix_time::ptime, T> to_map()

Convert the schedule to a regular map.

Returns:

A map with time points as keys and values of type T.