Changeset 5890 for code/branches/core5/src/modules
- Timestamp:
- Oct 6, 2009, 5:29:39 AM (15 years ago)
- Location:
- code/branches/core5/src/modules/objects/eventsystem
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/modules/objects/eventsystem/EventTarget.cc
r5887 r5890 38 38 { 39 39 RegisterObject(EventTarget); 40 41 this->bActive_ = false; 40 42 } 41 43 … … 48 50 SUPER(EventTarget, XMLPort, xmlelement, mode); 49 51 52 XMLPortParam(EventTarget, "target", setTargetName, getTargetName, xmlelement, mode); 53 50 54 // since we need event sources mapped to any state, we have to parse XML by ourselves 51 55 this->loadAllEventStates(xmlelement, mode, this, Class(EventTarget)); … … 54 58 void EventTarget::processEvent(Event& event) 55 59 { 60 if (this->bActive_) 61 { 62 COUT(2) << "Warning: Detected Event loop in EventTarget \"" << this->getName() << "\"" << std::endl; 63 return; 64 } 65 66 this->bActive_ = true; 56 67 this->fireEvent(event); 68 this->bActive_ = false; 57 69 } 58 70 59 void EventTarget:: changedName()71 void EventTarget::setTargetName(const std::string& name) 60 72 { 61 SUPER(EventTarget, changedName);62 73 this->target_ = name; 74 63 75 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it) 64 if (it->getName() == this-> getName())76 if (it->getName() == this->target_) 65 77 this->addEventTarget(*it); 66 78 } … … 68 80 void EventTarget::loadedNewXMLName(BaseObject* object) 69 81 { 70 if (this-> getName()== "")82 if (this->target_ == "") 71 83 return; 72 84 73 if (object->getName() == this-> getName())85 if (object->getName() == this->target_) 74 86 this->addEventTarget(object); 75 87 } -
code/branches/core5/src/modules/objects/eventsystem/EventTarget.h
r5887 r5890 47 47 virtual void processEvent(Event& event); 48 48 49 virtual void changedName(); 49 void setTargetName(const std::string& name); 50 inline const std::string& getTargetName() const 51 { return this->target_; } 50 52 51 53 private: 52 54 virtual void loadedNewXMLName(BaseObject* object); 53 55 void addEventTarget(BaseObject* object); 56 57 std::string target_; 58 bool bActive_; 54 59 }; 55 60 }
Note: See TracChangeset
for help on using the changeset viewer.