Changeset 3196 for code/trunk/src/core/Identifier.h
- Timestamp:
- Jun 20, 2009, 9:20:47 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/pch (added) merged: 3114-3118,3124-3125,3127-3131,3133,3138-3194
- Property svn:mergeinfo changed
-
code/trunk/src/core/Identifier.h
r2784 r3196 55 55 #include "CorePrereqs.h" 56 56 57 #include <cassert> 58 #include <map> 57 59 #include <set> 58 #include <map>59 #include <vector>60 60 #include <string> 61 #include <utility>62 61 #include <typeinfo> 63 #include <cstdlib> 64 #include <cassert> 65 62 63 #include "util/Debug.h" 66 64 #include "MetaObjectList.h" 67 #include "Iterator.h" 65 #include "ObjectList.h" 66 #include "ObjectListBase.h" 68 67 #include "Super.h" 69 #include "Functor.h"70 #include "util/Debug.h"71 #include "util/String.h"72 68 73 69 namespace orxonox … … 223 219 /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */ 224 220 inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; } 225 /** @brief Returns true if this class has at least one construction callback Functor registered. */226 inline bool hasConstructionCallback() const { return this->bHasConstructionCallback_; }227 221 228 222 /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */ … … 251 245 ConsoleCommand* getConsoleCommand(const std::string& name) const; 252 246 ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const; 253 254 void addConstructionCallback(Functor* functor);255 void removeConstructionCallback(Functor* functor);256 247 257 248 void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass); … … 276 267 /** @brief Returns the direct children of the class the Identifier belongs to. @return The list of all direct children */ 277 268 inline std::set<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); } 278 279 bool bHasConstructionCallback_; //!< True if at least one Functor is registered to get informed when an object of type T is created.280 std::vector<Functor*> constructionCallbacks_; //!< All construction callback Functors of this class.281 269 282 270 ObjectListBase* objects_; //!< The list of all objects of this class … … 383 371 */ 384 372 template <class T> 385 ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()373 inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier() 386 374 { 387 375 // check if the static field has already been filled … … 398 386 */ 399 387 template <class T> 400 ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier(const std::string& name)388 inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier(const std::string& name) 401 389 { 402 390 ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier(); … … 435 423 */ 436 424 template <class T> 437 void ClassIdentifier<T>::addObject(T* object)425 inline void ClassIdentifier<T>::addObject(T* object) 438 426 { 439 427 COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl; 440 428 object->getMetaList().add(this->objects_, this->objects_->add(new ObjectListElement<T>(object))); 441 if (this->bHasConstructionCallback_)442 {443 // Call all registered callbacks that a new object of type T has been created.444 // Do NOT deliver a T* pointer here because it's way too risky (object not yet fully created).445 for (unsigned int i = 0; i < this->constructionCallbacks_.size(); ++i)446 (*constructionCallbacks_[i])();447 }448 429 } 449 430
Note: See TracChangeset
for help on using the changeset viewer.