Orxonox
0.0.5 Codename: Arcturus
|
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... | |
ClassTreeMaskNode * | operator* () const |
Returns a pointer to the ClassTreeMaskNode whereon the iterator points. More... | |
const ClassTreeMaskIterator & | operator++ () |
Iterates through the rule-tree. More... | |
ClassTreeMaskNode * | operator-> () 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... | |
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.
orxonox::ClassTreeMaskIterator::ClassTreeMaskIterator | ( | ClassTreeMaskNode * | node | ) |
Constructor: Initializes the iterator by creating a helper-list with the root-node and putting it to the stack.
node | The root-node |
orxonox::ClassTreeMaskIterator::~ClassTreeMaskIterator | ( | ) |
Destructor: Does nothing.
|
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.
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.
|
private |
A stack to store list-iterators.
|
private |
A list for internal use (it only stores the root-node)