MIRA
Public Types | Public Member Functions | List of all members
StampedDataQueue< T > Class Template Reference

Implements a queue where Stamped data can be added. More...

#include <utils/StampedDataQueue.h>

Public Types

typedef std::list< Stamped< T >, Eigen::aligned_allocator< T > > Container
 The type of the underlying container. More...
 
typedef Stamped< T > value_type
 some typedefs for STL compliance More...
 
typedef Container::const_iterator const_iterator
 some typedefs for STL compliance More...
 
typedef Container::size_type size_type
 some typedefs for STL compliance More...
 

Public Member Functions

 StampedDataQueue (size_type maxCapacity=100, Duration maxStorageTime=Duration::seconds(10))
 Creates new StampedDataQueue with the specified maximum capacity (default 100) and maximum storage time (default 10 seconds). More...
 
void setMaxStorageTime (Duration maxStorageTime)
 Sets the maximum storage time. More...
 
size_type capacity () const
 Returns the maximum number of items that can be stored in the queue. More...
 
void reserve (size_type n)
 Request a change in capacity. More...
 
size_type size () const
 Returns the number of stored elements. More...
 
bool empty () const
 Returns true, if no element is stored. More...
 
bool insert (const Stamped< T > &data)
 Inserts new data to the queue. More...
 
void clear ()
 clears the whole queue and removes all elements More...
 
const Stamped< T > & getData (const Time &timestamp) const
 Returns the data from the queue whose time stamp is closest to the specified timestamp. More...
 
std::pair< const_iterator, const_iteratorgetInterval (const Time &timestamp, std::size_t size, std::size_t before, std::size_t after)
 Returns two iterators that mark the begin and end of an interval of data. More...
 

Detailed Description

template<typename T>
class mira::StampedDataQueue< T >

Implements a queue where Stamped data can be added.

Afterwards the data can be obtained by specifying an arbitrary timestamp. The queue will then search within the stored data to return the data that corresponds to the requested timestamp.

In order to control the number of elements in the queue, a maximum number of items can be specified (the capacity). Additionally, a maximum storage time span can be specified. This ensures that data is removed from the queue if it is older than the timestamp of the latest entry plus the max. storage time.

Member Typedef Documentation

◆ Container

typedef std::list<Stamped<T>, Eigen::aligned_allocator<T> > Container

The type of the underlying container.

◆ value_type

typedef Stamped<T> value_type

some typedefs for STL compliance

◆ const_iterator

typedef Container::const_iterator const_iterator

some typedefs for STL compliance

◆ size_type

typedef Container::size_type size_type

some typedefs for STL compliance

Constructor & Destructor Documentation

◆ StampedDataQueue()

StampedDataQueue ( size_type  maxCapacity = 100,
Duration  maxStorageTime = Duration::seconds(10) 
)
inline

Creates new StampedDataQueue with the specified maximum capacity (default 100) and maximum storage time (default 10 seconds).

Member Function Documentation

◆ setMaxStorageTime()

void setMaxStorageTime ( Duration  maxStorageTime)
inline

Sets the maximum storage time.

◆ capacity()

size_type capacity ( ) const
inline

Returns the maximum number of items that can be stored in the queue.

If more items are added, the oldest items will get lost.

◆ reserve()

void reserve ( size_type  n)
inline

Request a change in capacity.

Requests that the capacity of the queue for the elements of the vector container be at least enough to hold n elements.

Note
The capacity only can grow.

◆ size()

size_type size ( ) const
inline

Returns the number of stored elements.

◆ empty()

bool empty ( ) const
inline

Returns true, if no element is stored.

◆ insert()

bool insert ( const Stamped< T > &  data)
inline

Inserts new data to the queue.

Returns true, if the data was inserted. Returns false, if the data is too old and was not inserted into the queue.

◆ clear()

void clear ( )
inline

clears the whole queue and removes all elements

◆ getData()

const Stamped<T>& getData ( const Time timestamp) const
inline

Returns the data from the queue whose time stamp is closest to the specified timestamp.

◆ getInterval()

std::pair<const_iterator,const_iterator> getInterval ( const Time timestamp,
std::size_t  size,
std::size_t  before,
std::size_t  after 
)
inline

Returns two iterators that mark the begin and end of an interval of data.

The interval is specified by the four parameters, where 'size' specifies the desired length of the interval. The 'before' and 'after' parameter specify the desired number of data items before (=older than) and after (=newer than) the specified 'timestamp'. If 'before'+'after' is lower than 'size', the method will add additional items before and after the given time stamp in order to fulfill the 'size' constraint, if possible.

If there is a data item in the queue with exactly the requested timestamp, it counts on the after side.

Note
The second returned iterator marks the end of the requested interval, i.e. like with container ends its predecessor is the last valid member of that interval itself, fulfilling the before constraint

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