Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 24, 2009, 8:58:27 PM (15 years ago)
Author:
landauf
Message:

some cleanup

Location:
code/branches/core5/src/libraries/core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/libraries/core/ClassFactory.h

    r5779 r5783  
    6565    {
    6666        public:
    67             ClassFactory(const std::string& name, bool bLoadable = true);
    68             BaseObject* fabricate(BaseObject* creator);
     67            /**
     68                @brief Constructor: Adds the ClassFactory to the Identifier of the same type.
     69                @param name The name of the class
     70                @param bLoadable True if the class can be loaded through XML
     71            */
     72            ClassFactory(const std::string& name, bool bLoadable = true)
     73            {
     74                COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;
     75                ClassIdentifier<T>::getIdentifier(name)->addFactory(this);
     76                ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);
     77            }
     78
     79            /**
     80                @brief Creates and returns a new object of class T.
     81                @return The new object
     82            */
     83            inline BaseObject* fabricate(BaseObject* creator)
     84            {
     85                return static_cast<BaseObject*>(new T(creator));
     86            }
    6987    };
    70 
    71     /**
    72         @brief Adds the ClassFactory to the Identifier of the same type.
    73         @param name The name of the class
    74         @param bLoadable True if the class can be loaded through XML
    75     */
    76     template <class T>
    77     ClassFactory<T>::ClassFactory(const std::string& name, bool bLoadable)
    78     {
    79         COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;
    80         ClassIdentifier<T>::getIdentifier(name)->addFactory(this);
    81         ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);
    82     }
    83 
    84     /**
    85         @brief Creates and returns a new object of class T.
    86         @return The new object
    87     */
    88     template <class T>
    89     inline BaseObject* ClassFactory<T>::fabricate(BaseObject* creator)
    90     {
    91         return static_cast<BaseObject*>(new T(creator));
    92     }
    9388}
    9489
  • code/branches/core5/src/libraries/core/Identifier.cc

    r5780 r5783  
    6666        this->bHasConsoleCommands_ = false;
    6767
    68         this->children_ = new std::set<const Identifier*>();
    69         this->directChildren_ = new std::set<const Identifier*>();
    70 
    7168        // Default network ID is the class ID
    7269        this->networkID_ = this->classID_;
     
    7875    Identifier::~Identifier()
    7976    {
    80         delete this->children_;
    81         delete this->directChildren_;
    8277        delete this->objects_;
    8378
     
    165160            {
    166161                // Tell the parent we're one of it's children
    167                 (*it)->getChildrenIntern().insert((*it)->getChildrenIntern().end(), this);
     162                (*it)->children_.insert((*it)->children_.end(), this);
    168163
    169164                // Erase all parents of our parent from our direct-parent-list
     
    187182            {
    188183                // Tell the parent we're one of it's direct children
    189                 (*it)->getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this);
     184                (*it)->directChildren_.insert((*it)->directChildren_.end(), this);
    190185
    191186                // Create the super-function dependencies
     
    201196    {
    202197        COUT(3) << "*** Identifier: Create class-hierarchy" << std::endl;
    203         std::map<std::string, Identifier*>::const_iterator it;
    204         it = Identifier::getStringIdentifierMap().begin();
    205         Identifier::getStringIdentifierMap().begin()->second->startCreatingHierarchy();
    206         for (it = Identifier::getStringIdentifierMap().begin(); it != Identifier::getStringIdentifierMap().end(); ++it)
     198        Identifier::startCreatingHierarchy();
     199        for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMap().begin(); it != Identifier::getStringIdentifierMap().end(); ++it)
    207200        {
    208201            // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
     
    213206            }
    214207        }
    215         Identifier::getStringIdentifierMap().begin()->second->stopCreatingHierarchy();
     208        Identifier::stopCreatingHierarchy();
    216209        COUT(3) << "*** Identifier: Finished class-hierarchy creation" << std::endl;
    217210    }
     
    315308    bool Identifier::isParentOf(const Identifier* identifier) const
    316309    {
    317         return (this->children_->find(identifier) != this->children_->end());
     310        return (this->children_.find(identifier) != this->children_.end());
    318311    }
    319312
     
    324317    bool Identifier::isDirectParentOf(const Identifier* identifier) const
    325318    {
    326         return (this->directChildren_->find(identifier) != this->directChildren_->end());
     319        return (this->directChildren_.find(identifier) != this->directChildren_.end());
    327320    }
    328321
  • code/branches/core5/src/libraries/core/Identifier.h

    r5779 r5783  
    138138
    139139            /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */
    140             inline const std::set<const Identifier*>& getChildren() const { return (*this->children_); }
     140            inline const std::set<const Identifier*>& getChildren() const { return this->children_; }
    141141            /** @brief Returns the begin-iterator of the children-list. @return The begin-iterator */
    142             inline std::set<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_->begin(); }
     142            inline std::set<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_.begin(); }
    143143            /** @brief Returns the end-iterator of the children-list. @return The end-iterator */
    144             inline std::set<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_->end(); }
     144            inline std::set<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_.end(); }
    145145
    146146            /** @brief Returns the direct parents of the class the Identifier belongs to. @return The list of all direct parents */
     
    152152
    153153            /** @brief Returns the direct children the class the Identifier belongs to. @return The list of all direct children */
    154             inline const std::set<const Identifier*>& getDirectChildren() const { return (*this->directChildren_); }
     154            inline const std::set<const Identifier*>& getDirectChildren() const { return this->directChildren_; }
    155155            /** @brief Returns the begin-iterator of the direct-children-list. @return The begin-iterator */
    156             inline std::set<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_->begin(); }
     156            inline std::set<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_.begin(); }
    157157            /** @brief Returns the end-iterator of the direct-children-list. @return The end-iterator */
    158             inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_->end(); }
     158            inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_.end(); }
    159159
    160160
     
    296296
    297297            /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */
    298             inline std::set<const Identifier*>& getChildrenIntern() const { return (*this->children_); }
     298            inline std::set<const Identifier*>& getChildrenIntern() const { return this->children_; }
    299299            /** @brief Returns the direct children of the class the Identifier belongs to. @return The list of all direct children */
    300             inline std::set<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); }
     300            inline std::set<const Identifier*>& getDirectChildrenIntern() const { return this->directChildren_; }
    301301
    302302            ObjectListBase* objects_;                                      //!< The list of all objects of this class
    303303
    304304        private:
    305             /**
    306                 @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents.
    307             */
    308             inline static void startCreatingHierarchy()
    309             {
    310                 hierarchyCreatingCounter_s++;
    311                 COUT(4) << "*** Identifier: Increased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
    312             }
    313 
    314             /**
    315                 @brief Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents.
    316             */
    317             inline static void stopCreatingHierarchy()
    318             {
    319                 hierarchyCreatingCounter_s--;
    320                 COUT(4) << "*** Identifier: Decreased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
    321             }
     305            /** @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents. */
     306            inline static void startCreatingHierarchy() { hierarchyCreatingCounter_s++; }
     307            /** @brief Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents. */
     308            inline static void stopCreatingHierarchy()  { hierarchyCreatingCounter_s--; }
    322309
    323310            static std::map<std::string, Identifier*>& getTypeIDIdentifierMap();
     
    326313
    327314            std::set<const Identifier*> parents_;                          //!< The parents of the class the Identifier belongs to
    328             std::set<const Identifier*>* children_;                        //!< The children of the class the Identifier belongs to
     315            mutable std::set<const Identifier*> children_;                 //!< The children of the class the Identifier belongs to
    329316
    330317            std::set<const Identifier*> directParents_;                    //!< The direct parents of the class the Identifier belongs to
    331             std::set<const Identifier*>* directChildren_;                  //!< The direct children of the class the Identifier belongs to
     318            mutable std::set<const Identifier*> directChildren_;           //!< The direct children of the class the Identifier belongs to
    332319
    333320            bool bCreatedOneObject_;                                       //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
Note: See TracChangeset for help on using the changeset viewer.