Class time_series::TimeSeriesInterface¶
-
template<typename
T
>
classtime_series
::
TimeSeriesInterface
¶ Interface for time series.
A time_series implements \( X_{{oldest}:{newest}} \) which can safely be accessed from either multiple threads or multiple processes.
this object has the following properties:
an oldest timeindex \( oldest\),
a newest timeindex \( newest \),
a value \( X_i \) for each \( i \in \{oldest, oldest + 1 , ..., newest\} \),
a length \(length\)
and a maximum length \(maxlength\)
Public Functions
-
~TimeSeriesInterface
()¶
-
Index
newest_timeindex
(bool wait = true) const = 0¶ returns \( newest \) index. If argument wait is true, waits if the time_series is empty. If argument wait is false and the time series is empty, returns time_series::EMPTY immediately.
-
Index
count_appended_elements
() const = 0¶ returns the number of element that has been contained in the queue, i.e. the number of elements that have been added from the start.
-
Index
oldest_timeindex
(bool wait = true) const = 0¶ returns \( oldest \). waits if the time_series is empty. If argument wait is false and the time series is empty, returns time_series::EMPTY immediately.
-
T
newest_element
() const = 0¶ returns \( X_{newest} \). waits if the time_series is empty.
-
T
operator[]
(const Index &timeindex) const = 0¶ returns \( X_{timeindex} \). waits if the time_series is empty or if \(timeindex > newest \).
-
Timestamp
timestamp_ms
(const Index &timeindex) const = 0¶ returns the time in miliseconds when \( X_{timeindex} \) was appended. Waits if the time_series is empty or if \(timeindex > newest \).
-
Timestamp
timestamp_s
(const Index &timeindex) const = 0¶ returns the time in seconds when \( X_{timeindex} \) was appended. Waits if the time_series is empty or if \(timeindex > newest \).
-
bool
wait_for_timeindex
(const Index &timeindex, const double &max_duration_s = std::numeric_limits<double>::quiet_NaN()) const = 0¶ Wait until the defined time index is reached. If the input time is below the oldest time index that have been registered read an exception is return.
-
std::size_t
length
() const = 0¶ returns the length of the time_series, i.e. \(0\) if it is empty, otherwise \(newest - oldest +1 \).
-
std::size_t
max_length
() const = 0¶ returns the maximum length of the time serie.
- Return
std::size_t
-
bool
has_changed_since_tag
() const = 0¶ returns boolean indicating whether new elements have been appended since the last time the tag() function was called.
-
void
tag
(const Index &timeindex) = 0¶ tags the current time_series, can later be used to check whether new elements have been added
-
Index
tagged_timeindex
() const = 0¶ returns the index at which the time series has been tagged. Returns the newest timeindex if the time series has never been tagged.
-
void
append
(const T &element) = 0¶ appends a new element to the time_series, e.g. we go from \( X_{1:10} \) to \( X_{1:11} \) (where \( X_{11}=\) element). if the time_series length is already equal to its max_length, then the oldest element is discarded, e.g. for a max_length = 10 we would go from \( X_{1:10} \) to \( X_{2:11} \).
-
bool
is_empty
() const = 0¶ returns true if no element has ever been appended to the time series.