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

The ClassTreeMaskObjectIterator iterates through all objects of the classes that were included by a ClassTreeMask. More...

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

Public Member Functions

 ClassTreeMaskObjectIterator ()=default
 Default-constructor: Does nothing. More...
 
 ClassTreeMaskObjectIterator (const ClassTreeMask &mask)
 Copy-Constructor: Initializes the iterator from another ClassTreeMask. More...
 
 operator bool () const
 Returns true if the ClassTreeMaskObjectIterator hasn't already reached the end. More...
 
bool operator!= (BaseObject *pointer) const
 Returns true if the ClassTreeMaskObjectIterator doesn't point at the given object. More...
 
BaseObjectoperator* () const
 Returns the object the ClassTreeMaskObjectIterator currently points at. More...
 
const ClassTreeMaskObjectIteratoroperator++ ()
 Iterate to the next object (if any). More...
 
BaseObjectoperator-> () const
 Returns the object the ClassTreeMaskObjectIterator currently points at. More...
 
ClassTreeMaskObjectIteratoroperator= (const ClassTreeMask &mask)
 Initializes the iterator from a given ClassTreeMask. More...
 
bool operator== (BaseObject *pointer) const
 Returns true if the ClassTreeMaskObjectIterator points at the given object. More...
 

Private Member Functions

void create (ClassTreeMaskNode *node)
 Recursive function to create the Iterators subclass-list by going through the node-tree of the mask. More...
 

Private Attributes

Iterator< BaseObjectobjectIterator_
 The current object of the iterator. More...
 
std::list< std::pair< const Identifier *, bool > > subclasses_
 A list of all Identifiers through which objects the iterator should iterate. More...
 
std::list< std::pair< const Identifier *, bool > >::iterator subclassIterator_
 The current class of the iterator. More...
 

Detailed Description

The ClassTreeMaskObjectIterator iterates through all objects of the classes that were included by a ClassTreeMask.

This is done the following way:

ClassTreeMask mask;
for (ClassTreeMaskObjectIterator it = mask.begin(); it != mask.end(); ++it)
it->doSomething();
Note
The ClassTreeMaskObjectIterator handles all objects as BaseObjects. If you want to use another class, you should use a dynamic_cast.

The performance of ClassTreeMaskObjectIterator is good as long as you don't exclude subclasses of included classes. Of course you can still exlucde subclasses, but if this is done more often, we need a new implementation using a second ObjectList in the Identifier, containing all objects of exactly one class.

Constructor & Destructor Documentation

orxonox::ClassTreeMaskObjectIterator::ClassTreeMaskObjectIterator ( )
inlinedefault

Default-constructor: Does nothing.

orxonox::ClassTreeMaskObjectIterator::ClassTreeMaskObjectIterator ( const ClassTreeMask mask)
inline

Copy-Constructor: Initializes the iterator from another ClassTreeMask.

Member Function Documentation

void orxonox::ClassTreeMaskObjectIterator::create ( ClassTreeMaskNode node)
private

Recursive function to create the Iterators subclass-list by going through the node-tree of the mask.

Parameters
nodeThe current node
orxonox::ClassTreeMaskObjectIterator::operator bool ( ) const
inlineexplicit

Returns true if the ClassTreeMaskObjectIterator hasn't already reached the end.

bool orxonox::ClassTreeMaskObjectIterator::operator!= ( BaseObject pointer) const
inline

Returns true if the ClassTreeMaskObjectIterator doesn't point at the given object.

BaseObject* orxonox::ClassTreeMaskObjectIterator::operator* ( ) const
inline

Returns the object the ClassTreeMaskObjectIterator currently points at.

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

Iterate to the next object (if any).

Returns
The iterator itself
BaseObject* orxonox::ClassTreeMaskObjectIterator::operator-> ( ) const
inline

Returns the object the ClassTreeMaskObjectIterator currently points at.

ClassTreeMaskObjectIterator & orxonox::ClassTreeMaskObjectIterator::operator= ( const ClassTreeMask mask)

Initializes the iterator from a given ClassTreeMask.

Parameters
maskThe mask
bool orxonox::ClassTreeMaskObjectIterator::operator== ( BaseObject pointer) const
inline

Returns true if the ClassTreeMaskObjectIterator points at the given object.

Member Data Documentation

Iterator<BaseObject> orxonox::ClassTreeMaskObjectIterator::objectIterator_
private

The current object of the iterator.

std::list<std::pair<const Identifier*, bool> > orxonox::ClassTreeMaskObjectIterator::subclasses_
private

A list of all Identifiers through which objects the iterator should iterate.

std::list<std::pair<const Identifier*, bool> >::iterator orxonox::ClassTreeMaskObjectIterator::subclassIterator_
private

The current class of the iterator.


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