Changeset 5879 for code/branches/core5/src/libraries/core/Event.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/Event.h
r5866 r5879 35 35 namespace orxonox 36 36 { 37 /** 38 @brief The Event struct contains information about a fired Event. 39 */ 37 40 struct _CoreExport Event 38 41 { 39 Event(bool activate, BaseObject* originator) : activate_(activate), originator_(originator), castedOriginator_(0) {}42 Event(bool activate, BaseObject* originator) : activate_(activate), originator_(originator) {} 40 43 41 bool activate_; 42 BaseObject* originator_; 43 void* castedOriginator_; 44 std::string sectionname_; 44 bool activate_; //!< True if this is an activating event (the event source was inactive before and just triggered the event) - false otherwise 45 std::string statename_; //!< The name of the state this event affects 46 BaseObject* originator_; //!< The object which triggered this event 45 47 }; 46 48 47 class _CoreExport EventContainer 49 /** 50 @brief The EventState contains information about an event state. 51 52 An event state is a state of an object, which can be changed by events. 53 Event states are changed through functions. Possible functions headers for set event states are: 54 - memoryless state: function() 55 - boolean state: function(bool state) 56 - individual state: function(bool state, SomeClass originator) 57 58 Note that SomeClass may be any class deriving from BaseObject. You will not receive events from originators of other classes. 59 The actual class for SomeClass must be specified as the second argument of the XMLPortEventState macro. 60 61 The this pointer of the affected object is hidden in the functors, because the events are processed in the BaseObject, but some 62 statefunctions may be from child-classes. 63 */ 64 class _CoreExport EventState 48 65 { 49 66 public: 50 Event Container(const std::string& eventname, Functor* eventfunction, Identifier* subclass) : bActive_(false), eventname_(eventname), eventfunction_(eventfunction), subclass_(subclass), activeEvents_(0) {}51 virtual ~Event Container();67 EventState(Functor* statefunction, Identifier* subclass) : bProcessingEvent_(false), activeEvents_(0), statefunction_(statefunction), subclass_(subclass) {} 68 virtual ~EventState(); 52 69 53 void process(BaseObject* object, const Event& event); 70 void process(const Event& event, BaseObject* object); 71 72 Functor* getFunctor() const 73 { return this->statefunction_; } 54 74 55 75 private: 56 bool bActive_; 57 std::string eventname_; 58 Functor* eventfunction_; 59 Identifier* subclass_; 60 61 int activeEvents_; 76 bool bProcessingEvent_; //!< This becomes true while the container processes an event (used to prevent loops) 77 int activeEvents_; //!< The number of events which affect this state and are currently active 78 Functor* statefunction_; //!< A functor to set the state 79 Identifier* subclass_; //!< Originators must be an instance of this class (usually BaseObject, but some statefunctions allow a second argument with an originator of a specific class) 62 80 }; 63 81 }
Note: See TracChangeset
for help on using the changeset viewer.