orxonox::ClassTreeMask Class Reference

The ClassTreeMask is a set of rules, containing the information for each class whether it's included or not. More...

#include <src/core/ClassTreeMask.h>

List of all members.

Public Member Functions

void add (const Identifier *subclass, bool bInclude, bool overwrite=true, bool clean=true)
 Adds a new rule for a given subclass to the mask.
void addSingle (const Identifier *subclass, bool bInclude, bool clean=true)
 Adds a new rule for a single subclass. The new rule doesn't change the mask for inheriting classes.
const ClassTreeMaskbegin () const
 Begin of the ClassTreeMaskObjectIterator.
 ClassTreeMask (const ClassTreeMask &other)
 Copyconstructor: Adds the root-node of the tree with the first rule ("include everything") and adds all rules from the other mask.
 ClassTreeMask ()
 Constructor: Adds the root-node of the tree with the first rule ("include everything").
void clean ()
 Removes all unneeded rules that don't change the information of the mask.
BaseObjectend () const
 End of the ClassTreeMaskObjectIterator.
void exclude (const Identifier *subclass, bool overwrite=true, bool clean=true)
 Adds a new "exclude" rule for a given subclass to the mask.
void excludeSingle (const Identifier *subclass, bool clean=true)
 Adds a new "exclude" rule for a single subclass. The new rule doesn't change the mask for inheriting classes.
void include (const Identifier *subclass, bool overwrite=true, bool clean=true)
 Adds a new "include" rule for a given subclass to the mask.
void includeSingle (const Identifier *subclass, bool clean=true)
 Adds a new "include" rule for a single subclass. The new rule doesn't change the mask for inheriting classes.
bool isExcluded (const Identifier *subclass) const
 Tells if a given subclass is excluded or not.
bool isIncluded (const Identifier *subclass) const
 Tells if a given subclass is included or not.
ClassTreeMask operator & (const ClassTreeMask &other) const
 Intersects two masks (only classes that are included in both masks will be included in the resulting mask too).
const ClassTreeMaskoperator &= (const ClassTreeMask &other)
 Intersects this mask with another mask (and-operation).
ClassTreeMask operator! () const
 Inverts the mask (all included classes are now excluded and vice versa).
bool operator!= (const ClassTreeMask &other) const
 Compares the mask with another mask and returns true if they represent different logics.
ClassTreeMask operator* (const ClassTreeMask &other) const
 Intersects two masks (only classes that are included in both masks will be included in the resulting mask too).
const ClassTreeMaskoperator*= (const ClassTreeMask &other)
 Intersects this mask with another mask.
ClassTreeMask operator+ (const ClassTreeMask &other) const
 Adds two masks in the sense of a union (all classes that are included in at least one of the masks will be included in the resulting mask too).
const ClassTreeMaskoperator+ () const
 Prefix operator + does nothing.
const ClassTreeMaskoperator+= (const ClassTreeMask &other)
 Unites this mask with another mask.
ClassTreeMask operator- (const ClassTreeMask &other) const
 Removes all elements of the second mask from the first mask (all classes that are included in the first mask stay included, except those that are included in the second mask too).
ClassTreeMask operator- () const
 Prefix operator - inverts the mask.
const ClassTreeMaskoperator-= (const ClassTreeMask &other)
 Subtracts another mask from this mask.
const ClassTreeMaskoperator= (const ClassTreeMask &other)
 Assignment operator: Adds all rules of the other mask.
bool operator== (const ClassTreeMask &other) const
 Compares the mask with another mask and returns true if they represent the same logic.
ClassTreeMask operator^ (const ClassTreeMask &other) const
 Joins two masks in the sense of a xor (exclusivity) operation (all classes that are included in exactly one of the masks, but not in both, will be included in the resulting mask too).
const ClassTreeMaskoperator^= (const ClassTreeMask &other)
 Joins this mask with another mask with a xor-operation.
ClassTreeMask operator| (const ClassTreeMask &other) const
 Adds two masks in the sense of a union (all classes that are included in at least one of the masks will be included in the resulting mask too).
const ClassTreeMaskoperator|= (const ClassTreeMask &other)
 Unites this mask with another mask (or-operation).
ClassTreeMask operator~ () const
 Inverts the mask (all included classes are now excluded and vice versa).
void reset ()
 Resets the mask to "include everything".
 ~ClassTreeMask ()
 Destructor: Deletes the root node (which will delete all subnodes too).

Private Member Functions

void add (ClassTreeMaskNode *node, const Identifier *subclass, bool bInclude, bool overwrite=true)
 Adds a new rule for a given subclass to a node of the internal rule-tree (recursive function).
void clean (ClassTreeMaskNode *node)
 Removes all unneded rules that don't change the information of a node of a mask (recursive function).
bool isIncluded (ClassTreeMaskNode *node, const Identifier *subclass) const
 Tells if a given subclass of a node in the rule-tree is included or not (recursive function).
bool nodeExists (const Identifier *subclass)
 Checks if a node for the given subclass exists.

Private Attributes

ClassTreeMaskNoderoot_
 The root-node of the internal rule-tree, usually BaseObject.

Friends

class ClassTreeMaskObjectIterator
std::ostream & operator<< (std::ostream &out, const ClassTreeMask &mask)
 Converts the content of a mask into a human readable string and puts it on the ostream.


Detailed Description

The ClassTreeMask is a set of rules, containing the information for each class whether it's included or not.

With a ClassTreeMask, you can include or exclude subtrees of the class-tree, starting with a given subclass, described by the corresponding Identifier. To minimize the size of the mask, the mask saves only relevant rules. But you can manually add rules that don't change the information of the mask by using clean = false. If you want to drop useless rules, call the clean() function.


Constructor & Destructor Documentation

orxonox::ClassTreeMask::ClassTreeMask (  ) 

Constructor: Adds the root-node of the tree with the first rule ("include everything").

References root_.

orxonox::ClassTreeMask::ClassTreeMask ( const ClassTreeMask other  ) 

Copyconstructor: Adds the root-node of the tree with the first rule ("include everything") and adds all rules from the other mask.

Parameters:
other The other mask

References root_.

orxonox::ClassTreeMask::~ClassTreeMask (  ) 

Destructor: Deletes the root node (which will delete all subnodes too).

References root_.


Member Function Documentation

void orxonox::ClassTreeMask::add ( ClassTreeMaskNode node,
const Identifier subclass,
bool  bInclude,
bool  overwrite = true 
) [private]

Adds a new rule for a given subclass to a node of the internal rule-tree (recursive function).

Parameters:
node The node
subclass The subclass
bInclude The rule: include (true) or exclude (false)
overwrite True = overwrite previously added rules for inheriting classes

References orxonox::ClassTreeMaskNode::addSubnode(), orxonox::ClassTreeMaskNode::getClass(), orxonox::Identifier::isA(), orxonox::ClassTreeMaskNode::setIncluded(), and orxonox::ClassTreeMaskNode::subnodes_.

void orxonox::ClassTreeMask::add ( const Identifier subclass,
bool  bInclude,
bool  overwrite = true,
bool  clean = true 
)

Adds a new rule for a given subclass to the mask.

Parameters:
subclass The subclass
bInclude The rule: include (true) or exclude (false)
overwrite True = overwrite previously added rules for inheriting classes
clean True = clean the tree after adding the new rule

References clean(), orxonox::Identifier::getDirectChildrenBegin(), orxonox::Identifier::getDirectChildrenEnd(), orxonox::Identifier::isA(), nodeExists(), and root_.

Referenced by operator!(), operator*(), operator+(), and operator^().

void orxonox::ClassTreeMask::addSingle ( const Identifier subclass,
bool  bInclude,
bool  clean = true 
)

Adds a new rule for a single subclass. The new rule doesn't change the mask for inheriting classes.

Parameters:
bInclude The rule: include (true) or exclude (false)
subclass The subclass
clean True = clean the tree after adding the new rule

References orxonox::Identifier::getDirectChildrenBegin(), orxonox::Identifier::getDirectChildrenEnd(), and isIncluded().

Referenced by excludeSingle(), and includeSingle().

const ClassTreeMask& orxonox::ClassTreeMask::begin (  )  const [inline]

void orxonox::ClassTreeMask::clean ( ClassTreeMaskNode node  )  [private]

Removes all unneded rules that don't change the information of a node of a mask (recursive function).

Parameters:
node The node

References clean(), orxonox::ClassTreeMaskNode::isIncluded(), and orxonox::ClassTreeMaskNode::subnodes_.

void orxonox::ClassTreeMask::clean (  ) 

Removes all unneeded rules that don't change the information of the mask.

References root_.

Referenced by add(), clean(), operator*(), operator+(), orxonox::ClassTreeMaskObjectIterator::operator=(), operator==(), and operator^().

BaseObject* orxonox::ClassTreeMask::end (  )  const [inline]

void orxonox::ClassTreeMask::exclude ( const Identifier subclass,
bool  overwrite = true,
bool  clean = true 
)

Adds a new "exclude" rule for a given subclass to the mask.

Parameters:
subclass The subclass
overwrite True = overwrite previously added rules for inheriting classes
clean True = clean the tree after adding the new rule

Referenced by orxonox::DistanceTrigger::addTargets(), orxonox::DistanceTrigger::DistanceTrigger(), orxonox::Level::networkcallback_applyXMLFile(), orxonox::CheckPoint::notifyMaskUpdate(), and orxonox::DistanceTrigger::removeTargets().

void orxonox::ClassTreeMask::excludeSingle ( const Identifier subclass,
bool  clean = true 
)

Adds a new "exclude" rule for a single subclass. The new rule doesn't change the mask for inheriting classes.

Parameters:
subclass The subclass
clean True = clean the tree after adding the new rule

References addSingle().

void orxonox::ClassTreeMask::include ( const Identifier subclass,
bool  overwrite = true,
bool  clean = true 
)

Adds a new "include" rule for a given subclass to the mask.

Parameters:
subclass The subclass
overwrite True = overwrite previously added rules for inheriting classes
clean True = clean the tree after adding the new rule

Referenced by orxonox::DistanceTrigger::addTargets(), orxonox::Level::networkcallback_applyXMLFile(), and orxonox::CheckPoint::notifyMaskUpdate().

void orxonox::ClassTreeMask::includeSingle ( const Identifier subclass,
bool  clean = true 
)

Adds a new "include" rule for a single subclass. The new rule doesn't change the mask for inheriting classes.

Parameters:
subclass The subclass
clean True = clean the tree after adding the new rule

References addSingle().

bool orxonox::ClassTreeMask::isExcluded ( const Identifier subclass  )  const

Tells if a given subclass is excluded or not.

Parameters:
subclass The subclass
Returns:
The inverted rule: Excluded (true) or included (false)

References isIncluded().

bool orxonox::ClassTreeMask::isIncluded ( ClassTreeMaskNode node,
const Identifier subclass 
) const [private]

Tells if a given subclass of a node in the rule-tree is included or not (recursive function).

Parameters:
node The node
subclass The subclass
Returns:
Included (true) or excluded (false)

References orxonox::ClassTreeMaskNode::getClass(), orxonox::Identifier::isA(), isIncluded(), orxonox::ClassTreeMaskNode::isIncluded(), and orxonox::ClassTreeMaskNode::subnodes_.

bool orxonox::ClassTreeMask::isIncluded ( const Identifier subclass  )  const

Tells if a given subclass is included or not.

Parameters:
subclass The subclass
Returns:
Included (true) or excluded (false)

References root_.

Referenced by addSingle(), orxonox::XMLPortObjectContainer::identifierIsIncludedInLoaderMask(), isExcluded(), isIncluded(), operator!(), operator*(), operator+(), operator^(), and orxonox::Loader::unload().

bool orxonox::ClassTreeMask::nodeExists ( const Identifier subclass  )  [private]

Checks if a node for the given subclass exists.

Parameters:
subclass The Identifier of the subclass
Returns:
True = the node exists

References root_.

Referenced by add().

ClassTreeMask orxonox::ClassTreeMask::operator & ( const ClassTreeMask other  )  const

Intersects two masks (only classes that are included in both masks will be included in the resulting mask too).

Parameters:
other The mask to intersect with
Returns:
The intersection

const ClassTreeMask & orxonox::ClassTreeMask::operator &= ( const ClassTreeMask other  ) 

Intersects this mask with another mask (and-operation).

Parameters:
other The other mask
Returns:
A reference to the mask itself

ClassTreeMask orxonox::ClassTreeMask::operator! (  )  const

Inverts the mask (all included classes are now excluded and vice versa).

Returns:
The complement

References add(), isIncluded(), and root_.

bool orxonox::ClassTreeMask::operator!= ( const ClassTreeMask other  )  const

Compares the mask with another mask and returns true if they represent different logics.

Parameters:
other The other mask
Returns:
True if the masks represent different logics

ClassTreeMask orxonox::ClassTreeMask::operator* ( const ClassTreeMask other  )  const

Intersects two masks (only classes that are included in both masks will be included in the resulting mask too).

Parameters:
other The mask to intersect with
Returns:
The intersection

References add(), clean(), isIncluded(), and root_.

const ClassTreeMask & orxonox::ClassTreeMask::operator*= ( const ClassTreeMask other  ) 

Intersects this mask with another mask.

Parameters:
other The other mask
Returns:
A reference to the mask itself

ClassTreeMask orxonox::ClassTreeMask::operator+ ( const ClassTreeMask other  )  const

Adds two masks in the sense of a union (all classes that are included in at least one of the masks will be included in the resulting mask too).

Parameters:
other The mask to unite with
Returns:
The union

References add(), clean(), isIncluded(), and root_.

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

Prefix operator + does nothing.

Returns:
A reference to the mask itself

const ClassTreeMask & orxonox::ClassTreeMask::operator+= ( const ClassTreeMask other  ) 

Unites this mask with another mask.

Parameters:
other The other mask
Returns:
A reference to the mask itself

ClassTreeMask orxonox::ClassTreeMask::operator- ( const ClassTreeMask other  )  const

Removes all elements of the second mask from the first mask (all classes that are included in the first mask stay included, except those that are included in the second mask too).

Parameters:
other The mask to subtract.
Returns:
The difference

ClassTreeMask orxonox::ClassTreeMask::operator- (  )  const

Prefix operator - inverts the mask.

Returns:
The inverted mask

const ClassTreeMask & orxonox::ClassTreeMask::operator-= ( const ClassTreeMask other  ) 

Subtracts another mask from this mask.

Parameters:
other The other mask
Returns:
A reference to the mask itself

const ClassTreeMask & orxonox::ClassTreeMask::operator= ( const ClassTreeMask other  ) 

Assignment operator: Adds all rules of the other mask.

Parameters:
other The other mask
Returns:
A reference to the mask itself

References reset(), and root_.

bool orxonox::ClassTreeMask::operator== ( const ClassTreeMask other  )  const

Compares the mask with another mask and returns true if they represent the same logic.

Parameters:
other The other mask
Returns:
True if both masks represent the same logic

References clean(), and root_.

ClassTreeMask orxonox::ClassTreeMask::operator^ ( const ClassTreeMask other  )  const

Joins two masks in the sense of a xor (exclusivity) operation (all classes that are included in exactly one of the masks, but not in both, will be included in the resulting mask too).

Parameters:
other The mask to join with
Returns:
The result

References add(), clean(), isIncluded(), and root_.

const ClassTreeMask & orxonox::ClassTreeMask::operator^= ( const ClassTreeMask other  ) 

Joins this mask with another mask with a xor-operation.

Parameters:
other The other mask
Returns:
A reference to the mask itself

ClassTreeMask orxonox::ClassTreeMask::operator| ( const ClassTreeMask other  )  const

Adds two masks in the sense of a union (all classes that are included in at least one of the masks will be included in the resulting mask too).

Parameters:
other The mask to unite with
Returns:
The union

const ClassTreeMask & orxonox::ClassTreeMask::operator|= ( const ClassTreeMask other  ) 

Unites this mask with another mask (or-operation).

Parameters:
other The other mask
Returns:
A reference to the mask itself

ClassTreeMask orxonox::ClassTreeMask::operator~ (  )  const

Inverts the mask (all included classes are now excluded and vice versa).

Returns:
The complement

void orxonox::ClassTreeMask::reset (  ) 

Resets the mask to "include everything".

References root_.

Referenced by operator=().


Friends And Related Function Documentation

friend class ClassTreeMaskObjectIterator [friend]

std::ostream& operator<< ( std::ostream &  out,
const ClassTreeMask mask 
) [friend]

Converts the content of a mask into a human readable string and puts it on the ostream.

Parameters:
out The ostream
mask The mask
Returns:
A reference to the ostream


Member Data Documentation


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

Generated on Tue Jul 28 16:22:23 2009 for Orxonox by  doxygen 1.5.6