Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
settlerlib::SortedDeque< M > Class Template Reference

Adds helper routines to the STL Deque for holding messages with headers. More...

#include <sorted_deque.h>

List of all members.

Public Member Functions

void add (const M &msg)
 Add a new element to the deque, correctly sorted by timestamp.
bool getClosestElem (const ros::Time &time, M &out)
 Get the elem that occurs closest to the specified time.
bool getElemAfterTime (const ros::Time &time, M &out) const
 Grab the oldest element that occurs right after the specified time.
bool getElemBeforeTime (const ros::Time &time, M &out) const
 Grab the oldest element that occurs right before the specified time.
std::vector< M > getInterval (const ros::Time &start, const ros::Time &end)
 Extract all the elements that occur in the interval between the start and end times.
std::vector< M > getSurroundingInterval (const ros::Time &start, const ros::Time &end)
void removeAllBeforeTime (const ros::Time &time)
 Removes all elements that occur before the specified time.
void setMaxSize (unsigned int max_size)
 Set the maximum # of elements this deque can hold. Older elems are popped once the length is exeeded.
 SortedDeque (std::string logger="deque")
 Assumes that '.header.stamp' can be used to get the stamp used for sorting.
 SortedDeque (boost::function< const ros::Time &(const M &)> getStampFunc, std::string logger="deque")
 Advanced constructor, allowing user to specific the timestamp getter method.

Static Public Member Functions

static const ros::TimegetHeaderStamp (const M &m)
static const ros::TimegetPtrStamp (const M &m)
static const ros::TimegetStructStamp (const M &m)

Private Member Functions

void DEQUE_DEBUG_STATS (const std::string &prefix)

Private Attributes

boost::function< const
ros::Time &(const M &)> 
getStamp
std::string logger_
unsigned int max_size_

Detailed Description

template<class M>
class settlerlib::SortedDeque< M >

Adds helper routines to the STL Deque for holding messages with headers.

Provides functionality to store a deque of messages that are sorted by timestamp. Users can then extract specific intervals of messages. Old messages fall off the back of the deque

Definition at line 58 of file sorted_deque.h.


Constructor & Destructor Documentation

template<class M>
settlerlib::SortedDeque< M >::SortedDeque ( std::string  logger = "deque") [inline]

Assumes that '.header.stamp' can be used to get the stamp used for sorting.

Parameters:
loggername of rosconsole logger to display debugging output from this deque

Definition at line 78 of file sorted_deque.h.

template<class M>
settlerlib::SortedDeque< M >::SortedDeque ( boost::function< const ros::Time &(const M &)>  getStampFunc,
std::string  logger = "deque" 
) [inline]

Advanced constructor, allowing user to specific the timestamp getter method.

Parameters:
getStampFuncFunction pointer specific how to get timestamp from the contained datatype
loggername of rosconsole logger to display debugging output from this deque

Definition at line 89 of file sorted_deque.h.


Member Function Documentation

template<class M>
void settlerlib::SortedDeque< M >::add ( const M &  msg) [inline]

Add a new element to the deque, correctly sorted by timestamp.

Parameters:
msgthe element to add

Definition at line 109 of file sorted_deque.h.

template<class M>
void settlerlib::SortedDeque< M >::DEQUE_DEBUG_STATS ( const std::string &  prefix) [inline, private]

Definition at line 329 of file sorted_deque.h.

template<class M>
bool settlerlib::SortedDeque< M >::getClosestElem ( const ros::Time time,
M &  out 
) [inline]

Get the elem that occurs closest to the specified time.

Parameters:
timeThe time that we want to closest elem to
outOutput: Stores the extracted elem
Returns:
False if the queue is empty

Definition at line 258 of file sorted_deque.h.

template<class M>
bool settlerlib::SortedDeque< M >::getElemAfterTime ( const ros::Time time,
M &  out 
) const [inline]

Grab the oldest element that occurs right after the specified time.

Parameters:
timeThe time that must occur before the elem
outOutput: Stores the extracted elem
Returns:
False there are no elems after the specified time

Definition at line 232 of file sorted_deque.h.

template<class M>
bool settlerlib::SortedDeque< M >::getElemBeforeTime ( const ros::Time time,
M &  out 
) const [inline]

Grab the oldest element that occurs right before the specified time.

Parameters:
timeThe time that must occur after the elem
outOutput: Stores the extracted elem
Returns:
False there are no elems before the specified time

Definition at line 206 of file sorted_deque.h.

template<class M>
static const ros::Time& settlerlib::SortedDeque< M >::getHeaderStamp ( const M &  m) [inline, static]

Definition at line 313 of file sorted_deque.h.

template<class M>
std::vector<M> settlerlib::SortedDeque< M >::getInterval ( const ros::Time start,
const ros::Time end 
) [inline]

Extract all the elements that occur in the interval between the start and end times.

Parameters:
startThe start of the interval
endThe end of the interval

Definition at line 141 of file sorted_deque.h.

template<class M>
static const ros::Time& settlerlib::SortedDeque< M >::getPtrStamp ( const M &  m) [inline, static]

Definition at line 303 of file sorted_deque.h.

template<class M>
static const ros::Time& settlerlib::SortedDeque< M >::getStructStamp ( const M &  m) [inline, static]

Definition at line 308 of file sorted_deque.h.

template<class M>
std::vector<M> settlerlib::SortedDeque< M >::getSurroundingInterval ( const ros::Time start,
const ros::Time end 
) [inline]

Retrieve the smallest interval of messages that surrounds an interval from start to end. If the messages in the cache do not surround (start,end), then this will return the interval that gets closest to surrounding (start,end)

Definition at line 174 of file sorted_deque.h.

template<class M>
void settlerlib::SortedDeque< M >::removeAllBeforeTime ( const ros::Time time) [inline]

Removes all elements that occur before the specified time.

Parameters:
timeAll elems that occur before this are removed from the deque

Definition at line 287 of file sorted_deque.h.

template<class M>
void settlerlib::SortedDeque< M >::setMaxSize ( unsigned int  max_size) [inline]

Set the maximum # of elements this deque can hold. Older elems are popped once the length is exeeded.

Parameters:
max_sizeThe maximum # of elems to hold. Passing in 0 implies that the queue can grow indefinitely (which is a recipe for a memory leak)

Definition at line 100 of file sorted_deque.h.


Member Data Documentation

template<class M>
boost::function<const ros::Time&(const M&)> settlerlib::SortedDeque< M >::getStamp [private]

Definition at line 327 of file sorted_deque.h.

template<class M>
std::string settlerlib::SortedDeque< M >::logger_ [private]

Definition at line 319 of file sorted_deque.h.

template<class M>
unsigned int settlerlib::SortedDeque< M >::max_size_ [private]

Definition at line 318 of file sorted_deque.h.


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


settlerlib
Author(s): Vijay Pradeep
autogenerated on Wed Aug 26 2015 10:56:05