Changeset 1543 for code/trunk/src/core/Identifier.h
- Timestamp:
- Jun 5, 2008, 2:18:14 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/core/Identifier.h
r1505 r1543 253 253 } 254 254 255 static Identifier* getIdentifier(std::string &name, Identifier *proposal); 256 255 257 std::set<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to 256 258 std::set<const Identifier*>* children_; //!< The children of the class the Identifier belongs to … … 288 290 289 291 To be really sure that not more than exactly one object exists (even with libraries), 290 ClassIdentifiers are only created by IdentifierDistributor. 291 292 You can access the ClassIdentifiers created by IdentifierDistributor through the 293 ClassManager singletons. 292 ClassIdentifiers are stored in the Identifier Singleton. 294 293 */ 295 294 template <class T> 296 295 class ClassIdentifier : public Identifier 297 296 { 298 template <class TT>299 friend class ClassManager;300 301 297 public: 302 298 ClassIdentifier<T>* registerClass(std::set<const Identifier*>* parents, const std::string& name, bool bRootClass); … … 316 312 void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container); 317 313 314 static ClassIdentifier<T> *getIdentifier(); 315 318 316 private: 319 317 ClassIdentifier(); … … 325 323 std::map<std::string, XMLPortClassParamContainer<T>*> xmlportParamContainers_; //!< All loadable parameters 326 324 std::map<std::string, XMLPortClassObjectContainer<T, class O>*> xmlportObjectContainers_; //!< All attachable objects 325 326 static ClassIdentifier<T> *classIdentifier_s; 327 327 }; 328 329 template <class T> 330 ClassIdentifier<T> *ClassIdentifier<T>::classIdentifier_s = 0; 328 331 329 332 /** … … 365 368 366 369 /** 370 @brief Creates the only instance of this class for the template class T and retrieves a unique Identifier for the given name. 371 @return The unique Identifier 372 */ 373 template <class T> 374 ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier() 375 { 376 // check if the static field has already been filled 377 if (ClassIdentifier<T>::classIdentifier_s == 0) 378 { 379 // Get the name of the class 380 std::string name = typeid(T).name(); 381 382 // create a new identifier anyway. Will be deleted in Identifier::getIdentifier if not used. 383 ClassIdentifier<T> *proposal = new ClassIdentifier<T>(); 384 385 // Get the entry from the map 386 ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)Identifier::getIdentifier(name, proposal); 387 } 388 389 // Finally return the unique ClassIdentifier 390 return ClassIdentifier<T>::classIdentifier_s; 391 } 392 393 /** 367 394 @brief Sets the name of the class. 368 395 @param name The name … … 472 499 SubclassIdentifier() 473 500 { 474 this->identifier_ = Class Manager<T>::getIdentifier();501 this->identifier_ = ClassIdentifier<T>::getIdentifier(); 475 502 } 476 503 … … 491 518 SubclassIdentifier<T>& operator=(Identifier* identifier) 492 519 { 493 if (!identifier->isA(Class Manager<T>::getIdentifier()))520 if (!identifier->isA(ClassIdentifier<T>::getIdentifier())) 494 521 { 495 522 COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl; 496 COUT(1) << "Error: Class " << identifier->getName() << " is not a " << Class Manager<T>::getIdentifier()->getName() << "!" << std::endl;497 COUT(1) << "Error: SubclassIdentifier<" << Class Manager<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;523 COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl; 524 COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl; 498 525 COUT(1) << "Aborting..." << std::endl; 499 526 abort(); … … 541 568 { 542 569 COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl; 543 COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << Class Manager<T>::getIdentifier()->getName() << "!" << std::endl;570 COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl; 544 571 COUT(1) << "Error: Couldn't fabricate a new Object." << std::endl; 545 572 COUT(1) << "Aborting..." << std::endl;
Note: See TracChangeset
for help on using the changeset viewer.