Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 16, 2008, 7:31:18 PM (16 years ago)
Author:
landauf
Message:

big update:

  • reimplemented direct-child and direct-parent list and several related functions (get-iterator, get-list)
  • reimplemented isDirectChildOf- and isDirectParentOf-functions in Identifier, SubclassIdentifier and OrxonoxClass
  • renamed isDirectlyA to isExactlyA in Identifier, SubclassIdentifier and OrxonoxClass
  • ClassTreeMask works now with interfaces and has more possibilities (parameters for overwriting of previous rules and cleaning after adding a new function)
  • ObjectList's begin() and end() functions use ClassManager to avoid problems with libraries
  • the Factory got functions to return begin() and end() iterator for the identifier-map
  • overloaded << operator to put identifier-lists on the stream
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core/src/orxonox/core/Identifier.h

    r814 r817  
    3939
    4040    Every object has a pointer to the Identifier of its class. This allows the use isA(...),
    41     isDirectlyA(...), isChildOf(...) and isParentOf(...).
     41    isExactlyA(...), isChildOf(...) and isParentOf(...).
    4242
    4343    To create the class-hierarchy, the Identifier has some intern functions and variables.
     
    8282
    8383        Every object has a pointer to the Identifier of its class. This allows the use isA(...),
    84         isDirectlyA(...), isChildOf(...) and isParentOf(...).
     84        isExactlyA(...), isChildOf(...) and isParentOf(...).
    8585
    8686        You can't directly create an Identifier, it's just the base-class for ClassIdentifier.
     
    102102            BaseObject* fabricate();
    103103            bool isA(const Identifier* identifier) const;
    104             bool isDirectlyA(const Identifier* identifier) const;
     104            bool isExactlyA(const Identifier* identifier) const;
    105105            bool isChildOf(const Identifier* identifier) const;
     106            bool isDirectChildOf(const Identifier* identifier) const;
    106107            bool isParentOf(const Identifier* identifier) const;
     108            bool isDirectParentOf(const Identifier* identifier) const;
    107109
    108110            /** @brief Removes all objects of the corresponding class. */
     
    114116            /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */
    115117            inline const std::list<const Identifier*>& getParents() const { return this->parents_; }
    116 
    117118            /** @brief Returns the begin-iterator of the parents-list. @return The begin-iterator */
    118119            inline std::list<const Identifier*>::const_iterator getParentsBegin() const { return this->parents_.begin(); }
    119 
    120120            /** @brief Returns the end-iterator of the parents-list. @return The end-iterator */
    121121            inline std::list<const Identifier*>::const_iterator getParentsEnd() const { return this->parents_.end(); }
    122122
     123            /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */
     124            inline const std::list<const Identifier*>& getChildren() const { return (*this->children_); }
    123125            /** @brief Returns the begin-iterator of the children-list. @return The begin-iterator */
    124126            inline std::list<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_->begin(); }
    125 
    126127            /** @brief Returns the end-iterator of the children-list. @return The end-iterator */
    127128            inline std::list<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_->end(); }
     129
     130            /** @brief Returns the direct parents of the class the Identifier belongs to. @return The list of all direct parents */
     131            inline const std::list<const Identifier*>& getDirectParents() const { return this->directParents_; }
     132            /** @brief Returns the begin-iterator of the direct-parents-list. @return The begin-iterator */
     133            inline std::list<const Identifier*>::const_iterator getDirectParentsBegin() const { return this->directParents_.begin(); }
     134            /** @brief Returns the end-iterator of the direct-parents-list. @return The end-iterator */
     135            inline std::list<const Identifier*>::const_iterator getDirectParentsEnd() const { return this->directParents_.end(); }
     136
     137            /** @brief Returns the direct children the class the Identifier belongs to. @return The list of all direct children */
     138            inline const std::list<const Identifier*>& getDirectChildren() const { return (*this->directChildren_); }
     139            /** @brief Returns the begin-iterator of the direct-children-list. @return The begin-iterator */
     140            inline std::list<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_->begin(); }
     141            /** @brief Returns the end-iterator of the direct-children-list. @return The end-iterator */
     142            inline std::list<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_->end(); }
    128143
    129144            /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */
     
    143158            inline void setConfigValueContainer(const std::string& varname, ConfigValueContainer* container)
    144159                { this->configValues_[varname] = container; }
     160
     161            static bool identifierIsInList(const Identifier* identifier, const std::list<const Identifier*>& list);
    145162
    146163        private:
     
    150167            void initialize(std::list<const Identifier*>* parents);
    151168
    152             /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */
    153             inline std::list<const Identifier*>& getParents() { return this->parents_; }
    154 
    155169            /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */
    156             inline std::list<const Identifier*>& getChildren() const { return (*this->children_); }
     170            inline std::list<const Identifier*>& getChildrenIntern() const { return (*this->children_); }
     171            /** @brief Returns the direct children of the class the Identifier belongs to. @return The list of all direct children */
     172            inline std::list<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); }
    157173
    158174            /**
     
    174190            }
    175191
    176             static bool identifierIsInList(const Identifier* identifier, const std::list<const Identifier*>& list);
    177 
    178             std::list<const Identifier*> parents_;                      //!< The Parents of the class the Identifier belongs to
    179             std::list<const Identifier*>* children_;                    //!< The Children of the class the Identifier belongs to
     192            std::list<const Identifier*> parents_;                      //!< The parents of the class the Identifier belongs to
     193            std::list<const Identifier*>* children_;                    //!< The children of the class the Identifier belongs to
     194
     195            std::list<const Identifier*> directParents_;                //!< The direct parents of the class the Identifier belongs to
     196            std::list<const Identifier*>* directChildren_;              //!< The direct children of the class the Identifier belongs to
    180197
    181198            std::string name_;                                          //!< The name of the class the Identifier belongs to
     
    188205    };
    189206
     207    std::ostream& operator<<(std::ostream& out, const std::list<const Identifier*>& list);
     208
    190209
    191210    // ###############################
     
    215234            void removeObjects() const;
    216235            void setName(const std::string& name);
     236            inline const ObjectList<T>* getObjects() const { return this->objects_; }
    217237
    218238        private:
     
    231251    ClassIdentifier<T>::ClassIdentifier()
    232252    {
    233         this->objects_ = ObjectList<T>::getList();
     253//        this->objects_ = ObjectList<T>::getList();
     254        this->objects_ = new ObjectList<T>();
    234255        this->bSetName_ = false;
    235256    }
     
    294315    void ClassIdentifier<T>::removeObjects() const
    295316    {
    296         for (Iterator<T> it = ObjectList<T>::start(); it;)
     317        for (Iterator<T> it = this->objects_->start(); it;)
    297318            delete *(it++);
    298319    }
     320
    299321
    300322    // ###############################
     
    409431
    410432            /** @brief Returns true, if the assigned identifier is exactly of the given type. @param identifier The identifier to compare with */
    411             inline bool isDirectlyA(const Identifier* identifier) const
    412                 { return this->identifier_->isDirectlyA(identifier); }
     433            inline bool isExactlyA(const Identifier* identifier) const
     434                { return this->identifier_->isExactlyA(identifier); }
    413435
    414436            /** @brief Returns true, if the assigned identifier is a child of the given identifier. @param identifier The identifier to compare with */
     
    416438                { return this->identifier_->isChildOf(identifier); }
    417439
     440            /** @brief Returns true, if the assigned identifier is a direct child of the given identifier. @param identifier The identifier to compare with */
     441            inline bool isDirectChildOf(const Identifier* identifier) const
     442                { return this->identifier_->isDirectChildOf(identifier); }
     443
    418444            /** @brief Returns true, if the assigned identifier is a parent of the given identifier. @param identifier The identifier to compare with */
    419445            inline bool isParentOf(const Identifier* identifier) const
    420446                { return this->identifier_->isParentOf(identifier); }
     447
     448            /** @brief Returns true, if the assigned identifier is a direct parent of the given identifier. @param identifier The identifier to compare with */
     449            inline bool isDirectParentOf(const Identifier* identifier) const
     450                { return this->identifier_->isDirectParentOf(identifier); }
    421451
    422452        private:
Note: See TracChangeset for help on using the changeset viewer.