Changeset 1940 for code/branches/objecthierarchy/src/core
- Timestamp:
- Oct 18, 2008, 10:58:46 PM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/core
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/core/BaseObject.h
r1841 r1940 93 93 inline const std::string& getLoaderIndentation() const { return this->loaderIndentation_; } 94 94 95 pr ivate:95 protected: 96 96 std::string name_; //!< The name of the object 97 bool bInitialized_; //!< True if the object was initialized (passed the object registration)98 97 bool bActive_; //!< True = the object is active 99 98 bool bVisible_; //!< True = the object is visible 99 100 private: 101 bool bInitialized_; //!< True if the object was initialized (passed the object registration) 100 102 const Level* level_; //!< The level that loaded this object 101 103 std::string loaderIndentation_; //!< Indentation of the debug output in the Loader -
code/branches/objecthierarchy/src/core/ClassFactory.h
r1747 r1940 55 55 { 56 56 public: 57 static bool create(const std::string& name );57 static bool create(const std::string& name, bool bLoadable = true); 58 58 BaseObject* fabricate(); 59 59 … … 68 68 /** 69 69 @brief Adds the ClassFactory to the Identifier of the same type and the Identifier to the Factory. 70 @param name The name of the class 71 @param bLoadable True if the class can be loaded through XML 70 72 @return Always true (this is needed because the compiler only allows assignments before main()) 71 73 */ 72 74 template <class T> 73 bool ClassFactory<T>::create(const std::string& name )75 bool ClassFactory<T>::create(const std::string& name, bool bLoadable) 74 76 { 75 77 COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl; 76 78 ClassIdentifier<T>::getIdentifier(name)->addFactory(new ClassFactory<T>); 79 ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable); 77 80 Factory::add(name, ClassIdentifier<T>::getIdentifier()); 78 81 -
code/branches/objecthierarchy/src/core/CoreIncludes.h
r1856 r1940 98 98 */ 99 99 #define CreateFactory(ClassName) \ 100 bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName) 100 bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, true) 101 102 /** 103 @brief Creates the entry in the Factory for classes which should not be loaded through XML. 104 @param ClassName The name of the class 105 */ 106 #define CreateUnloadableFactory(ClassName) \ 107 bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName, false) 101 108 102 109 /** … … 111 118 @param String The name of the class 112 119 */ 113 #define ClassBy Name(String) \120 #define ClassByString(String) \ 114 121 orxonox::Factory::getIdentifier(String) 115 122 -
code/branches/objecthierarchy/src/core/Factory.cc
r1856 r1940 46 46 Identifier* Factory::getIdentifier(const std::string& name) 47 47 { 48 return getFactoryPointer()->identifierStringMap_[name]; 48 std::map<std::string, Identifier*>::const_iterator it = getFactoryPointer()->identifierStringMap_.find(name); 49 if (it != getFactoryPointer()->identifierStringMap_.end()) 50 return it->second; 51 else 52 return 0; 49 53 } 50 54 … … 56 60 Identifier* Factory::getIdentifier(const unsigned int id) 57 61 { 58 return getFactoryPointer()->identifierNetworkIDMap_[id]; 62 std::map<unsigned int, Identifier*>::const_iterator it = getFactoryPointer()->identifierNetworkIDMap_.find(id); 63 if (it != getFactoryPointer()->identifierNetworkIDMap_.end()) 64 return it->second; 65 else 66 return 0; 59 67 } 60 68 … … 68 76 getFactoryPointer()->identifierStringMap_[name] = identifier; 69 77 getFactoryPointer()->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier; 78 std::cout << identifier->getName() << ": " << identifier->getNetworkID() << std::endl; 70 79 } 71 80 … … 80 89 getFactoryPointer()->identifierNetworkIDMap_.erase(oldID); 81 90 getFactoryPointer()->identifierNetworkIDMap_[newID] = identifier; 91 std::cout << identifier->getName() << ": " << oldID << " -> " << newID << std::endl; 82 92 } 83 93 -
code/branches/objecthierarchy/src/core/Identifier.cc
r1856 r1940 59 59 this->bSetName_ = false; 60 60 this->factory_ = 0; 61 this->bLoadable_ = true; 61 62 62 63 this->bHasConfigValues_ = false; -
code/branches/objecthierarchy/src/core/Identifier.h
r1856 r1940 107 107 bool isDirectParentOf(const Identifier* identifier) const; 108 108 109 /** @brief Returns true if the class can be loaded through XML. */ 110 inline bool isLoadable() const { return this->bLoadable_; } 111 /** @brief Set the class to be loadable through XML or not. */ 112 inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; } 113 109 114 /** @brief Returns the list of all existing objects of this class. @return The list */ 110 115 inline ObjectListBase* getObjects() const … … 285 290 bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents) 286 291 bool bSetName_; //!< True if the name is set 292 bool bLoadable_; //!< False = it's not permitted to load the object through XML 287 293 std::string name_; //!< The name of the class the Identifier belongs to 288 294 BaseFactory* factory_; //!< The Factory, able to create new objects of the given class (if available) -
code/branches/objecthierarchy/src/core/XMLPort.h
r1889 r1940 468 468 for (ticpp::Iterator<ticpp::Element> child = xmlsubelement->FirstChildElement(false); child != child.end(); child++) 469 469 { 470 Identifier* identifier = ClassBy Name(child->Value());470 Identifier* identifier = ClassByString(child->Value()); 471 471 if (identifier) 472 472 { 473 473 if (identifier->isA(Class(O))) 474 474 { 475 if ( this->identifierIsIncludedInLoaderMask(identifier))475 if (identifier->isLoadable()) 476 476 { 477 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl; 478 479 BaseObject* newObject = identifier->fabricate(); 480 newObject->setLoaderIndentation(((BaseObject*)object)->getLoaderIndentation() + " "); 481 newObject->setLevel(((BaseObject*)object)->getLevel()); 482 newObject->setNamespace(((BaseObject*)object)->getNamespace()); 483 484 if (this->bLoadBefore_) 477 if (this->identifierIsIncludedInLoaderMask(identifier)) 485 478 { 486 newObject->XMLPort(*child, XMLPort::LoadObject); 487 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl; 479 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl; 480 481 BaseObject* newObject = identifier->fabricate(); 482 newObject->setLoaderIndentation(((BaseObject*)object)->getLoaderIndentation() + " "); 483 newObject->setLevel(((BaseObject*)object)->getLevel()); 484 newObject->setNamespace(((BaseObject*)object)->getNamespace()); 485 486 if (this->bLoadBefore_) 487 { 488 newObject->XMLPort(*child, XMLPort::LoadObject); 489 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl; 490 } 491 else 492 { 493 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl; 494 } 495 496 COUT(5) << ((BaseObject*)object)->getLoaderIndentation(); 497 (*this->loadexecutor_)(object, newObject); 498 499 if (!this->bLoadBefore_) 500 newObject->XMLPort(*child, XMLPort::LoadObject); 501 502 COUT(5) << ((BaseObject*)object)->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl; 488 503 } 489 else 490 { 491 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl; 492 } 493 494 COUT(5) << ((BaseObject*)object)->getLoaderIndentation(); 495 (*this->loadexecutor_)(object, newObject); 496 497 if (!this->bLoadBefore_) 498 newObject->XMLPort(*child, XMLPort::LoadObject); 499 500 COUT(5) << ((BaseObject*)object)->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl; 504 } 505 else 506 { 507 COUT(2) << ((BaseObject*)object)->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not loadable." << std::endl; 501 508 } 502 509 }
Note: See TracChangeset
for help on using the changeset viewer.