Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 3, 2009, 6:32:05 PM (15 years ago)
Author:
landauf
Message:

some cleanup in the eventsystem. not sure if everything still works, but there are more changes to come.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/libraries/core/BaseObject.h

    r5839 r5866  
    152152            virtual void changedGametype() {}
    153153
     154            void addEventSource(BaseObject* source, const std::string& state);
     155            void removeEventSource(BaseObject* source);
     156            BaseObject* getEventSource(unsigned int index, const std::string& state) const;
     157
    154158            void fireEvent();
    155159            void fireEvent(bool activate);
     
    159163            virtual void processEvent(Event& event);
    160164
    161             inline void registerEventListener(BaseObject* object, const std::string& sectionname)
    162                 { this->eventListeners_[object] = sectionname; }
    163             inline void unregisterEventListener(BaseObject* object)
    164                 { this->eventListeners_.erase(object); }
    165 
    166             void addEvent(BaseObject* event, const std::string& sectionname);
    167             void removeEvent(BaseObject* event);
    168             BaseObject* getEvent(unsigned int index) const;
    169 
    170             void addEventContainer(const std::string& sectionname, EventContainer* container);
    171             EventContainer* getEventContainer(const std::string& sectionname) const;
    172 
    173165            /** @brief Sets the indentation of the debug output in the Loader. @param indentation The indentation */
    174166            inline void setLoaderIndentation(const std::string& indentation) { this->loaderIndentation_ = indentation; }
     
    177169
    178170        protected:
     171            /** @brief Adds an object which listens to the events of this object. */
     172            inline void registerEventListener(BaseObject* object)
     173                { this->eventListeners_.insert(object); }
     174            /** @brief Removes an event listener from this object. */
     175            inline void unregisterEventListener(BaseObject* object)
     176                { this->eventListeners_.erase(object); }
     177
     178            void addEventContainer(const std::string& sectionname, EventContainer* container);
     179            EventContainer* getEventContainer(const std::string& sectionname) const;
     180
    179181            std::string name_;                                 //!< The name of the object
    180182            std::string oldName_;                              //!< The old name of the object
     
    197199            BaseObject*            creator_;
    198200            SmartPtr<Scene>        scene_;
     201            uint32_t               sceneID_;
    199202            SmartPtr<Gametype>     gametype_;
    200203            Gametype*              oldGametype_;
    201204            std::set<Template*>    templates_;
    202             std::map<BaseObject*,  std::string> eventListeners_;
    203             std::list<BaseObject*> events_;
    204             std::map<std::string, EventContainer*> eventContainers_;
    205             uint32_t               sceneID_;
     205           
     206            std::map<BaseObject*, std::string>      eventSources_;      //!< List of objects which send events to this object, mapped to the state which they affect
     207            std::set<BaseObject*>                   eventListeners_;    //!< List of objects which listen to the events of this object
     208            std::map<std::string, EventContainer*>  eventContainers_;
    206209    };
    207210
Note: See TracChangeset for help on using the changeset viewer.