Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Private Attributes | List of all members
orxonox::ClassTreeMaskIterator Class Reference

The ClassTreeMaskIterator moves through all ClassTreeMaskNodes of the internal tree of a ClassTreeMask which contains the rules. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/ClassTreeMask.h>

Public Member Functions

 ClassTreeMaskIterator (ClassTreeMaskNode *node)
 Constructor: Initializes the iterator by creating a helper-list with the root-node and putting it to the stack. More...
 
 ~ClassTreeMaskIterator ()
 Destructor: Does nothing. More...
 
 operator bool () const
 Returns true if the stack is empty, meaning we've reached the end of the tree. More...
 
bool operator!= (ClassTreeMaskNode *compare) const
 Compares the current node with the given one and returns true if they don't match. More...
 
ClassTreeMaskNodeoperator* () const
 Returns a pointer to the ClassTreeMaskNode whereon the iterator points. More...
 
const ClassTreeMaskIteratoroperator++ ()
 Iterates through the rule-tree. More...
 
ClassTreeMaskNodeoperator-> () const
 Returns a pointer to the ClassTreeMaskNode whereon the iterator points. More...
 
bool operator== (ClassTreeMaskNode *compare) const
 Compares the current node with the given one and returns true if they match. More...
 

Private Attributes

std::stack< std::pair< std::list< ClassTreeMaskNode * >::iterator, std::list< ClassTreeMaskNode * >::iterator > > nodes_
 A stack to store list-iterators. More...
 
std::list< ClassTreeMaskNode * > rootlist_
 A list for internal use (it only stores the root-node) More...
 

Detailed Description

The ClassTreeMaskIterator moves through all ClassTreeMaskNodes of the internal tree of a ClassTreeMask which contains the rules.

Because of the complicated shape of the internal rule-tree of ClassTreeMask, an iterator is used to move through all nodes of the tree. It starts with the BaseObject and moves on to the first subclass until it reaches a leaf of the tree. Then the iterator moves one step back and iterates to the second subclass. If there are no more subclasses, it steps another step back, and so on.

Example: A and B are children of BaseObject, A1 and A2 are children of A, B1 and B2 are children of B. The ClassTreeMaskIterator would move trough the tree in the following order: BaseObject, A, A1, A2, B, B1, B2.

Note that the iterator doesn't move trough the whole class-tree, but only through the internal tree of the mask, containing the minimal needed set of nodes to describe the mask.

Constructor & Destructor Documentation

orxonox::ClassTreeMaskIterator::ClassTreeMaskIterator ( ClassTreeMaskNode node)

Constructor: Initializes the iterator by creating a helper-list with the root-node and putting it to the stack.

Parameters
nodeThe root-node
orxonox::ClassTreeMaskIterator::~ClassTreeMaskIterator ( )

Destructor: Does nothing.

Member Function Documentation

orxonox::ClassTreeMaskIterator::operator bool ( ) const
explicit

Returns true if the stack is empty, meaning we've reached the end of the tree.

bool orxonox::ClassTreeMaskIterator::operator!= ( ClassTreeMaskNode compare) const

Compares the current node with the given one and returns true if they don't match.

ClassTreeMaskNode * orxonox::ClassTreeMaskIterator::operator* ( ) const

Returns a pointer to the ClassTreeMaskNode whereon the iterator points.

const ClassTreeMaskIterator & orxonox::ClassTreeMaskIterator::operator++ ( )

Iterates through the rule-tree.

Returns
A reference to the iterator itself
ClassTreeMaskNode * orxonox::ClassTreeMaskIterator::operator-> ( ) const

Returns a pointer to the ClassTreeMaskNode whereon the iterator points.

bool orxonox::ClassTreeMaskIterator::operator== ( ClassTreeMaskNode compare) const

Compares the current node with the given one and returns true if they match.

Member Data Documentation

std::stack<std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator> > orxonox::ClassTreeMaskIterator::nodes_
private

A stack to store list-iterators.

std::list<ClassTreeMaskNode*> orxonox::ClassTreeMaskIterator::rootlist_
private

A list for internal use (it only stores the root-node)


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