OSVR-Core
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
osvr::vbtracker::history::HistoryContainer< ValueType, AllowDuplicateTimes_ > Class Template Reference

Stores values over time, in chronological order, in a deque for two-ended access. More...

#include <HistoryContainer.h>

Public Types

using value_type = ValueType
 
using timestamp_type = detail::timestamp
 
using full_value_type = detail::full_value_type< value_type >
 
using container_type = detail::inner_container_type< value_type >
 
using size_type = detail::container_size_type< value_type >
 
using iterator = detail::iterator< value_type >
 
using const_iterator = iterator
 
using comparator_type = detail::TimestampPairLessThan< value_type >
 
using subset_range_type = detail::HistorySubsetRange< value_type >
 

Public Member Functions

size_type size () const
 Get number of entries in history.
 
size_type highWaterMark () const
 Get the maximum number of entries ever recorded.
 
bool empty () const
 Gets whether history is empty or not.
 
timestamp_type const & oldest_timestamp () const
 
value_type const & oldest () const
 
timestamp_type const & newest_timestamp () const
 Returns the newest timestamp in the container. More...
 
value_type const & newest () const
 
void pop_oldest ()
 
void pop_newest ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
const_iterator end () const
 
const_iterator cend () const
 
void clear ()
 
bool is_strictly_newest (timestamp_type const &tv) const
 Returns true if the given timestamp is strictly newer than the newest timestamp in the container, or if the container is empty (thus making the timestamp trivially newest)
 
bool is_as_new_as_newest (timestamp_type const &tv) const
 Returns true if the given timestamp is no older than the newest timestamp in the container, or if the container is empty (thus making the timestamp trivially newest)
 
bool is_valid_to_push_newest (timestamp_type const &tv)
 Returns true if the given timestamp meets the criteria of push_newest: strictly newest if AllowDuplicateTimes is false, as new as newest if AllowDuplicateTimes is true. More...
 
const_iterator upper_bound (timestamp_type const &tv) const
 Wrapper around std::upper_bound: returns iterator to first element newer than timestamp given or end() if none. More...
 
const_iterator lower_bound (timestamp_type const &tv) const
 Wrapper around std::lower_bound: returns iterator to first element with timestamp equal or newer than timestamp given or end() if none. More...
 
const_iterator closest_not_newer (timestamp_type const &tv) const
 Return an iterator to the newest, last pair of timestamp and value that is not newer than the given timestamp. More...
 
subset_range_type get_range_newer_than (timestamp_type const &tv) const
 Returns a proxy object that can be treated as a range in a range-for loop to iterate over all elements strictly newer than the given timestamp. More...
 
size_type pop_before (timestamp_type const &tv)
 Remove all entries in history with timestamps strictly older than the given timestamp. More...
 
size_type pop_after (timestamp_type const &tv)
 Remove all entries in history with timestamps strictly newer than the given timestamp. More...
 
void push_newest (osvr::util::time::TimeValue const &tv, value_type const &value)
 Adds a new value to history. More...
 

Static Public Member Functions

static comparator_type comparator ()
 Returns a comparison functor (comparing timestamps) for use with standard algorithms like lower_bound and upper_bound.
 

Static Public Attributes

static const bool AllowDuplicateTimes = AllowDuplicateTimes_
 Whether multiple entries with the same timestamp are permitted to be pushed. More...
 

Detailed Description

template<typename ValueType, bool AllowDuplicateTimes_ = true>
class osvr::vbtracker::history::HistoryContainer< ValueType, AllowDuplicateTimes_ >

Stores values over time, in chronological order, in a deque for two-ended access.

Member Function Documentation

§ closest_not_newer()

template<typename ValueType, bool AllowDuplicateTimes_ = true>
const_iterator osvr::vbtracker::history::HistoryContainer< ValueType, AllowDuplicateTimes_ >::closest_not_newer ( timestamp_type const &  tv) const
inline

Return an iterator to the newest, last pair of timestamp and value that is not newer than the given timestamp.

If none meet this criteria, returns end().

This will return one element past where we want. It's OK if that's end(), but not if it's begin().

§ get_range_newer_than()

template<typename ValueType, bool AllowDuplicateTimes_ = true>
subset_range_type osvr::vbtracker::history::HistoryContainer< ValueType, AllowDuplicateTimes_ >::get_range_newer_than ( timestamp_type const &  tv) const
inline

Returns a proxy object that can be treated as a range in a range-for loop to iterate over all elements strictly newer than the given timestamp.

(Uses upper_bound internally.)

§ is_valid_to_push_newest()

template<typename ValueType, bool AllowDuplicateTimes_ = true>
bool osvr::vbtracker::history::HistoryContainer< ValueType, AllowDuplicateTimes_ >::is_valid_to_push_newest ( timestamp_type const &  tv)
inline

Returns true if the given timestamp meets the criteria of push_newest: strictly newest if AllowDuplicateTimes is false, as new as newest if AllowDuplicateTimes is true.

§ lower_bound()

template<typename ValueType, bool AllowDuplicateTimes_ = true>
const_iterator osvr::vbtracker::history::HistoryContainer< ValueType, AllowDuplicateTimes_ >::lower_bound ( timestamp_type const &  tv) const
inline

Wrapper around std::lower_bound: returns iterator to first element with timestamp equal or newer than timestamp given or end() if none.

§ newest_timestamp()

template<typename ValueType, bool AllowDuplicateTimes_ = true>
timestamp_type const& osvr::vbtracker::history::HistoryContainer< ValueType, AllowDuplicateTimes_ >::newest_timestamp ( ) const
inline

Returns the newest timestamp in the container.

Caveat: throws an exception in an empty container - if you want to actually compare to see if you're at least as new as the newest, see is_as_new_as_newest(), if you want to see if your value is newer than all others, see is_strictly_newest(). Both of these contain special handling for empty containers.

§ pop_after()

template<typename ValueType, bool AllowDuplicateTimes_ = true>
size_type osvr::vbtracker::history::HistoryContainer< ValueType, AllowDuplicateTimes_ >::pop_after ( timestamp_type const &  tv)
inline

Remove all entries in history with timestamps strictly newer than the given timestamp.

Returns
number of elements removed.

§ pop_before()

template<typename ValueType, bool AllowDuplicateTimes_ = true>
size_type osvr::vbtracker::history::HistoryContainer< ValueType, AllowDuplicateTimes_ >::pop_before ( timestamp_type const &  tv)
inline

Remove all entries in history with timestamps strictly older than the given timestamp.

Returns
number of elements removed.
Todo:
is this right?

§ push_newest()

template<typename ValueType, bool AllowDuplicateTimes_ = true>
void osvr::vbtracker::history::HistoryContainer< ValueType, AllowDuplicateTimes_ >::push_newest ( osvr::util::time::TimeValue const &  tv,
value_type const &  value 
)
inline

Adds a new value to history.

It must be newer (or equal time, based on template parameters) than the newest (or the history must be empty).

§ upper_bound()

template<typename ValueType, bool AllowDuplicateTimes_ = true>
const_iterator osvr::vbtracker::history::HistoryContainer< ValueType, AllowDuplicateTimes_ >::upper_bound ( timestamp_type const &  tv) const
inline

Wrapper around std::upper_bound: returns iterator to first element newer than timestamp given or end() if none.

Member Data Documentation

§ AllowDuplicateTimes

template<typename ValueType, bool AllowDuplicateTimes_ = true>
const bool osvr::vbtracker::history::HistoryContainer< ValueType, AllowDuplicateTimes_ >::AllowDuplicateTimes = AllowDuplicateTimes_
static

Whether multiple entries with the same timestamp are permitted to be pushed.


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