Changeset 7911 in orxonox.OLD for branches/gui/src/lib
- Timestamp:
- May 27, 2006, 5:56:15 PM (19 years ago)
- Location:
- branches/gui/src/lib/event
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/event/event_handler.cc
r7910 r7911 183 183 { 184 184 for(unsigned int i = 0; i < ES_NUMBER; i++) 185 this->listeners[i][eventType].push_back(el); 186 } 187 else 188 this->listeners[state][eventType].push_back(el); 185 if (!this->findListener( NULL, (elState)i, eventType, el)) 186 this->listeners[i][eventType].push_back(el); 187 else 188 { 189 PRINTF(2)("%s::%s was already subscribed to state %d event %d\n", el->getClassName(), el->getName(), i, eventType); 190 } 191 } 192 else 193 { 194 if (!this->findListener( NULL, state, eventType, el)) 195 this->listeners[state][eventType].push_back(el); 196 else 197 { 198 PRINTF(2)("%s::%s was already subscribed to state %d event %d\n", el->getClassName(), el->getName(), state, eventType); 199 } 200 } 189 201 } 190 202 … … 204 216 for (unsigned int i = 0; i < ES_NUMBER; i++) 205 217 { 206 std::vector<EventListener*>::iterator listener = 207 std::find(this->listeners[i][eventType].begin(), 208 this->listeners[i][eventType].end(), 209 el); 210 if (listener != this->listeners[i][eventType].end()) 218 std::vector<EventListener*>::iterator listener; 219 if (this->findListener(&listener, (elState)i, eventType, el)) 211 220 this->listeners[i][eventType].erase(listener); 212 221 } 213 222 else 214 223 { 215 std::vector<EventListener*>::iterator listener = 216 std::find(this->listeners[state][eventType].begin(), 217 this->listeners[state][eventType].end(), 218 el); 219 if (listener != this->listeners[state][eventType].end()) 224 std::vector<EventListener*>::iterator listener; 225 if (this->findListener(&listener, state, eventType, el)) 220 226 this->listeners[state][eventType].erase(listener); 221 227 } … … 293 299 294 300 301 bool EventHandler::findListener(std::vector<EventListener*>::iterator* it, elState state, int eventType, EventListener* listener) 302 { 303 std::vector<EventListener*>::iterator findIterator = 304 std::find(this->listeners[state][eventType].begin(), this->listeners[state][eventType].end(), listener); 305 if (it != NULL) 306 *it = findIterator; 307 return ( findIterator != this->listeners[state][eventType].end()); 308 309 } 310 311 312 295 313 /** 296 314 * @brief if the unicode characters should be recorded. … … 323 341 } 324 342 } 343 325 344 326 345 … … 418 437 419 438 /// setting a temporary state in case of an EventListener's process changes the state. 420 printf("%d \n", this->listeners[state][event.type].size());439 printf("%d event: %d state: %d\n", this->listeners[state][event.type].size(), event.type, state); 421 440 for (unsigned int i = 0; i < this->listeners[state][event.type].size(); i++) 422 441 { -
branches/gui/src/lib/event/event_handler.h
r7903 r7911 55 55 EventHandler(); 56 56 57 bool findListener(std::vector<EventListener*>::iterator* it, elState state, int eventType, EventListener* listener); 58 57 59 private: 58 60 static EventHandler* singletonRef; //!< the singleton reference
Note: See TracChangeset
for help on using the changeset viewer.