Changeset 2069 for code/branches/objecthierarchy/src/core
- Timestamp:
- Oct 30, 2008, 11:58:31 PM (16 years ago)
- Location:
- code/branches/objecthierarchy/src/core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/core/BaseObject.cc
r2065 r2069 217 217 EventContainer* BaseObject::getEventContainer(const std::string& sectionname) const 218 218 { 219 std::map<std::string, EventContainer*>::const_iterator it = this->eventContainers_. begin();219 std::map<std::string, EventContainer*>::const_iterator it = this->eventContainers_.find(sectionname); 220 220 if (it != this->eventContainers_.end()) 221 221 return ((*it).second); -
code/branches/objecthierarchy/src/core/Event.cc
r2065 r2069 38 38 } 39 39 40 void EventContainer::process( BaseObject* object, const Event& event)40 void EventContainer::process(void* object, const Event& event) 41 41 { 42 42 if (this->eventname_ == event.sectionname_) … … 47 47 ++this->activeEvents_; 48 48 else 49 { 49 50 --this->activeEvents_; 50 51 52 if (this->activeEvents_ < 0) 53 this->activeEvents_ = 0; 54 } 55 51 56 if (this->eventfunction_->getParamCount() == 0 && event.activate_) 52 (*this->eventfunction_)( object);57 (*this->eventfunction_)(); 53 58 else if ((this->activeEvents_ == 1 && event.activate_) || (this->activeEvents_ == 0 && !event.activate_)) 54 59 { 55 60 if (this->eventfunction_->getParamCount() == 1) 56 (*this->eventfunction_)( object,this->activeEvents_);61 (*this->eventfunction_)(this->activeEvents_); 57 62 else if (this->eventfunction_->getParamCount() >= 2 && event.castedOriginator_) 58 (*this->eventfunction_)( object,this->activeEvents_, event.castedOriginator_);63 (*this->eventfunction_)(this->activeEvents_, event.castedOriginator_); 59 64 } 60 65 } -
code/branches/objecthierarchy/src/core/Event.h
r2065 r2069 48 48 public: 49 49 EventContainer(const std::string& eventname, Executor* eventfunction, Identifier* subclass) : eventname_(eventname), eventfunction_(eventfunction), subclass_(subclass), activeEvents_(0) {} 50 ~EventContainer();50 virtual ~EventContainer(); 51 51 52 v oid process(BaseObject* object, const Event& event);52 virtual void process(void* object, const Event& event); 53 53 54 54 private: … … 59 59 int activeEvents_; 60 60 }; 61 62 template <class T> 63 class ClassEventContainer : public EventContainer 64 { 65 public: 66 ClassEventContainer(const std::string& eventname, ExecutorMember<T>* eventfunction, Identifier* subclass) : EventContainer(eventname, (Executor*)eventfunction, subclass), eventfunction_(eventfunction) {} 67 68 void process(void* object, const Event& event) 69 { 70 this->eventfunction_->setObject((T*)object); 71 EventContainer::process(object, event); 72 } 73 74 private: 75 ExecutorMember<T>* eventfunction_; 76 }; 61 77 } 62 78 -
code/branches/objecthierarchy/src/core/EventIncludes.h
r2066 r2069 49 49 if (!containername) \ 50 50 { \ 51 containername = new orxonox:: EventContainer(std::string(eventname), executor, orxonox::ClassIdentifier<subclassname>::getIdentifier()); \51 containername = new orxonox::ClassEventContainer<classname>(std::string(eventname), executor, orxonox::ClassIdentifier<subclassname>::getIdentifier()); \ 52 52 this->addEventContainer(eventname, containername); \ 53 53 } \
Note: See TracChangeset
for help on using the changeset viewer.