Changeset 5879 for code/branches/core5/src/libraries/core/BaseObject.h
- Timestamp:
- Oct 5, 2009, 5:02:25 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/core/BaseObject.h
r5866 r5879 37 37 #define _BaseObject_H__ 38 38 39 #define SetMainState(classname, statename, setfunction, getfunction) \40 if (this->getMainStateName() == statename) \41 { \42 this->functorSetMainState_ = createFunctor(&classname::setfunction, this); \43 this->functorGetMainState_ = createFunctor(&classname::getfunction, this); \44 }45 46 47 39 #include "CorePrereqs.h" 48 40 … … 69 61 virtual ~BaseObject(); 70 62 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 63 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 71 64 72 65 /** @brief Returns if the object was initialized (passed the object registration). @return True was the object is initialized */ … … 111 104 112 105 void setMainState(bool state); 113 bool getMainState() const; 114 115 void setMainStateName(const std::string& name); 106 107 /** @brief Sets the name of the main state (used for event reactions). */ 108 void setMainStateName(const std::string& name) 109 { 110 if (this->mainStateName_ != name) 111 { 112 this->mainStateName_ = name; 113 this->changedMainStateName(); 114 } 115 } 116 /** @brief Returns the name of the main state. */ 116 117 inline const std::string& getMainStateName() const { return this->mainStateName_; } 117 virtual void changedMainState(); 118 /** @brief This function gets called if the main state name of the object changes. */ 119 virtual void changedMainStateName(); 118 120 119 121 /** @brief Sets a pointer to the xml file that loaded this object. @param file The pointer to the XMLFile */ … … 176 178 { this->eventListeners_.erase(object); } 177 179 178 void addEvent Container(const std::string& sectionname, EventContainer* container);179 Event Container* getEventContainer(const std::string& sectionname) const;180 void addEventState(const std::string& name, EventState* container); 181 EventState* getEventState(const std::string& name) const; 180 182 181 183 std::string name_; //!< The name of the object … … 184 186 mbool bVisible_; //!< True = the object is visible 185 187 std::string mainStateName_; 186 Functor* functorSetMainState_; 187 Functor* functorGetMainState_; 188 Functor* mainStateFunctor_; 188 189 189 190 private: 190 191 void setXMLName(const std::string& name); 191 192 Template* getTemplate(unsigned int index) const; 193 void registerEventStates(); 192 194 193 195 bool bInitialized_; //!< True if the object was initialized (passed the object registration) … … 204 206 std::set<Template*> templates_; 205 207 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_; 208 std::map<BaseObject*, std::string> eventSources_; //!< List of objects which send events to this object, mapped to the state which they affect 209 std::set<BaseObject*> eventListeners_; //!< List of objects which listen to the events of this object 210 std::map<std::string, EventState*> eventStates_; //!< Maps the name of the event states to their helper objects 211 bool bRegisteredEventStates_; //!< Becomes true after the object registered its event states (with XMLEventPort) 209 212 }; 210 213 … … 212 215 SUPER_FUNCTION(2, BaseObject, changedActivity, false); 213 216 SUPER_FUNCTION(3, BaseObject, changedVisibility, false); 214 SUPER_FUNCTION(4, BaseObject, processEvent, false); 215 SUPER_FUNCTION(6, BaseObject, changedMainState, false); 216 SUPER_FUNCTION(9, BaseObject, changedName, false); 217 SUPER_FUNCTION(10, BaseObject, changedGametype, false); 217 SUPER_FUNCTION(4, BaseObject, XMLEventPort, false); 218 SUPER_FUNCTION(8, BaseObject, changedName, false); 219 SUPER_FUNCTION(9, BaseObject, changedGametype, false); 218 220 } 219 221
Note: See TracChangeset
for help on using the changeset viewer.