Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 29, 2008, 4:15:03 AM (16 years ago)
Author:
landauf
Message:
  • some small adjustments in identifier and co.
  • renamed GetIdentifier to ClassByName and ClassByID
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/core/Identifier.h

    r1755 r1856  
    190190            inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapEnd() const { return this->consoleCommands_LC_.end(); }
    191191
     192            /** @brief Returns the map that stores all XMLPort params. @return The const_iterator */
     193            inline const std::map<std::string, XMLPortParamContainer*>& getXMLPortParamMap() const { return this->xmlportParamContainers_; }
     194            /** @brief Returns a const_iterator to the beginning of the map that stores all XMLPort params. @return The const_iterator */
     195            inline std::map<std::string, XMLPortParamContainer*>::const_iterator getXMLPortParamMapBegin() const { return this->xmlportParamContainers_.begin(); }
     196            /** @brief Returns a const_iterator to the end of the map that stores all XMLPort params. @return The const_iterator */
     197            inline std::map<std::string, XMLPortParamContainer*>::const_iterator getXMLPortParamMapEnd() const { return this->xmlportParamContainers_.end(); }
     198
     199            /** @brief Returns the map that stores all XMLPort objects. @return The const_iterator */
     200            inline const std::map<std::string, XMLPortObjectContainer*>& getXMLPortObjectMap() const { return this->xmlportObjectContainers_; }
     201            /** @brief Returns a const_iterator to the beginning of the map that stores all XMLPort objects. @return The const_iterator */
     202            inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortObjectMapBegin() const { return this->xmlportObjectContainers_.begin(); }
     203            /** @brief Returns a const_iterator to the end of the map that stores all XMLPort objects. @return The const_iterator */
     204            inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortObjectMapEnd() const { return this->xmlportObjectContainers_.end(); }
    192205
    193206            /** @brief Returns true if this class has at least one config value. @return True if this class has at least one config value */
     
    219232            ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const;
    220233
     234            void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);
     235
    221236        protected:
    222237            Identifier();
     
    224239            virtual ~Identifier();
    225240
    226             void initialize(std::set<const Identifier*>* parents);
    227241            static Identifier* getIdentifierSingleton(const std::string& name, Identifier* proposal);
    228 
    229242            virtual void createSuperFunctionCaller() const = 0;
    230243
     
    239252            inline std::set<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); }
    240253
    241             bool bCreatedOneObject_;                                       //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
    242254            ObjectListBase* objects_;                                      //!< The list of all objects of this class
    243255
     
    261273            }
    262274
     275            void initialize(std::set<const Identifier*>* parents);
     276
    263277            static void destroyAllIdentifiers();
    264278
     
    269283            std::set<const Identifier*>* directChildren_;                  //!< The direct children of the class the Identifier belongs to
    270284
     285            bool bCreatedOneObject_;                                       //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
    271286            bool bSetName_;                                                //!< True if the name is set
    272287            std::string name_;                                             //!< The name of the class the Identifier belongs to
     
    311326            static ClassIdentifier<T> *getIdentifier();
    312327            static ClassIdentifier<T> *getIdentifier(const std::string& name);
    313             void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);
     328            void addObject(T* object);
    314329            static bool isFirstCall();
    315             void addObject(T* object);
    316330
    317331            void updateConfigValues(bool updateChildren = true) const;
     
    328342            }
    329343
    330             static ClassIdentifier<T> *classIdentifier_s;
     344            static ClassIdentifier<T>* classIdentifier_s;
    331345    };
    332346
    333347    template <class T>
    334     ClassIdentifier<T> *ClassIdentifier<T>::classIdentifier_s = 0;
    335 
    336     /**
    337         @brief Registers a class, which means that the name and the parents get stored.
    338         @param parents A list, containing the Identifiers of all parents of the class
    339         @param bRootClass True if the class is either an Interface or the BaseObject itself
    340     */
    341     template <class T>
    342     void ClassIdentifier<T>::initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass)
    343     {
    344         // Check if at least one object of the given type was created
    345         if (!this->bCreatedOneObject_ && Identifier::isCreatingHierarchy())
    346         {
    347             // If no: We have to store the informations and initialize the Identifier
    348             COUT(4) << "*** ClassIdentifier: Register Class in " << this->getName() << "-Singleton -> Initialize Singleton." << std::endl;
    349             if (bRootClass)
    350                 this->initialize(0); // If a class is derived from two interfaces, the second interface might think it's derived from the first because of the order of constructor-calls. Thats why we set parents to zero in that case.
    351             else
    352                 this->initialize(parents);
    353         }
    354     }
     348    ClassIdentifier<T>* ClassIdentifier<T>::classIdentifier_s;
    355349
    356350    /**
     
    476470            SubclassIdentifier(Identifier* identifier)
    477471            {
    478                 this->identifier_ = identifier;
     472                this->operator=(identifier);
    479473            }
    480474
     
    500494            /**
    501495                @brief Overloading of the * operator: returns the assigned identifier.
    502                 @return The assigned identifier
    503             */
    504             Identifier* operator*()
     496            */
     497            inline Identifier* operator*()
    505498            {
    506499                return this->identifier_;
     
    509502            /**
    510503                @brief Overloading of the -> operator: returns the assigned identifier.
    511                 @return The assigned identifier
    512             */
    513             Identifier* operator->() const
     504            */
     505            inline Identifier* operator->() const
     506            {
     507                return this->identifier_;
     508            }
     509
     510            /**
     511                @brief Returns the assigned identifier. This allows you to assign a SubclassIdentifier to a normal Identifier*.
     512            */
     513            inline operator Identifier*() const
    514514            {
    515515                return this->identifier_;
     
    527527                if (newObject)
    528528                {
    529                     // Do a dynamic_cast, because an object of type T is much better than of type BaseObject
    530                     return (T*)(newObject);
     529                    return dynamic_cast<T*>(newObject);
    531530                }
    532531                else
     
    552551
    553552            /** @brief Returns the assigned identifier. @return The identifier */
    554             inline const Identifier* getIdentifier() const
     553            inline Identifier* getIdentifier() const
    555554                { return this->identifier_; }
    556555
    557             /** @brief Returns true, if the assigned identifier is at least of the given type. @param identifier The identifier to compare with */
    558             inline bool isA(const Identifier* identifier) const
    559                 { return this->identifier_->isA(identifier); }
    560 
    561             /** @brief Returns true, if the assigned identifier is exactly of the given type. @param identifier The identifier to compare with */
    562             inline bool isExactlyA(const Identifier* identifier) const
    563                 { return this->identifier_->isExactlyA(identifier); }
    564 
    565             /** @brief Returns true, if the assigned identifier is a child of the given identifier. @param identifier The identifier to compare with */
    566             inline bool isChildOf(const Identifier* identifier) const
    567                 { return this->identifier_->isChildOf(identifier); }
    568 
    569             /** @brief Returns true, if the assigned identifier is a direct child of the given identifier. @param identifier The identifier to compare with */
    570             inline bool isDirectChildOf(const Identifier* identifier) const
    571                 { return this->identifier_->isDirectChildOf(identifier); }
    572 
    573             /** @brief Returns true, if the assigned identifier is a parent of the given identifier. @param identifier The identifier to compare with */
    574             inline bool isParentOf(const Identifier* identifier) const
    575                 { return this->identifier_->isParentOf(identifier); }
    576 
    577             /** @brief Returns true, if the assigned identifier is a direct parent of the given identifier. @param identifier The identifier to compare with */
    578             inline bool isDirectParentOf(const Identifier* identifier) const
    579                 { return this->identifier_->isDirectParentOf(identifier); }
     556//            /** @brief Returns true, if the assigned identifier is at least of the given type. @param identifier The identifier to compare with */
     557//            inline bool isA(const Identifier* identifier) const
     558//                { return this->identifier_->isA(identifier); }
     559//
     560//            /** @brief Returns true, if the assigned identifier is exactly of the given type. @param identifier The identifier to compare with */
     561//            inline bool isExactlyA(const Identifier* identifier) const
     562//                { return this->identifier_->isExactlyA(identifier); }
     563//
     564//            /** @brief Returns true, if the assigned identifier is a child of the given identifier. @param identifier The identifier to compare with */
     565//            inline bool isChildOf(const Identifier* identifier) const
     566//                { return this->identifier_->isChildOf(identifier); }
     567//
     568//            /** @brief Returns true, if the assigned identifier is a direct child of the given identifier. @param identifier The identifier to compare with */
     569//            inline bool isDirectChildOf(const Identifier* identifier) const
     570//                { return this->identifier_->isDirectChildOf(identifier); }
     571//
     572//            /** @brief Returns true, if the assigned identifier is a parent of the given identifier. @param identifier The identifier to compare with */
     573//            inline bool isParentOf(const Identifier* identifier) const
     574//                { return this->identifier_->isParentOf(identifier); }
     575//
     576//            /** @brief Returns true, if the assigned identifier is a direct parent of the given identifier. @param identifier The identifier to compare with */
     577//            inline bool isDirectParentOf(const Identifier* identifier) const
     578//                { return this->identifier_->isDirectParentOf(identifier); }
    580579
    581580        private:
Note: See TracChangeset for help on using the changeset viewer.