Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 30, 2008, 11:58:31 PM (16 years ago)
Author:
landauf
Message:

fixed a bug in the event system
fixed a bug in Trigger and tweaked some features

Location:
code/branches/objecthierarchy/src/core
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/core/BaseObject.cc

    r2065 r2069  
    217217    EventContainer* BaseObject::getEventContainer(const std::string& sectionname) const
    218218    {
    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);
    220220        if (it != this->eventContainers_.end())
    221221            return ((*it).second);
  • code/branches/objecthierarchy/src/core/Event.cc

    r2065 r2069  
    3838    }
    3939
    40     void EventContainer::process(BaseObject* object, const Event& event)
     40    void EventContainer::process(void* object, const Event& event)
    4141    {
    4242        if (this->eventname_ == event.sectionname_)
     
    4747                    ++this->activeEvents_;
    4848                else
     49                {
    4950                    --this->activeEvents_;
    5051
     52                    if (this->activeEvents_ < 0)
     53                        this->activeEvents_ = 0;
     54                }
     55
    5156                if (this->eventfunction_->getParamCount() == 0 && event.activate_)
    52                     (*this->eventfunction_)(object);
     57                    (*this->eventfunction_)();
    5358                else if ((this->activeEvents_ == 1 && event.activate_) || (this->activeEvents_ == 0 && !event.activate_))
    5459                {
    5560                    if (this->eventfunction_->getParamCount() == 1)
    56                         (*this->eventfunction_)(object, this->activeEvents_);
     61                        (*this->eventfunction_)(this->activeEvents_);
    5762                    else if (this->eventfunction_->getParamCount() >= 2 && event.castedOriginator_)
    58                         (*this->eventfunction_)(object, this->activeEvents_, event.castedOriginator_);
     63                        (*this->eventfunction_)(this->activeEvents_, event.castedOriginator_);
    5964                }
    6065            }
  • code/branches/objecthierarchy/src/core/Event.h

    r2065 r2069  
    4848        public:
    4949            EventContainer(const std::string& eventname, Executor* eventfunction, Identifier* subclass) : eventname_(eventname), eventfunction_(eventfunction), subclass_(subclass), activeEvents_(0) {}
    50             ~EventContainer();
     50            virtual ~EventContainer();
    5151
    52             void process(BaseObject* object, const Event& event);
     52            virtual void process(void* object, const Event& event);
    5353
    5454        private:
     
    5959            int activeEvents_;
    6060    };
     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    };
    6177}
    6278
  • code/branches/objecthierarchy/src/core/EventIncludes.h

    r2066 r2069  
    4949    if (!containername) \
    5050    { \
    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()); \
    5252        this->addEventContainer(eventname, containername); \
    5353    } \
Note: See TracChangeset for help on using the changeset viewer.