NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
statecontroller::StateQueue Class Reference

Implements a dynamic State queue. More...

#include <state_controller.h>

Public Member Functions

 StateQueue ()
 Default constructor.
 
virtual ~StateQueue ()
 Destructor.
 
void reset ()
 Reinitialise the StateQueue object.
 
void clear ()
 For use by state controller states (guaranteed not to cause vector reallocation)
 
void clear_hard ()
 For use during reset/initialisation (may trigger vector reallocation)
 
void reserveCapacity (index_t n)
 Increase the queue capacity so that it is at least n (does nothing if the capacity is already at least n, or n is nullIndex, and throws std::bad_alloc if the allocation fails because n is too large)
 
StatePtr get (index_t ind) const
 Returns nullStatePtr if ind is out of range or nullIndex.
 
void set (index_t ind, StatePtr state)
 Does nothing if ind is out of range or nullIndex.
 
void setNextState (StatePtr state)
 Clears the entire queue and sets the next state to the given state instance (use only with simple next state logic!)
 
StatePtr getNextState () const
 Returns nullStatePtr if queue is empty.
 
void append (StatePtr state)
 Always successful.
 
void prepend (StatePtr state)
 Always successful.
 
void insertBefore (index_t ind, StatePtr state)
 Does nothing if ind is out of range or nullIndex (in this case the allowed range is up to QueueVec.size() = Queue.length() inclusive)
 
void insertAfter (index_t ind, StatePtr state)
 Does nothing if ind is out of range or nullIndex.
 
void remove (index_t ind)
 Does nothing if ind is out of range or nullIndex.
 
index_t length () const
 Always successful.
 
bool isEmpty () const
 Always successful.
 
bool validIndex (index_t ind) const
 Always successful (function returns false for nullIndex)
 
index_t headIndex () const
 Returns nullIndex if queue is empty.
 
index_t tailIndex () const
 Returns nullIndex if queue is empty.
 
StatePtr headItem () const
 Returns nullStatePtr if queue is empty.
 
StatePtr tailItem () const
 Returns nullStatePtr if queue is empty.
 
StatePtr advance ()
 Returns nullStatePtr if queue is empty.
 
bool containsID (int id) const
 Always successful.
 
bool containsState (StatePtr state) const
 Always successful.
 
StatePtr stateOf (int id, index_t start=0) const
 Returns nullStatePtr if the given ID is not found.
 
index_t indexOf (int id, index_t start=0) const
 Returns nullIndex if the given ID is not found.
 
index_t indexOf (StatePtr state, index_t start=0) const
 Returns nullIndex if the given state is not found.
 

Static Public Attributes

static const index_t DEF_QUEUE_CAPACITY = 16
 Default queue capacity to reserve in memory on reset.
 

Detailed Description

Implements a dynamic State queue.

This class is used by the StateController class to schedule states into the future for execution.


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