Changeset 9644 for code/branches
- Timestamp:
- Aug 11, 2013, 10:42:57 PM (11 years ago)
- Location:
- code/branches/core6/src/libraries/core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/src/libraries/core/CoreIncludes.h
r9640 r9644 95 95 */ 96 96 #define InternRegisterObject(ClassName, bRootClass) \ 97 if (ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initiali seObject(this, #ClassName, bRootClass)) \97 if (ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initializeObject(this, #ClassName, bRootClass)) \ 98 98 return; \ 99 99 else \ -
code/branches/core6/src/libraries/core/class/Identifier.h
r9643 r9644 114 114 inline const std::string& getName() const { return this->name_; } 115 115 void setName(const std::string& name); 116 117 /// Returns the name of the class as it is returned by typeid(T).name() 118 virtual const std::string& getTypeidName() = 0; 116 119 117 120 /// Returns the network ID to identify a class through the network. … … 272 275 static ClassIdentifier<T>* getIdentifier(const std::string& name); 273 276 274 bool initiali seObject(T* object, const std::string& className, bool bRootClass);277 bool initializeObject(T* object, const std::string& className, bool bRootClass); 275 278 276 279 void setConfigValues(T* object, Configurable*) const; … … 280 283 void addObjectToList(T* object, Identifiable*); 281 284 282 void updateConfigValues(bool updateChildren = true) const; 285 virtual void updateConfigValues(bool updateChildren = true) const; 286 287 virtual const std::string& getTypeidName() 288 { return this->typeidName_; } 283 289 284 290 private: 285 static void initialiseIdentifier(); 291 static void initializeIdentifier(); 292 286 293 ClassIdentifier(const ClassIdentifier<T>& identifier) {} // don't copy 287 294 ClassIdentifier() 288 295 { 296 this->typeidName_ = typeid(T).name(); 289 297 SuperFunctionInitialization<0, T>::initialize(this); 290 298 } … … 299 307 void updateConfigValues(bool updateChildren, Identifiable*) const; 300 308 309 std::string typeidName_; 301 310 static ClassIdentifier<T>* classIdentifier_s; 302 311 }; … … 314 323 // check if the Identifier already exists 315 324 if (!ClassIdentifier<T>::classIdentifier_s) 316 ClassIdentifier<T>::initiali seIdentifier();325 ClassIdentifier<T>::initializeIdentifier(); 317 326 318 327 return ClassIdentifier<T>::classIdentifier_s; … … 336 345 */ 337 346 template <class T> 338 void ClassIdentifier<T>::initialiseIdentifier() 339 { 340 // Get the name of the class 341 std::string name = typeid(T).name(); 342 343 // create a new identifier anyway. Will be deleted in Identifier::getIdentifier if not used. 347 /*static */ void ClassIdentifier<T>::initializeIdentifier() 348 { 349 // create a new identifier anyway. Will be deleted if not used. 344 350 ClassIdentifier<T>* proposal = new ClassIdentifier<T>(); 345 351 346 352 // Get the entry from the map 347 ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)IdentifierManager::getInstance().getIdentifierSingleton( name,proposal);353 ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)IdentifierManager::getInstance().getIdentifierSingleton(proposal); 348 354 349 355 if (ClassIdentifier<T>::classIdentifier_s == proposal) 350 { 351 orxout(verbose, context::identifier) << "Requested Identifier for " << name << " was not yet existing and got created." << endl; 352 } 356 orxout(verbose, context::identifier) << "Requested Identifier for " << proposal->getTypeidName() << " was not yet existing and got created." << endl; 353 357 else 354 358 { 355 orxout(verbose, context::identifier) << "Requested Identifier for " << name << " was already existing and got assigned." << endl; 359 orxout(verbose, context::identifier) << "Requested Identifier for " << proposal->getTypeidName() << " was already existing and got assigned." << endl; 360 delete proposal; // delete proposal (it is not used anymore) 356 361 } 357 362 } … … 364 369 */ 365 370 template <class T> 366 bool ClassIdentifier<T>::initiali seObject(T* object, const std::string& className, bool bRootClass)371 bool ClassIdentifier<T>::initializeObject(T* object, const std::string& className, bool bRootClass) 367 372 { 368 373 if (bRootClass) -
code/branches/core6/src/libraries/core/class/IdentifierManager.cc
r9641 r9644 57 57 /** 58 58 @brief Returns an identifier by name and adds it if not available 59 @param name The name of the identifier as typeid().name() suggests60 59 @param proposal A pointer to a newly created identifier for the case of non existence in the map 61 60 @return The identifier (unique instance) 62 61 */ 63 Identifier* IdentifierManager::getIdentifierSingleton( const std::string& name,Identifier* proposal)62 Identifier* IdentifierManager::getIdentifierSingleton(Identifier* proposal) 64 63 { 65 std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeId_.find(name); 64 const std::string& typeidName = proposal->getTypeidName(); 65 std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeidName_.find(typeidName); 66 66 67 if (it != this->identifierByType Id_.end())67 if (it != this->identifierByTypeidName_.end()) 68 68 { 69 // There is already an entry: return it and delete the proposal 70 delete proposal; 69 // There is already an entry: return it 71 70 return it->second; 72 71 } … … 74 73 { 75 74 // There is no entry: put the proposal into the map and return it 76 this->identifierByType Id_[name] = proposal;75 this->identifierByTypeidName_[typeidName] = proposal; 77 76 return proposal; 78 77 } … … 96 95 orxout(internal_status) << "Create class-hierarchy" << endl; 97 96 this->startCreatingHierarchy(); 98 for (std::map<std::string, Identifier*>::const_iterator it = this->identifierByType Id_.begin(); it != this->identifierByTypeId_.end(); ++it)97 for (std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeidName_.begin(); it != this->identifierByTypeidName_.end(); ++it) 99 98 { 100 99 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. … … 114 113 void IdentifierManager::destroyAllIdentifiers() 115 114 { 116 for (std::map<std::string, Identifier*>::iterator it = this->identifierByType Id_.begin(); it != this->identifierByTypeId_.end(); ++it)115 for (std::map<std::string, Identifier*>::iterator it = this->identifierByTypeidName_.begin(); it != this->identifierByTypeidName_.end(); ++it) 117 116 delete (it->second); 118 117 119 this->identifierByType Id_.clear();118 this->identifierByTypeidName_.clear(); 120 119 this->identifierByString_.clear(); 121 120 this->identifierByLowercaseString_.clear(); -
code/branches/core6/src/libraries/core/class/IdentifierManager.h
r9642 r9644 47 47 static IdentifierManager& getInstance(); 48 48 49 Identifier* getIdentifierSingleton( const std::string& name,Identifier* proposal);49 Identifier* getIdentifierSingleton(Identifier* proposal); 50 50 void registerIdentifier(Identifier* identifier); 51 51 … … 96 96 { hierarchyCreatingCounter_s--; } 97 97 98 std::map<std::string, Identifier*> identifierByType Id_;//!< Map with the names as received by typeid(). This is only used internally.98 std::map<std::string, Identifier*> identifierByTypeidName_; //!< Map with the names as received by typeid(). This is only used internally. 99 99 100 100 std::map<std::string, Identifier*> identifierByString_; //!< Map that stores all Identifiers with their names.
Note: See TracChangeset
for help on using the changeset viewer.