Changeset 3224 for code/branches/core4/src
- Timestamp:
- Jun 23, 2009, 8:14:46 PM (16 years ago)
- Location:
- code/branches/core4/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core4/src/core/CoreIncludes.h
r3196 r3224 56 56 */ 57 57 #define InternRegisterObject(ClassName, bRootClass) \ 58 this->setIdentifier(orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)); \ 59 if (orxonox::Identifier::isCreatingHierarchy()) \ 60 { \ 61 if (this->getParents()) \ 62 { \ 63 orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initializeClassHierarchy(this->getParents(), bRootClass); \ 64 this->getParents()->insert(this->getParents()->end(), this->getIdentifier()); \ 65 } \ 66 this->setConfigValues(); \ 58 if (ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initialiseObject(this, #ClassName, bRootClass)) \ 67 59 return; \ 68 } \ 69 orxonox::ClassIdentifier<ClassName>::getIdentifier()->addObject(this) 70 71 /** 72 @brief Intern macro, containing the specific part of RegisterRootObject. 73 @param ClassName The name of the class 74 */ 75 #define InternRegisterRootObject(ClassName) \ 76 if (orxonox::Identifier::isCreatingHierarchy() && !this->getParents()) \ 77 this->createParents(); \ 78 InternRegisterObject(ClassName, true) 60 else \ 61 ((void)0) 79 62 80 63 /** … … 83 66 */ 84 67 #define RegisterObject(ClassName) \ 85 COUT(5) << "*** Register Object: " << #ClassName << std::endl; \86 68 InternRegisterObject(ClassName, false) 87 69 … … 91 73 */ 92 74 #define RegisterRootObject(ClassName) \ 93 COUT(5) << "*** Register Root-Object: " << #ClassName << std::endl; \ 94 InternRegisterRootObject(ClassName) 75 InternRegisterObject(ClassName, true) 95 76 96 77 /** … … 115 96 orxonox::ClassIdentifier<ClassName>::getIdentifier() 116 97 117 /**118 @brief Returns the Identifier with a given name through the factory.119 @param String The name of the class120 */121 #define ClassByString(String) \122 orxonox::Factory::getIdentifier(String)123 98 124 /** 125 @brief Returns the Identifier with a given network ID through the factory. 126 @param networkID The network ID of the class 127 */ 128 #define ClassByID(networkID) \ 129 orxonox::Factory::getIdentifier(networkID) 99 namespace orxonox 100 { 101 /** 102 @brief Returns the Identifier with a given name through the factory. 103 @param String The name of the class 104 */ 105 inline Identifier* ClassByString(const std::string& name) 106 { 107 return Factory::getIdentifier(name); 108 } 109 110 /** 111 @brief Returns the Identifier with a given network ID through the factory. 112 @param networkID The network ID of the class 113 */ 114 inline Identifier* ClassByID(uint32_t id) 115 { 116 return Factory::getIdentifier(id); 117 } 118 } 130 119 131 120 #endif /* _CoreIncludes_H__ */ -
code/branches/core4/src/core/Identifier.h
r3223 r3224 349 349 static ClassIdentifier<T> *getIdentifier(); 350 350 static ClassIdentifier<T> *getIdentifier(const std::string& name); 351 void addObject(T* object); 351 352 bool initialiseObject(T* object, const std::string& className, bool bRootClass); 352 353 353 354 void updateConfigValues(bool updateChildren = true) const; … … 428 429 */ 429 430 template <class T> 430 inline void ClassIdentifier<T>::addObject(T* object) 431 { 432 COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl; 433 object->getMetaList().add(this->objects_, this->objects_->add(new ObjectListElement<T>(object))); 434 // Add pointer of type T to the map in the OrxonoxClass instance that enables "dynamic_casts" 435 object->objectPointers_.push_back(std::make_pair(this->getClassID(), reinterpret_cast<void*>(object))); 431 bool ClassIdentifier<T>::initialiseObject(T* object, const std::string& className, bool bRootClass) 432 { 433 if (bRootClass) 434 COUT(5) << "*** Register Root-Object: " << className << std::endl; 435 else 436 COUT(5) << "*** Register Object: " << className << std::endl; 437 438 object->identifier_ = this; 439 if (Identifier::isCreatingHierarchy()) 440 { 441 if (bRootClass && !object->parents_) 442 object->parents_ = new std::set<const Identifier*>(); 443 444 if (object->parents_) 445 { 446 this->initializeClassHierarchy(object->parents_, bRootClass); 447 object->parents_->insert(object->parents_->end(), this); 448 } 449 450 object->setConfigValues(); 451 return true; 452 } 453 else 454 { 455 COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl; 456 object->metaList_->add(this->objects_, this->objects_->add(new ObjectListElement<T>(object))); 457 458 // Add pointer of type T to the map in the OrxonoxClass instance that enables "dynamic_casts" 459 object->objectPointers_.push_back(std::make_pair(this->getClassID(), reinterpret_cast<void*>(object))); 460 return false; 461 } 436 462 } 437 463 -
code/branches/core4/src/core/OrxonoxClass.h
r3223 r3224 63 63 inline Identifier* getIdentifier() const { return this->identifier_; } 64 64 65 /** @brief Sets the Identifier of the object. Used by the RegisterObject-macro. */66 inline void setIdentifier(Identifier* identifier) { this->identifier_ = identifier; }67 68 /** @brief Returns the list of all parents of the object. @return The list */69 inline std::set<const Identifier*>* getParents() const { return this->parents_; }70 71 /** @brief Creates the parents-list. */72 inline void createParents() { this->parents_ = new std::set<const Identifier*>(); }73 74 /** @brief Returns the MetaObjectList of the object, containing a link to all ObjectLists and ObjectListElements the object is registered in. @return The list */75 inline MetaObjectList& getMetaList() { return (*this->metaList_); }76 77 78 65 bool isA(const Identifier* identifier); 79 66 bool isExactlyA(const Identifier* identifier); -
code/branches/core4/src/network/NetworkFunction.h
r3223 r3224 38 38 #include <boost/preprocessor/cat.hpp> 39 39 40 #include "core/OrxonoxClass.h"41 40 #include "core/Functor.h" 41 #include "core/Identifier.h" 42 42 #include "FunctionCallManager.h" 43 43 #include "synchronisable/Synchronisable.h"
Note: See TracChangeset
for help on using the changeset viewer.