Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
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 </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/ClassTreeMask.h>

Public Member Functions

 ClassTreeMask ()
 Constructor: Adds the root-node of the tree with the first rule ("include everything"). More...
 
 ClassTreeMask (const ClassTreeMask &other)
 Copy-constructor: Adds the root-node of the tree with the first rule ("include everything") and adds all rules from the other mask. More...
 
 ~ClassTreeMask ()
 Destructor: Deletes the root node (which will delete all subnodes too). More...
 
void add (const Identifier *subclass, bool bInclude, bool overwrite=true, bool clean=true)
 Adds a new rule for a given subclass to the mask. More...
 
void addSingle (const Identifier *subclass, bool bInclude, bool clean=true)
 Adds a new rule for a single subclass. More...
 
const ClassTreeMaskbegin () const
 Begin of the ClassTreeMaskObjectIterator. More...
 
void clean ()
 Removes all unneeded rules that don't change the information of the mask. More...
 
BaseObjectend () const
 End of the ClassTreeMaskObjectIterator. More...
 
void exclude (const Identifier *subclass, bool overwrite=true, bool clean=true)
 Adds a new "exclude" rule for a given subclass to the mask. More...
 
void excludeSingle (const Identifier *subclass, bool clean=true)
 Adds a new "exclude" rule for a single subclass. More...
 
void include (const Identifier *subclass, bool overwrite=true, bool clean=true)
 Adds a new "include" rule for a given subclass to the mask. More...
 
void includeSingle (const Identifier *subclass, bool clean=true)
 Adds a new "include" rule for a single subclass. More...
 
bool isExcluded (const Identifier *subclass) const
 Tells if a given subclass is excluded or not. More...
 
bool isIncluded (const Identifier *subclass) const
 Tells if a given subclass is included or not. More...
 
ClassTreeMask operator! () const
 Inverts the mask (all included classes are now excluded and vice versa). More...
 
bool operator!= (const ClassTreeMask &other) const
 Compares the mask with another mask and returns true if they represent different logics. More...
 
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). More...
 
const ClassTreeMaskoperator&= (const ClassTreeMask &other)
 Intersects this mask with another mask (and-operation) More...
 
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). More...
 
const ClassTreeMaskoperator*= (const ClassTreeMask &other)
 Intersects this mask with another mask. More...
 
const ClassTreeMaskoperator+ () const
 Prefix operator + does nothing. More...
 
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). More...
 
const ClassTreeMaskoperator+= (const ClassTreeMask &other)
 Unites this mask with another mask. More...
 
ClassTreeMask operator- () const
 Prefix operator - inverts the mask. More...
 
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). More...
 
const ClassTreeMaskoperator-= (const ClassTreeMask &other)
 Subtracts another mask from this mask. More...
 
ClassTreeMaskoperator= (const ClassTreeMask &other)
 Assignment operator: Adds all rules of the other mask. More...
 
bool operator== (const ClassTreeMask &other) const
 Compares the mask with another mask and returns true if they represent the same logic. More...
 
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). More...
 
const ClassTreeMaskoperator^= (const ClassTreeMask &other)
 Joins this mask with another mask with a xor-operation. More...
 
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). More...
 
const ClassTreeMaskoperator|= (const ClassTreeMask &other)
 Unites this mask with another mask (or-operation). More...
 
ClassTreeMask operator~ () const
 Inverts the mask (all included classes are now excluded and vice versa). More...
 
void reset ()
 Resets the mask to "include everything". More...
 

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). More...
 
void clean (ClassTreeMaskNode *node)
 Removes all unneded rules that don't change the information of a node of a mask (recursive function). More...
 
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). More...
 
bool nodeExists (const Identifier *subclass)
 Checks if a node for the given subclass exists. More...
 

Private Attributes

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

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. More...
 

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.

Example:

mymask.exclude(Class(A));
mymask.exclude(Class(B));
mymask.include(Class(ChildOfA));

In this example, the classes A and B are excluded from the mask, but one of the child classes of A is included again.

Constructor & Destructor Documentation

orxonox::ClassTreeMask::ClassTreeMask ( )

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

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

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

orxonox::ClassTreeMask::~ClassTreeMask ( )

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

Member Function Documentation

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
subclassThe subclass
bIncludeThe rule: include (true) or exclude (false)
overwriteTrue = overwrite previously added rules for inheriting classes
cleanTrue = clean the tree after adding the new rule
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
nodeThe node
subclassThe subclass
bIncludeThe rule: include (true) or exclude (false)
overwriteTrue = overwrite previously added rules for inheriting classes
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
bIncludeThe rule: include (true) or exclude (false)
subclassThe subclass
cleanTrue = clean the tree after adding the new rule
const ClassTreeMask& orxonox::ClassTreeMask::begin ( ) const
inline
void orxonox::ClassTreeMask::clean ( )

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

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
nodeThe node
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
subclassThe subclass
overwriteTrue = overwrite previously added rules for inheriting classes
cleanTrue = clean the tree after adding the new rule
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
subclassThe subclass
cleanTrue = clean the tree after adding the new rule
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
subclassThe subclass
overwriteTrue = overwrite previously added rules for inheriting classes
cleanTrue = clean the tree after adding the new rule
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
subclassThe subclass
cleanTrue = clean the tree after adding the new rule
bool orxonox::ClassTreeMask::isExcluded ( const Identifier subclass) const

Tells if a given subclass is excluded or not.

Parameters
subclassThe subclass
Returns
The inverted rule: Excluded (true) or included (false)
bool orxonox::ClassTreeMask::isIncluded ( const Identifier subclass) const

Tells if a given subclass is included or not.

Parameters
subclassThe subclass
Returns
Included (true) or excluded (false)
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
nodeThe node
subclassThe subclass
Returns
Included (true) or excluded (false)
bool orxonox::ClassTreeMask::nodeExists ( const Identifier subclass)
private

Checks if a node for the given subclass exists.

Parameters
subclassThe Identifier of the subclass
Returns
True = the node exists
ClassTreeMask orxonox::ClassTreeMask::operator! ( ) const

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

Returns
The complement
bool orxonox::ClassTreeMask::operator!= ( const ClassTreeMask other) const

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

Parameters
otherThe 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
otherThe mask to intersect with
Returns
The intersection
const ClassTreeMask & orxonox::ClassTreeMask::operator&= ( const ClassTreeMask other)

Intersects this mask with another mask (and-operation)

Parameters
otherThe other mask
Returns
A reference to the mask itself
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
otherThe mask to intersect with
Returns
The intersection
const ClassTreeMask & orxonox::ClassTreeMask::operator*= ( const ClassTreeMask other)

Intersects this mask with another mask.

Parameters
otherThe other mask
Returns
A reference to the mask itself
const ClassTreeMask & orxonox::ClassTreeMask::operator+ ( ) const

Prefix operator + does nothing.

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
otherThe mask to unite with
Returns
The union
const ClassTreeMask & orxonox::ClassTreeMask::operator+= ( const ClassTreeMask other)

Unites this mask with another mask.

Parameters
otherThe other mask
Returns
A reference to the mask itself
ClassTreeMask orxonox::ClassTreeMask::operator- ( ) const

Prefix operator - inverts the mask.

Returns
The inverted mask
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
otherThe mask to subtract.
Returns
The difference
const ClassTreeMask & orxonox::ClassTreeMask::operator-= ( const ClassTreeMask other)

Subtracts another mask from this mask.

Parameters
otherThe other mask
Returns
A reference to the mask itself
ClassTreeMask & orxonox::ClassTreeMask::operator= ( const ClassTreeMask other)

Assignment operator: Adds all rules of the other mask.

Parameters
otherThe other mask
Returns
A reference to the mask itself
bool orxonox::ClassTreeMask::operator== ( const ClassTreeMask other) const

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

Parameters
otherThe other mask
Returns
True if both masks represent the same logic
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
otherThe mask to join with
Returns
The result
const ClassTreeMask & orxonox::ClassTreeMask::operator^= ( const ClassTreeMask other)

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

Parameters
otherThe 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
otherThe mask to unite with
Returns
The union
const ClassTreeMask & orxonox::ClassTreeMask::operator|= ( const ClassTreeMask other)

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

Parameters
otherThe 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".

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
outThe ostream
maskThe mask
Returns
A reference to the ostream

Member Data Documentation

ClassTreeMaskNode* orxonox::ClassTreeMask::root_
private

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


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