Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 5, 2008, 2:18:14 PM (16 years ago)
Author:
rgrieder
Message:
  • applied patch to remove ClassManager (wouldn't wanna maintain it anymore ;))
  • sorted core CMLs a little bit
  • updated OrxonoxStableHeaders.h
File:
1 edited

Legend:

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

    r1505 r1543  
    253253            }
    254254
     255            static Identifier* getIdentifier(std::string &name, Identifier *proposal);
     256
    255257            std::set<const Identifier*> parents_;                          //!< The parents of the class the Identifier belongs to
    256258            std::set<const Identifier*>* children_;                        //!< The children of the class the Identifier belongs to
     
    288290
    289291        To be really sure that not more than exactly one object exists (even with libraries),
    290         ClassIdentifiers are only created by IdentifierDistributor.
    291 
    292         You can access the ClassIdentifiers created by IdentifierDistributor through the
    293         ClassManager singletons.
     292        ClassIdentifiers are stored in the Identifier Singleton.
    294293    */
    295294    template <class T>
    296295    class ClassIdentifier : public Identifier
    297296    {
    298         template <class TT>
    299         friend class ClassManager;
    300 
    301297        public:
    302298            ClassIdentifier<T>* registerClass(std::set<const Identifier*>* parents, const std::string& name, bool bRootClass);
     
    316312            void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container);
    317313
     314            static ClassIdentifier<T> *getIdentifier();
     315
    318316        private:
    319317            ClassIdentifier();
     
    325323            std::map<std::string, XMLPortClassParamContainer<T>*> xmlportParamContainers_;              //!< All loadable parameters
    326324            std::map<std::string, XMLPortClassObjectContainer<T, class O>*> xmlportObjectContainers_;   //!< All attachable objects
     325
     326            static ClassIdentifier<T> *classIdentifier_s;
    327327    };
     328
     329    template <class T>
     330    ClassIdentifier<T> *ClassIdentifier<T>::classIdentifier_s = 0;
    328331
    329332    /**
     
    365368
    366369    /**
     370        @brief Creates the only instance of this class for the template class T and retrieves a unique Identifier for the given name.
     371        @return The unique Identifier
     372    */
     373    template <class T>
     374    ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
     375    {
     376        // check if the static field has already been filled
     377        if (ClassIdentifier<T>::classIdentifier_s == 0)
     378        {
     379            // Get the name of the class
     380            std::string name = typeid(T).name();
     381
     382            // create a new identifier anyway. Will be deleted in Identifier::getIdentifier if not used.
     383            ClassIdentifier<T> *proposal = new ClassIdentifier<T>();
     384
     385            // Get the entry from the map
     386            ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)Identifier::getIdentifier(name, proposal);
     387        }
     388
     389        // Finally return the unique ClassIdentifier
     390        return ClassIdentifier<T>::classIdentifier_s;
     391    }
     392
     393    /**
    367394        @brief Sets the name of the class.
    368395        @param name The name
     
    472499            SubclassIdentifier()
    473500            {
    474                 this->identifier_ = ClassManager<T>::getIdentifier();
     501                this->identifier_ = ClassIdentifier<T>::getIdentifier();
    475502            }
    476503
     
    491518            SubclassIdentifier<T>& operator=(Identifier* identifier)
    492519            {
    493                 if (!identifier->isA(ClassManager<T>::getIdentifier()))
     520                if (!identifier->isA(ClassIdentifier<T>::getIdentifier()))
    494521                {
    495522                    COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
    496                     COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassManager<T>::getIdentifier()->getName() << "!" << std::endl;
    497                     COUT(1) << "Error: SubclassIdentifier<" << ClassManager<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;
     523                    COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
     524                    COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;
    498525                    COUT(1) << "Aborting..." << std::endl;
    499526                    abort();
     
    541568                    {
    542569                        COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
    543                         COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassManager<T>::getIdentifier()->getName() << "!" << std::endl;
     570                        COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
    544571                        COUT(1) << "Error: Couldn't fabricate a new Object." << std::endl;
    545572                        COUT(1) << "Aborting..." << std::endl;
Note: See TracChangeset for help on using the changeset viewer.