Changeset 2087 for code/trunk/src/core/Identifier.cc
- Timestamp:
- Nov 1, 2008, 7:04:09 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/core/Identifier.cc
r1856 r2087 59 59 this->bSetName_ = false; 60 60 this->factory_ = 0; 61 this->bLoadable_ = true; 61 62 62 63 this->bHasConfigValues_ = false; 63 64 this->bHasConsoleCommands_ = false; 65 this->bHasConstructionCallback_ = false; 64 66 65 67 this->children_ = new std::set<const Identifier*>(); … … 213 215 @return The new object 214 216 */ 215 BaseObject* Identifier::fabricate( )217 BaseObject* Identifier::fabricate(BaseObject* creator) 216 218 { 217 219 if (this->factory_) 218 220 { 219 return this->factory_->fabricate( ); // We have to return a BaseObject, because we don't know the exact type.221 return this->factory_->fabricate(creator); // We have to return a BaseObject, because we don't know the exact type. 220 222 } 221 223 else … … 420 422 XMLPortParamContainer* Identifier::getXMLPortParamContainer(const std::string& paramname) 421 423 { 422 std::map<std::string, XMLPortParamContainer*>::const_iterator it = xmlportParamContainers_.find(paramname);423 if (it != xmlportParamContainers_.end())424 std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname); 425 if (it != this->xmlportParamContainers_.end()) 424 426 return ((*it).second); 425 427 else … … 434 436 void Identifier::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container) 435 437 { 438 std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname); 439 if (it != this->xmlportParamContainers_.end()) 440 { 441 COUT(2) << "Warning: Overwriting XMLPortParamContainer in class " << this->getName() << "." << std::endl; 442 delete (it->second); 443 } 444 436 445 this->xmlportParamContainers_[paramname] = container; 437 446 } … … 444 453 XMLPortObjectContainer* Identifier::getXMLPortObjectContainer(const std::string& sectionname) 445 454 { 446 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = xmlportObjectContainers_.find(sectionname);447 if (it != xmlportObjectContainers_.end())455 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname); 456 if (it != this->xmlportObjectContainers_.end()) 448 457 return ((*it).second); 449 458 else … … 458 467 void Identifier::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container) 459 468 { 469 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname); 470 if (it != this->xmlportObjectContainers_.end()) 471 { 472 COUT(2) << "Warning: Overwriting XMLPortObjectContainer in class " << this->getName() << "." << std::endl; 473 delete (it->second); 474 } 475 460 476 this->xmlportObjectContainers_[sectionname] = container; 477 } 478 479 /** 480 @brief Returns a XMLPortEventContainer that attaches an event to this class. 481 @param sectionname The name of the section that contains the event 482 @return The container 483 */ 484 XMLPortObjectContainer* Identifier::getXMLPortEventContainer(const std::string& eventname) 485 { 486 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname); 487 if (it != this->xmlportEventContainers_.end()) 488 return ((*it).second); 489 else 490 return 0; 491 } 492 493 /** 494 @brief Adds a new XMLPortEventContainer that attaches an event to this class. 495 @param sectionname The name of the section that contains the event 496 @param container The container 497 */ 498 void Identifier::addXMLPortEventContainer(const std::string& eventname, XMLPortObjectContainer* container) 499 { 500 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname); 501 if (it != this->xmlportEventContainers_.end()) 502 { 503 COUT(2) << "Warning: Overwriting XMLPortEventContainer in class " << this->getName() << "." << std::endl; 504 delete (it->second); 505 } 506 507 this->xmlportEventContainers_[eventname] = container; 508 } 509 510 /** 511 @brief Adds a construction callback functor that gets called every time an object is created. 512 @param functor Functor pointer to any function with no argument. 513 */ 514 void Identifier::addConstructionCallback(Functor* functor) 515 { 516 for (unsigned int i = 0; i < this->constructionCallbacks_.size(); ++i) 517 { 518 if (this->constructionCallbacks_[i] == functor) 519 return; 520 } 521 this->constructionCallbacks_.push_back(functor); 522 this->bHasConstructionCallback_ = true; 523 } 524 525 /** 526 @brief Removes a construction callback functor that gets called every time an object is created. 527 @param functor Functor pointer to any function with no argument. 528 */ 529 void Identifier::removeConstructionCallback(Functor* functor) 530 { 531 for (unsigned int i = 0; i < this->constructionCallbacks_.size(); ++i) 532 { 533 if (this->constructionCallbacks_[i] == functor) 534 { 535 this->constructionCallbacks_.erase(this->constructionCallbacks_.begin() + i); 536 } 537 } 538 if (constructionCallbacks_.empty()) 539 this->bHasConstructionCallback_ = false; 461 540 } 462 541
Note: See TracChangeset
for help on using the changeset viewer.