Changeset 5887 for code/branches/core5/src/libraries/core/BaseObject.cc
- Timestamp:
- Oct 6, 2009, 4:51:08 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/core/BaseObject.cc
r5883 r5887 245 245 246 246 /** 247 @brief Adds an object which listens to the events of this object. 247 @brief Adds an object which listens to the events of this object. The events are sent to the other objects mainstate. 248 248 */ 249 249 void BaseObject::addEventListener(BaseObject* listener) … … 268 268 } 269 269 270 /** 271 @brief Adds a new event-state to the object. Event-states are states which can be changed by events. 272 @param name The name of the event 273 @param state The object containing information about the event-state 274 */ 270 275 void BaseObject::addEventState(const std::string& name, EventState* state) 271 276 { … … 280 285 } 281 286 287 /** 288 @brief Returns the event-state with the given name. 289 */ 282 290 EventState* BaseObject::getEventState(const std::string& name) const 283 291 { … … 406 414 } 407 415 } 416 417 /** 418 @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. 419 */ 420 void BaseObject::loadAllEventStates(Element& xmlelement, XMLPort::Mode mode, BaseObject* object, Identifier* identifier) 421 { 422 Element* events = xmlelement.FirstChildElement("events", false); 423 if (events) 424 { 425 // get the list of all states present 426 std::list<std::string> eventnames; 427 if (mode == XMLPort::LoadObject || mode == XMLPort::ExpandObject) 428 { 429 for (ticpp::Iterator<ticpp::Element> child = events->FirstChildElement(false); child != child.end(); child++) 430 eventnames.push_back(child->Value()); 431 } 432 else if (mode == XMLPort::SaveObject) 433 { 434 } 435 436 // iterate through all states and get the event sources 437 for (std::list<std::string>::iterator it = eventnames.begin(); it != eventnames.end(); ++it) 438 { 439 std::string statename = (*it); 440 441 // if the event state is already known, continue with the next state 442 orxonox::EventState* eventstate = object->getEventState(statename); 443 if (eventstate) 444 continue; 445 446 XMLPortClassObjectContainer<BaseObject, BaseObject>* container = (XMLPortClassObjectContainer<BaseObject, BaseObject>*)(identifier->getXMLPortObjectContainer(statename)); 447 if (!container) 448 { 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 + ")"); 451 setfunctor->setDefaultValue(1, statename); 452 getfunctor->setDefaultValue(1, statename); 453 454 container = new XMLPortClassObjectContainer<BaseObject, BaseObject>(statename, identifier, setfunctor, getfunctor, false, true); 455 identifier->addXMLPortObjectContainer(statename, container); 456 } 457 container->port(object, *events, mode); 458 } 459 } 460 } 408 461 }
Note: See TracChangeset
for help on using the changeset viewer.