Changeset 6417 for code/trunk/src/libraries/core/BaseObject.cc
- Timestamp:
- Dec 25, 2009, 10:23:58 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/BaseObject.cc
r5929 r6417 36 36 #include <tinyxml/tinyxml.h> 37 37 38 #include "util/StringUtils.h"39 38 #include "CoreIncludes.h" 40 39 #include "Event.h" … … 119 118 XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, Template*); 120 119 XMLPortObject(BaseObject, BaseObject, "eventlisteners", addEventListener, getEventListener, xmlelement, mode); 121 120 122 121 Element* events = 0; 123 122 if (mode == XMLPort::LoadObject || mode == XMLPort::ExpandObject) … … 139 138 XMLPortEventState(BaseObject, BaseObject, "visibility", setVisible, xmlelement, mode); 140 139 XMLPortEventState(BaseObject, BaseObject, "mainstate", setMainState, xmlelement, mode); 141 140 142 141 this->bRegisteredEventStates_ = true; 143 142 } … … 236 235 if (it->second != state) 237 236 continue; 238 237 239 238 if (i == index) 240 239 return it->first; … … 252 251 listener->addEventSource(this, "mainstate"); 253 252 } 254 253 255 254 /** 256 255 @brief Returns an event listener with a given index. … … 278 277 if (it != this->eventStates_.end()) 279 278 { 280 COUT(2) << "Warning: Overwriting EventState in class " << this->getIdentifier()->getName() << "."<< std::endl;279 COUT(2) << "Warning: Overwriting EventState in class " << this->getIdentifier()->getName() << '.' << std::endl; 281 280 delete (it->second); 282 281 } … … 292 291 std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(name); 293 292 if (it != this->eventStates_.end()) 294 return ( (*it).second);293 return (it->second); 295 294 else 296 295 return 0; … … 344 343 { 345 344 this->registerEventStates(); 346 345 347 346 std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(event.statename_); 348 347 if (it != this->eventStates_.end()) 349 348 it->second->process(event, this); 350 else if ( event.statename_ != "")349 else if (!event.statename_.empty()) 351 350 COUT(2) << "Warning: \"" << event.statename_ << "\" is not a valid state in object \"" << this->getName() << "\" of class " << this->getIdentifier()->getName() << "." << std::endl; 352 351 else … … 356 355 /** 357 356 @brief Sets the main state of the object to a given boolean value. 358 357 359 358 Note: The main state of an object can be set with the @ref setMainStateName function. 360 359 It's part of the eventsystem and used for event forwarding (when the target object can't specify a specific state, … … 386 385 this->mainStateFunctor_ = 0; 387 386 388 if ( this->mainStateName_ != "")387 if (!this->mainStateName_.empty()) 389 388 { 390 389 this->registerEventStates(); 391 390 392 391 std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(this->mainStateName_); 393 392 if (it != this->eventStates_.end() && it->second->getFunctor()) … … 402 401 } 403 402 } 404 403 405 404 /** 406 405 @brief Calls XMLEventPort with an empty XML-element to register the event states if necessary. … … 414 413 } 415 414 } 416 415 417 416 /** 418 417 @brief Manually loads all event states, even if the class doesn't officially support them. This is needed by some classes like @ref EventDispatcher or @ref EventTarget. … … 437 436 for (std::list<std::string>::iterator it = eventnames.begin(); it != eventnames.end(); ++it) 438 437 { 439 std::stringstatename = (*it);438 const std::string& statename = (*it); 440 439 441 440 // if the event state is already known, continue with the next state … … 447 446 if (!container) 448 447 { 449 ExecutorMember<BaseObject>* setfunctor = createExecutor(createFunctor(&BaseObject::addEventSource), std::string( "BaseObject" ) + "::" + "addEventSource" + "(" + statename + ")");450 ExecutorMember<BaseObject>* getfunctor = createExecutor(createFunctor(&BaseObject::getEventSource), std::string( "BaseObject" ) + "::" + "getEventSource" + "(" + statename + ")");448 ExecutorMember<BaseObject>* setfunctor = createExecutor(createFunctor(&BaseObject::addEventSource), std::string( "BaseObject" ) + "::" + "addEventSource" + '(' + statename + ')'); 449 ExecutorMember<BaseObject>* getfunctor = createExecutor(createFunctor(&BaseObject::getEventSource), std::string( "BaseObject" ) + "::" + "getEventSource" + '(' + statename + ')'); 451 450 setfunctor->setDefaultValue(1, statename); 452 451 getfunctor->setDefaultValue(1, statename);
Note: See TracChangeset
for help on using the changeset viewer.