Changeset 1856 for code/trunk/src/core
- Timestamp:
- Sep 29, 2008, 4:15:03 AM (16 years ago)
- Location:
- code/trunk/src/core
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/core/CoreIncludes.h
r1789 r1856 94 94 95 95 /** 96 @brief Creates the entry in the Factory. 97 @param ClassName The name of the class 98 */ 99 #define CreateFactory(ClassName) \ 100 bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName) 101 102 /** 96 103 @brief Returns the Identifier of the given class. 97 104 @param ClassName The name of the class … … 101 108 102 109 /** 103 @brief Creates the entry in the Factory.104 @param ClassNameThe name of the class110 @brief Returns the Identifier with a given name through the factory. 111 @param String The name of the class 105 112 */ 106 #define C reateFactory(ClassName) \107 bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName)113 #define ClassByName(String) \ 114 orxonox::Factory::getIdentifier(String) 108 115 109 116 /** 110 @brief Returns the Identifier with either a given name ora given network ID through the factory.111 @param StringOrInt The name or the network ID of the class117 @brief Returns the Identifier with a given network ID through the factory. 118 @param networkID The network ID of the class 112 119 */ 113 #define GetIdentifier(StringOrInt) \114 orxonox::Factory::getIdentifier( StringOrInt)120 #define ClassByID(networkID) \ 121 orxonox::Factory::getIdentifier(networkID) 115 122 116 123 #endif /* _CoreIncludes_H__ */ -
code/trunk/src/core/Factory.cc
r1747 r1856 110 110 return &theOneAndOnlyFactoryInstance; 111 111 } 112 113 /**114 @brief Returns the begin-iterator of the factory-map.115 @return The begin-iterator116 */117 std::map<std::string, Identifier*>::const_iterator Factory::getFactoryBegin()118 {119 return Factory::getFactoryPointer()->identifierStringMap_.begin();120 }121 122 /**123 @brief Returns the end-iterator of the factory-map.124 @return The end-iterator125 */126 std::map<std::string, Identifier*>::const_iterator Factory::getFactoryEnd()127 {128 return Factory::getFactoryPointer()->identifierStringMap_.end();129 }130 112 } -
code/trunk/src/core/Factory.h
r1505 r1856 66 66 67 67 static Factory* getFactoryPointer(); // avoid overriding order problem in the static intialisation process 68 static std::map<std::string, Identifier*>::const_iterator getFactoryBegin(); 69 static std::map<std::string, Identifier*>::const_iterator getFactoryEnd(); 68 69 /** @brief Returns the factory-map. */ 70 static const std::map<std::string, Identifier*>& getFacbtoryMap() 71 { return Factory::getFactoryPointer()->identifierStringMap_; } 72 /** @brief Returns the begin-iterator of the factory-map. */ 73 static std::map<std::string, Identifier*>::const_iterator getFactoryMapBegin() 74 { return Factory::getFactoryPointer()->identifierStringMap_.begin(); } 75 /** @brief Returns the end-iterator of the factory-map. */ 76 static std::map<std::string, Identifier*>::const_iterator getFactoryMapEnd() 77 { return Factory::getFactoryPointer()->identifierStringMap_.end(); } 70 78 71 79 private: -
code/trunk/src/core/Identifier.cc
r1747 r1856 115 115 identifiers[name] = proposal; 116 116 return proposal; 117 } 118 } 119 120 /** 121 @brief Registers a class, which means that the name and the parents get stored. 122 @param parents A list, containing the Identifiers of all parents of the class 123 @param bRootClass True if the class is either an Interface or the BaseObject itself 124 */ 125 void Identifier::initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass) 126 { 127 // Check if at least one object of the given type was created 128 if (!this->bCreatedOneObject_ && Identifier::isCreatingHierarchy()) 129 { 130 // If no: We have to store the informations and initialize the Identifier 131 COUT(4) << "*** ClassIdentifier: Register Class in " << this->getName() << "-Singleton -> Initialize Singleton." << std::endl; 132 if (bRootClass) 133 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. 134 else 135 this->initialize(parents); 117 136 } 118 137 } -
code/trunk/src/core/Identifier.h
r1755 r1856 190 190 inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapEnd() const { return this->consoleCommands_LC_.end(); } 191 191 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(); } 192 205 193 206 /** @brief Returns true if this class has at least one config value. @return True if this class has at least one config value */ … … 219 232 ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const; 220 233 234 void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass); 235 221 236 protected: 222 237 Identifier(); … … 224 239 virtual ~Identifier(); 225 240 226 void initialize(std::set<const Identifier*>* parents);227 241 static Identifier* getIdentifierSingleton(const std::string& name, Identifier* proposal); 228 229 242 virtual void createSuperFunctionCaller() const = 0; 230 243 … … 239 252 inline std::set<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); } 240 253 241 bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents)242 254 ObjectListBase* objects_; //!< The list of all objects of this class 243 255 … … 261 273 } 262 274 275 void initialize(std::set<const Identifier*>* parents); 276 263 277 static void destroyAllIdentifiers(); 264 278 … … 269 283 std::set<const Identifier*>* directChildren_; //!< The direct children of the class the Identifier belongs to 270 284 285 bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents) 271 286 bool bSetName_; //!< True if the name is set 272 287 std::string name_; //!< The name of the class the Identifier belongs to … … 311 326 static ClassIdentifier<T> *getIdentifier(); 312 327 static ClassIdentifier<T> *getIdentifier(const std::string& name); 313 void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);328 void addObject(T* object); 314 329 static bool isFirstCall(); 315 void addObject(T* object);316 330 317 331 void updateConfigValues(bool updateChildren = true) const; … … 328 342 } 329 343 330 static ClassIdentifier<T> *classIdentifier_s;344 static ClassIdentifier<T>* classIdentifier_s; 331 345 }; 332 346 333 347 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; 355 349 356 350 /** … … 476 470 SubclassIdentifier(Identifier* identifier) 477 471 { 478 this-> identifier_ = identifier;472 this->operator=(identifier); 479 473 } 480 474 … … 500 494 /** 501 495 @brief Overloading of the * operator: returns the assigned identifier. 502 @return The assigned identifier 503 */ 504 Identifier* operator*() 496 */ 497 inline Identifier* operator*() 505 498 { 506 499 return this->identifier_; … … 509 502 /** 510 503 @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 514 514 { 515 515 return this->identifier_; … … 527 527 if (newObject) 528 528 { 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); 531 530 } 532 531 else … … 552 551 553 552 /** @brief Returns the assigned identifier. @return The identifier */ 554 inline constIdentifier* getIdentifier() const553 inline Identifier* getIdentifier() const 555 554 { return this->identifier_; } 556 555 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) const559 { 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) const563 { 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) const567 { 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) const571 { 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) const575 { 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) const579 { 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); } 580 579 581 580 private: -
code/trunk/src/core/XMLPort.h
r1854 r1856 468 468 for (ticpp::Iterator<ticpp::Element> child = xmlsubelement->FirstChildElement(false); child != child.end(); child++) 469 469 { 470 Identifier* identifier = GetIdentifier(child->Value());470 Identifier* identifier = ClassByName(child->Value()); 471 471 if (identifier) 472 472 {
Note: See TracChangeset
for help on using the changeset viewer.