Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 11, 2010, 12:34:00 AM (14 years ago)
Author:
landauf
Message:

merged doc branch back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/ClassTreeMask.h

    r7268 r7401  
    2929/**
    3030    @file
    31     @brief Definition of the ClassTreeMask, ClassTreeMaskNode and ClassTreeMaskIterator classes.
    32 
    33     ClassTreeMask is a class to define a mask of the class-tree beginning with BaseObject.
     31    @ingroup Class
     32    @brief Declaration of the ClassTreeMask, ClassTreeMaskNode, and ClassTreeMaskIterator classes.
     33
     34    ClassTreeMask is a class to define a mask of the class-tree beginning with orxonox::BaseObject.
    3435    You can include or exclude classes by calling the corresponding functions with the
    35     Identifier of the class.
     36    orxonox::Identifier of the class. This mask can then be used to filter out objects that
     37    are instances of classes which aren't included in the tree, for example when Loading a
     38    level file or if a Trigger should be triggered by only a few classes.
     39
     40    See the description of orxonox::ClassTreeMask for a short example.
    3641
    3742    You can work with a ClassTreeMask in the sense of the set-theory, meaning that you can create
    3843    unions, intersections, complements and differences by using overloaded operators.
    3944
    40 
     45    @par Tree structure
    4146
    4247    The ClassTreeMask is internally represented by a tree. The nodes in the tree are
     
    4550    nodes changing the mask. By adding new rules, the tree gets reordered dynamically.
    4651
    47     Adding a new rule overwrites all rules assigned to inherited classes. Use overwrite = false
     52    Adding a new rule overwrites all rules assigned to inherited classes. Use <tt>overwrite = false</tt>
    4853    if you don't like this feature. Useless rules that don't change the information of the mask
    49     aren't saved in the internal tree. Use clean = false if you wan't to save them.
    50 
    51     With overwrite = false and clean = false it doesn't matter in which way you create the mask.
    52     You can manually drop useless rules from the tree by calling clean().
    53 
    54 
    55 
    56     Because of the complicated shape of the internal tree, there is an iterator to iterate
    57     through all ClassTreeMaskNodes of a mask. It starts with the BaseObject and moves on to
    58     the first subclass until it reaches a leaf of the tree. Then the iterator moves one step
    59     back and iterates to the second subclass. If there are no more subclasses, it steps another
    60     step back, and so on.
    61 
    62     Example: A and B are children of BaseObject, A1 and A2 are children of A, B1 and B2 are children of B.
    63     The ClassTreeMaskIterator would move trough the tree in the following order:
    64     BaseObject, A, A1, A2, B, B1, B2.
    65 
    66     Note that the iterator doesn't move trough the whole class-tree, but only through the
    67     internal tree of the mask, containing the minimal needed set of nodes to describe the mask.
     54    aren't saved in the internal tree. Use <tt>clean = false</tt> if you still want to save them.
     55
     56    With <tt>overwrite = false</tt> and <tt>clean = false</tt> it doesn't matter in which order
     57    you create the mask. You can manually drop useless rules from the tree by calling
     58    @ref orxonox::ClassTreeMask::clean() "clean()".
     59
     60    @par Objects
     61
     62    To iterate through all objects of the classes that were included by a ClassTreeMask,
     63    use orxonox::ClassTreeMaskObjectIterator. The description of this class also contains
     64    a short example of how to use it.
    6865*/
    6966
     
    8380    // ###      ClassTreeMaskNode      ###
    8481    // ###################################
    85     //! The ClassTreeMaskNode is a node in the internal tree of the ClassTreeMask, containing the rules of the mask.
    8682    /**
     83        @brief The ClassTreeMaskNode is a node in the internal tree of the ClassTreeMask, containing the rules of the mask.
     84
    8785        The ClassTreeMaskNode is used to store the rule (included or excluded) for a given
    8886        class (described by the corresponding Identifier). The nodes are used in the internal
     
    105103            void addSubnode(ClassTreeMaskNode* subnode);
    106104
    107             /** @brief Tells if the rule is "included" or not. @return The rule: true = included, false = excluded */
     105            /// Tells if the rule is "included" or not.
    108106            inline bool isIncluded() const { return this->bIncluded_; }
    109             /** @brief Tells if the rule is "excluded" or not. @return The inverted rule: true = excluded, false = included */
     107            /// Tells if the rule is "excluded" or not.
    110108            inline bool isExcluded() const { return (!this->bIncluded_); }
    111109
    112             /** @brief Returns the Identifier of the class the rule refers to. @return The Identifier representing the class */
     110            /// Returns the Identifier of the class the rule refers to.
    113111            inline const Identifier* getClass() const { return this->subclass_; }
    114112
    115             /** @brief Returns true if the Node has some subnodes. */
     113            /// Returns true if the node has some subnodes.
    116114            inline bool hasSubnodes() const { return !this->subnodes_.empty(); }
    117115
     
    119117            void deleteAllSubnodes();
    120118
    121             const Identifier* subclass_;                //!< The Identifier of the subclass the rule refers to
    122             bool bIncluded_;                            //!< The rule: included or excluded
    123             std::list<ClassTreeMaskNode*> subnodes_;    //!< A list containing all subnodes in the tree
     119            const Identifier* subclass_;                ///< The Identifier of the subclass the rule refers to
     120            bool bIncluded_;                            ///< The rule: included or excluded
     121            std::list<ClassTreeMaskNode*> subnodes_;    ///< A list containing all subnodes of this node
    124122    };
    125123
     
    128126    // ###    ClassTreeMaskIterator    ###
    129127    // ###################################
    130     //! The ClassTreeMaskIterator moves through all ClassTreeMaskNodes of the internal tree of a ClassTreeMask, containing the rules.
    131128    /**
     129        @brief The ClassTreeMaskIterator moves through all ClassTreeMaskNodes of the internal tree of a ClassTreeMask which contains the rules.
     130
    132131        Because of the complicated shape of the internal rule-tree of ClassTreeMask, an
    133132        iterator is used to move through all nodes of the tree. It starts with the BaseObject
     
    135134        iterator moves one step back and iterates to the second subclass. If there are no more
    136135        subclasses, it steps another step back, and so on.
     136
     137        Example: A and B are children of BaseObject, A1 and A2 are children of A, B1 and B2 are children of B.
     138        The ClassTreeMaskIterator would move trough the tree in the following order:
     139        BaseObject, A, A1, A2, B, B1, B2.
     140
     141        Note that the iterator doesn't move trough the whole class-tree, but only through the
     142        internal tree of the mask, containing the minimal needed set of nodes to describe the mask.
    137143    */
    138144    class _CoreExport ClassTreeMaskIterator
     
    150156
    151157        private:
    152             std::stack<std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator> > nodes_;    //!< A stack to store list-iterators
    153             std::list<ClassTreeMaskNode*> rootlist_;                                                                            //!< A list for internal use (it only stores the root-node)
     158            std::stack<std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator> > nodes_;    ///< A stack to store list-iterators
     159            std::list<ClassTreeMaskNode*> rootlist_;                                                                            ///< A list for internal use (it only stores the root-node)
    154160    };
    155161
     
    158164    // ###        ClassTreeMask        ###
    159165    // ###################################
    160     //! The ClassTreeMask is a set of rules, containing the information for each class whether it's included or not.
    161166    /**
     167        @brief The ClassTreeMask is a set of rules, containing the information for each class whether it's included or not.
     168
    162169        With a ClassTreeMask, you can include or exclude subtrees of the class-tree, starting
    163170        with a given subclass, described by the corresponding Identifier. To minimize the size
    164171        of the mask, the mask saves only relevant rules. But you can manually add rules that
    165         don't change the information of the mask by using clean = false. If you want to drop
     172        don't change the information of the mask by using <tt>clean = false</tt>. If you want to drop
    166173        useless rules, call the clean() function.
     174
     175        Example:
     176        @code
     177        ClassTreeMask mymask;
     178        mymask.exclude(Class(A));
     179        mymask.exclude(Class(B));
     180        mymask.include(Class(ChildOfA));
     181        @endcode
     182
     183        In this example, the classes A and B are excluded from the mask, but one of the child
     184        classes of A is included again.
    167185    */
    168186    class _CoreExport ClassTreeMask
     
    189207            bool isExcluded(const Identifier* subclass) const;
    190208
    191             /** @brief Begin of the ClassTreeMaskObjectIterator. */
     209            /// Begin of the ClassTreeMaskObjectIterator.
    192210            inline const ClassTreeMask& begin() const { return (*this); }
    193             /** @brief End of the ClassTreeMaskObjectIterator. */
     211            /// End of the ClassTreeMaskObjectIterator.
    194212            inline BaseObject*          end()   const { return 0; }
    195213
     
    228246            bool nodeExists(const Identifier* subclass);
    229247
    230             ClassTreeMaskNode* root_;   //!< The root-node of the internal rule-tree, usually BaseObject
     248            ClassTreeMaskNode* root_;   ///< The root-node of the internal rule-tree, usually BaseObject
    231249    };
    232250
     
    235253    // ### ClassTreeMaskObjectIterator ###
    236254    // ###################################
    237     //! The ClassTreeMaskObjectIterator iterates through all objects of all classes, included by a ClassTreeMask.
    238255    /**
    239         The ClassTreeMaskObjectIterator iterates through all objects of all classes,
    240         included by a ClassTreeMask. This is done the following way:
    241 
     256        @brief The ClassTreeMaskObjectIterator iterates through all objects of the classes that were included by a ClassTreeMask.
     257
     258        This is done the following way:
     259        @code
    242260        ClassTreeMask mask;
    243261        for (ClassTreeMaskObjectIterator it = mask.begin(); it != mask.end(); ++it)
    244262            it->doSomething();
    245 
    246         Note: The ClassTreeMaskObjectIterator handles all objects as BaseObjects. If
     263        @endcode
     264
     265        @note The ClassTreeMaskObjectIterator handles all objects as BaseObjects. If
    247266              you want to use another class, you should use a dynamic_cast.
    248267
    249         Performance of ClassTreeMaskObjectIterator is good as long as you don't exclude
     268        The performance of ClassTreeMaskObjectIterator is good as long as you don't exclude
    250269        subclasses of included classes. Of course you can still exlucde subclasses, but
    251270        if this is done more often, we need a new implementation using a second ObjectList
     
    255274    {
    256275        public:
    257             /** @brief Defaultconstructor: Does nothing. */
     276            /// Default-constructor: Does nothing.
    258277            inline ClassTreeMaskObjectIterator() {}
    259             /** @brief Constructor: Initializes the iterator from a given ClassTreeMask. @param mask The mask */
     278            /// Copy-Constructor: Initializes the iterator from another ClassTreeMask.
    260279            inline ClassTreeMaskObjectIterator(const ClassTreeMask& mask) { (*this) = mask; }
    261280
     
    264283            const ClassTreeMaskObjectIterator& operator++();
    265284
    266             /** @brief Returns true if the ClassTreeMaskObjectIterator points at the given object. @param pointer The pointer of the object */
     285            /// Returns true if the ClassTreeMaskObjectIterator points at the given object.
    267286            inline bool operator==(BaseObject* pointer) const { return (this->objectIterator_ && (*this->objectIterator_) == pointer) || (!this->objectIterator_ && pointer == 0); }
    268             /** @brief Returns true if the ClassTreeMaskObjectIterator doesn't point at the given object. @param pointer The pointer of the object */
     287            /// Returns true if the ClassTreeMaskObjectIterator doesn't point at the given object.
    269288            inline bool operator!=(BaseObject* pointer) const { return (this->objectIterator_ && (*this->objectIterator_) != pointer) || (!this->objectIterator_ && pointer != 0); }
    270             /** @brief Returns true if the ClassTreeMaskObjectIterator hasn't already reached the end. */
     289            /// Returns true if the ClassTreeMaskObjectIterator hasn't already reached the end.
    271290            inline operator bool() const { return (this->objectIterator_); }
    272             /** @brief Returns the object the ClassTreeMaskObjectIterator currently points at. */
     291            /// Returns the object the ClassTreeMaskObjectIterator currently points at.
    273292            inline BaseObject* operator*() const { return (*this->objectIterator_); }
    274             /** @brief Returns the object the ClassTreeMaskObjectIterator currently points at. */
     293            /// Returns the object the ClassTreeMaskObjectIterator currently points at.
    275294            inline BaseObject* operator->() const { return (*this->objectIterator_); }
    276295
     
    278297            void create(ClassTreeMaskNode* node);
    279298
    280             std::list<std::pair<const Identifier*, bool> >           subclasses_;       //!< A list of all Identifiers through which objects the iterator should iterate
    281             std::list<std::pair<const Identifier*, bool> >::iterator subclassIterator_; //!< The current class of the iterator
    282             Iterator<BaseObject>                                     objectIterator_;   //!< The current object of the iterator
     299            std::list<std::pair<const Identifier*, bool> >           subclasses_;       ///< A list of all Identifiers through which objects the iterator should iterate
     300            std::list<std::pair<const Identifier*, bool> >::iterator subclassIterator_; ///< The current class of the iterator
     301            Iterator<BaseObject>                                     objectIterator_;   ///< The current object of the iterator
    283302    };
    284303}
Note: See TracChangeset for help on using the changeset viewer.