- Timestamp:
- Oct 12, 2009, 8:20:07 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/core5 (added) merged: 5768-5769,5772,5775-5780,5783-5785,5791-5792,5795-5807,5809-5814,5816-5832,5836-5839,5842-5853,5855-5899,5904-5922,5924-5928
- Property svn:mergeinfo changed
-
code/trunk/src/modules/objects/eventsystem/EventTarget.cc
r5781 r5929 29 29 #include "EventTarget.h" 30 30 #include "core/CoreIncludes.h" 31 #include "core/XMLPort.h" 31 32 32 33 namespace orxonox … … 37 38 { 38 39 RegisterObject(EventTarget); 40 41 this->bActive_ = false; 39 42 } 40 43 … … 42 45 { 43 46 } 47 48 void EventTarget::XMLPort(Element& xmlelement, XMLPort::Mode mode) 49 { 50 SUPER(EventTarget, XMLPort, xmlelement, mode); 44 51 45 void EventTarget::changedName() 52 XMLPortParam(EventTarget, "target", setTargetName, getTargetName, xmlelement, mode); 53 54 // since we need event sources mapped to any state, we have to parse XML by ourselves 55 this->loadAllEventStates(xmlelement, mode, this, Class(EventTarget)); 56 } 57 58 void EventTarget::processEvent(Event& event) 46 59 { 47 SUPER(EventTarget, changedName); 60 if (this->bActive_) 61 { 62 COUT(2) << "Warning: Detected Event loop in EventTarget \"" << this->getName() << "\"" << std::endl; 63 return; 64 } 48 65 66 this->bActive_ = true; 67 this->fireEvent(event); 68 this->bActive_ = false; 69 } 70 71 void EventTarget::setTargetName(const std::string& name) 72 { 73 this->target_ = name; 74 49 75 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it) 50 if (it->getName() == this-> getName())51 this->add AsEvent(*it);76 if (it->getName() == this->target_) 77 this->addEventTarget(*it); 52 78 } 53 79 54 80 void EventTarget::loadedNewXMLName(BaseObject* object) 55 81 { 56 if (this-> getName()== "")82 if (this->target_ == "") 57 83 return; 58 84 59 if (object->getName() == this-> getName())60 this->add AsEvent(object);85 if (object->getName() == this->target_) 86 this->addEventTarget(object); 61 87 } 62 88 63 void EventTarget::add AsEvent(BaseObject* object)89 void EventTarget::addEventTarget(BaseObject* object) 64 90 { 65 91 if (object != static_cast<BaseObject*>(this)) 66 object->addEvent (this, "");92 object->addEventSource(this, ""); 67 93 } 68 94 }
Note: See TracChangeset
for help on using the changeset viewer.