Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 13, 2008, 6:39:53 PM (16 years ago)
Author:
landauf
Message:
  • Changed the ClassManager/IdentifierDistributor: ClassIdentifiers are now saved with the name returned by typeid(class).name() because this is a simple way getting the name without creating an object (which might be impossible because of non-public constructors or abstract functions).
  • Changed some debug outputs
File:
1 edited

Legend:

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

    r810 r811  
    147147            {
    148148                hierarchyCreatingCounter_s++;
    149                 COUT(4) << "*** Increased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
     149                COUT(4) << "*** Identifier: Increased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
    150150            }
    151151
     
    156156            {
    157157                hierarchyCreatingCounter_s--;
    158                 COUT(4) << "*** Decreased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
     158                COUT(4) << "*** Identifier: Decreased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
    159159            }
    160160
     
    228228    ClassIdentifier<T>* ClassIdentifier<T>::registerClass(const IdentifierList* parents, const std::string& name, bool bRootClass)
    229229    {
    230         COUT(4) << "*** Register Class in " << name << "-Singleton." << std::endl;
     230        COUT(4) << "*** ClassIdentifier: Register Class in " << name << "-Singleton." << std::endl;
    231231
    232232        // Check if at least one object of the given type was created
     
    236236            this->setName(name);
    237237
    238             COUT(4) << "*** Register Class in " << name << "-Singleton -> Initialize Singleton." << std::endl;
     238            COUT(4) << "*** ClassIdentifier: Register Class in " << name << "-Singleton -> Initialize Singleton." << std::endl;
    239239            if (bRootClass)
    240240                this->initialize(NULL); // 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.
     
    267267    void ClassIdentifier<T>::addObject(T* object)
    268268    {
    269         COUT(4) << "*** Added object to " << this->getName() << "-list." << std::endl;
     269        COUT(4) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
    270270        object->getMetaList().add(this->objects_, this->objects_->add(object));
    271271    }
     
    299299            SubclassIdentifier()
    300300            {
    301                 std::string name = ClassManager<T>::getName();
    302 
    303                 if (name != "unknown")
    304                     this->subclassIdentifier_ = ClassManager<T>::getIdentifier(name);
    305                 else
    306                     this->subclassIdentifier_ = 0;
    307 
    308                 this->identifier_ = this->subclassIdentifier_;
     301                this->identifier_ = ClassManager<T>::getIdentifier();
    309302            }
    310303
     
    315308            SubclassIdentifier(Identifier* identifier)
    316309            {
    317                 std::string name = ClassManager<T>::getName();
    318 
    319                 if (name != "unknown")
    320                     this->subclassIdentifier_ = ClassManager<T>::getIdentifier(name);
    321                 else
    322                     this->subclassIdentifier_ = 0;
    323 
    324310                this->identifier_ = identifier;
    325311            }
     
    332318            SubclassIdentifier<T>& operator=(Identifier* identifier)
    333319            {
    334                 if (!identifier->isA(this->subclassIdentifier_))
     320                if (!identifier->isA(ClassManager<T>::getIdentifier()))
    335321                {
    336                     COUT(1) << "Error: Class " << identifier->getName() << " is not a " << this->subclassIdentifier_->getName() << "!" << std::endl;
    337                     COUT(1) << "Error: SubclassIdentifier<" << this->subclassIdentifier_->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;
     322                    COUT(1) << "An error occurred in SubclassIdentifier:" << std::endl;
     323                    COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassManager<T>::getIdentifier()->getName() << "!" << std::endl;
     324                    COUT(1) << "Error: SubclassIdentifier<" << ClassManager<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;
    338325                    COUT(1) << "Aborting..." << std::endl;
    339326                    abort();
     
    380367                    if (this->identifier_)
    381368                    {
    382                         COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << this->subclassIdentifier_->getName() << "!" << std::endl;
     369                        COUT(1) << "An error occurred in SubclassIdentifier:" << std::endl;
     370                        COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassManager<T>::getIdentifier()->getName() << "!" << std::endl;
    383371                        COUT(1) << "Error: Couldn't fabricate a new Object." << std::endl;
    384372                        COUT(1) << "Aborting..." << std::endl;
     
    386374                    else
    387375                    {
     376                        COUT(1) << "An error occurred in SubclassIdentifier:" << std::endl;
    388377                        COUT(1) << "Error: Couldn't fabricate a new Object - Identifier is undefined." << std::endl;
    389378                        COUT(1) << "Aborting..." << std::endl;
     
    416405        private:
    417406            Identifier* identifier_;            //!< The assigned identifier
    418             Identifier* subclassIdentifier_;    //!< The identifier of the subclass
    419407    };
    420408}
Note: See TracChangeset for help on using the changeset viewer.