Changeset 2074 for code/branches/objecthierarchy/src/core
- Timestamp:
- Oct 31, 2008, 3:31:21 AM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/core
- Files:
-
- 2 added
- 4 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 { -
code/branches/objecthierarchy/src/core/BaseObject.h
r2065 r2074 115 115 void fireEvent(); 116 116 void fireEvent(bool activate); 117 void fireEvent(bool activate, BaseObject* originator); 118 void fireEvent(Event& event); 117 119 118 120 virtual void processEvent(Event& event); 119 121 122 inline void registerEventListener(BaseObject* object, const std::string& sectionname) 123 { this->eventListeners_[object] = sectionname; } 124 inline void unregisterEventListener(BaseObject* object) 125 { this->eventListeners_.erase(object); } 126 120 127 void addEvent(BaseObject* event, const std::string& sectionname); 128 void removeEvent(BaseObject* event); 121 129 BaseObject* getEvent(unsigned int index) const; 122 130 … … 136 144 137 145 private: 146 void setXMLName(const std::string& name); 138 147 Template* getTemplate(unsigned int index) const; 139 148 -
code/branches/objecthierarchy/src/core/CMakeLists.txt
r2063 r2074 34 34 Template.cc 35 35 XMLPort.cc 36 XMLNameListener.cc 36 37 37 38 # shell -
code/branches/objecthierarchy/src/core/CorePrereqs.h
r2063 r2074 155 155 class Tickable; 156 156 class XMLFile; 157 class XMLNameListener; 157 158 template <class T, class O> 158 159 class XMLPortClassObjectContainer;
Note: See TracChangeset
for help on using the changeset viewer.