Changeset 2908 for code/branches/questsystem5/src/core/Identifier.h
- Timestamp:
- Apr 8, 2009, 12:58:47 AM (16 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/core/Identifier.h
r2907 r2908 357 357 static ClassIdentifier<T> *getIdentifier(const std::string& name); 358 358 void addObject(T* object); 359 static bool isFirstCall(); 359 360 360 361 void updateConfigValues(bool updateChildren = true) const; 361 362 362 363 private: 363 static void initialiseIdentifier();364 364 ClassIdentifier(const ClassIdentifier<T>& identifier) {} // don't copy 365 365 ClassIdentifier() … … 376 376 377 377 template <class T> 378 ClassIdentifier<T>* ClassIdentifier<T>::classIdentifier_s = 0; 378 ClassIdentifier<T>* ClassIdentifier<T>::classIdentifier_s; 379 380 /** 381 @brief Returns true if the function gets called the first time, false otherwise. 382 @return True if this function got called the first time. 383 */ 384 template <class T> 385 bool ClassIdentifier<T>::isFirstCall() 386 { 387 static bool bFirstCall = true; 388 389 if (bFirstCall) 390 { 391 bFirstCall = false; 392 return true; 393 } 394 else 395 { 396 return false; 397 } 398 } 379 399 380 400 /** … … 386 406 { 387 407 // check if the static field has already been filled 388 if (ClassIdentifier<T>::classIdentifier_s == 0) 389 ClassIdentifier<T>::initialiseIdentifier(); 390 408 if (ClassIdentifier<T>::isFirstCall()) 409 { 410 // Get the name of the class 411 std::string name = typeid(T).name(); 412 413 // create a new identifier anyway. Will be deleted in Identifier::getIdentifier if not used. 414 ClassIdentifier<T>* proposal = new ClassIdentifier<T>(); 415 416 // Get the entry from the map 417 ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)Identifier::getIdentifierSingleton(name, proposal); 418 419 if (ClassIdentifier<T>::classIdentifier_s == proposal) 420 { 421 COUT(4) << "*** Identifier: Requested Identifier for " << name << " was not yet existing and got created." << std::endl; 422 } 423 else 424 { 425 COUT(4) << "*** Identifier: Requested Identifier for " << name << " was already existing and got assigned." << std::endl; 426 } 427 } 428 429 // Finally return the unique ClassIdentifier 391 430 return ClassIdentifier<T>::classIdentifier_s; 392 431 } … … 403 442 identifier->setName(name); 404 443 return identifier; 405 }406 407 /**408 @brief Assigns the static field for the identifier singleton.409 */410 template <class T>411 void ClassIdentifier<T>::initialiseIdentifier()412 {413 // Get the name of the class414 std::string name = typeid(T).name();415 416 // create a new identifier anyway. Will be deleted in Identifier::getIdentifier if not used.417 ClassIdentifier<T>* proposal = new ClassIdentifier<T>();418 419 // Get the entry from the map420 ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)Identifier::getIdentifierSingleton(name, proposal);421 422 if (ClassIdentifier<T>::classIdentifier_s == proposal)423 {424 COUT(4) << "*** Identifier: Requested Identifier for " << name << " was not yet existing and got created." << std::endl;425 }426 else427 {428 COUT(4) << "*** Identifier: Requested Identifier for " << name << " was already existing and got assigned." << std::endl;429 }430 444 } 431 445
Note: See TracChangeset
for help on using the changeset viewer.