Changeset 2074 for code/branches/objecthierarchy/src/core/BaseObject.cc
- Timestamp:
- Oct 31, 2008, 3:31:21 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/core/BaseObject.cc
r2069 r2074 38 38 #include "XMLPort.h" 39 39 #include "XMLFile.h" 40 #include "XMLNameListener.h" 40 41 #include "Template.h" 41 42 #include "util/String.h" … … 81 82 { 82 83 for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it) 83 (*it)->eventListeners_.erase(this); 84 (*it)->unregisterEventListener(this); 85 86 for (std::map<BaseObject*, std::string>::const_iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it) 87 it->first->removeEvent(this); 84 88 } 85 89 … … 92 96 void BaseObject::XMLPort(Element& xmlelement, XMLPort::Mode mode) 93 97 { 94 XMLPortParam(BaseObject, "name", set Name, getName, xmlelement, mode);98 XMLPortParam(BaseObject, "name", setXMLName, getName, xmlelement, mode); 95 99 XMLPortParam(BaseObject, "visible", setVisible, isVisible, xmlelement, mode); 96 100 XMLPortParam(BaseObject, "active", setActive, isActive, xmlelement, mode); … … 135 139 136 140 /** 141 @brief Loads the name of the object through XML and calls all XMLNameListener. 142 @param name The name of the object 143 */ 144 void BaseObject::setXMLName(const std::string& name) 145 { 146 this->setName(name); 147 148 for (ObjectList<XMLNameListener>::iterator it = ObjectList<XMLNameListener>::begin(); it != ObjectList<XMLNameListener>::end(); ++it) 149 it->loadedNewXMLName(this); 150 } 151 152 /** 137 153 @brief Returns the levelfile that loaded this object. 138 154 @return The levelfile … … 187 203 void BaseObject::addEvent(BaseObject* event, const std::string& sectionname) 188 204 { 189 event-> eventListeners_[this] = sectionname;205 event->registerEventListener(this, sectionname); 190 206 this->events_.push_back(event); 207 } 208 209 void BaseObject::removeEvent(BaseObject* event) 210 { 211 this->events_.remove(event); 191 212 } 192 213 … … 232 253 void BaseObject::fireEvent(bool activate) 233 254 { 234 Event event(activate, this); 255 this->fireEvent(activate, this); 256 } 257 258 void BaseObject::fireEvent(bool activate, BaseObject* originator) 259 { 260 Event event(activate, originator); 235 261 236 262 for (std::map<BaseObject*, std::string>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it) … … 241 267 } 242 268 269 void BaseObject::fireEvent(Event& event) 270 { 271 for (std::map<BaseObject*, std::string>::iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it) 272 it->first->processEvent(event); 273 } 274 243 275 void BaseObject::processEvent(Event& event) 244 276 {
Note: See TracChangeset
for help on using the changeset viewer.