IMS2
Pre-Alpha
An Orbiter add-on to allow on-runtime construction of spacecraft from predefined modules
|
EventHandler base class. All classes that implement eventhandling must inherit from this class. More...
Public Member Functions | |
void | ConnectToMyEventGenerator (EventSink *sink, EVENTPIPE pipe) |
connects an EventSink to the EventGenerator of this in the appropriate pipe. More... | |
void | ConnectToMyEventSink (EventSink *sink, EVENTPIPE pipe) |
Connects an EventSink on this to the passed event sink. More... | |
void | ConnectMySinkToYourNode (EventNode *node, EVENTPIPE pipe) |
Connects an EventSink on this to the passed EventNode, no matter whether generator or another sink. More... | |
EVENTHANDLERTYPE | GetEventHandlerType () |
Returns the EVENTHANDLERTYPE of this event handler. | |
UINT | GetUID () |
Returns the globaly unique identifier of this event handler. | |
Protected Member Functions | |
EventGenerator * | createEventGenerator (EVENTPIPE pipe) |
Creates a new EventGenerator for this handler instance. More... | |
EventSink * | createEventSink (EVENTPIPE pipe) |
creates a new EventSink in this handler instance More... | |
void | disconnect (EventHandler *handler, bool bidirectional=true) |
Completely severs connections to and from the passed EventHandler, all sinks, all generators. More... | |
void | sendEvents () |
Tells all event generators in this event handler to advance their event cue. More... | |
void | processWaitingQueue () |
processes all events in the waiting queue. More... | |
void | addEvent (Event_Base *_event, EVENTPIPE _pipe=DEFAULT_PIPE) |
Adds an event to the eventcue of an eventpipe. More... | |
void | addEventToWaitingQueue (Event_Base *_event) |
Adds an event to this handlers waiting queue. More... | |
void | relayEvent (Event_Base *_event, EVENTPIPE _pipe) |
Relays an event to another event pipe. More... | |
EventSink * | getEventSink (EVENTPIPE pipe) |
returns the EventSink on this EventHandler that belongs to the passed event pipe More... | |
EventGenerator * | getEventGenerator (EVENTPIPE pipe) |
Returns the EventGenerator on this EventHandler that belongs to the passed event pipe. More... | |
virtual bool | ProcessEvent (Event_Base *e)=0 |
Receives all events coming through this EventHandler. More... | |
Protected Attributes | |
EVENTPIPE | defaultpipe = DEFAULT_PIPE |
Use this to set the defualt event pipe of this event handler. | |
EVENTHANDLERTYPE | eventhandlertype |
An identifier that offers a group identification. | |
Private Member Functions | |
void | createWaitingQueue () |
creates the generator and sink for the waiting queue More... | |
Private Attributes | |
UINT | uid |
Globally unique identier, handy mostly for debugging. | |
map< EVENTPIPE, EventGenerator * > | eventgenerators |
Stores the event generators of this EventHandler. | |
map< EVENTPIPE, EventSink * > | eventsinks |
Stores the EventSinks of this EventHandler. | |
EventGenerator * | waiting_queue = NULL |
The event generator dedicated to processing the waiting queue. | |
EventSink * | waiting_sink = NULL |
The event sink for the waiting queue. | |
Friends | |
class | EventSink |
EventHandler base class. All classes that implement eventhandling must inherit from this class.
For a more detailed description of the event engine as a whole, see the file documentation for EventHandler.h
|
protected |
Adds an event to the eventcue of an eventpipe.
_event | A pointer to an event. The memory will be freed by the event handler once the event has been processed |
_pipe | The event pipe the event should be added to. if _pipe == DEFAULT_PIPE, the event will be sent along this handlers default pipe (i.e. the first generator in the list). |
|
protected |
Adds an event to this handlers waiting queue.
The waiting queue is a dedicated event generator that will not generate its events when sendEvents() is called, but instead when processWaitingQueue is called.
_event | A pointer to an event. The memory will be freed by the event handler once the event has been processed. |
Connects an EventSink on this to the passed EventNode, no matter whether generator or another sink.
In short, this forms a connection in opposite direction from ConnectToMyEventGenerator and ConnectToMyEventSink
node | The EventGenerator the Sink on this should connect to |
pipe | The Eventpipe the Sink should be a part of. A sink of this pipe must be present on this! |
connects an EventSink to the EventGenerator of this in the appropriate pipe.
sink | The EventSink to be connected to an EventGenerator in this handler instance |
pipe | The event pipe the sink should hook into |
|
protected |
Creates a new EventGenerator for this handler instance.
pipe | The event pipe this generator services |
creates a new EventSink in this handler instance
pipe | The event pipe this sink should hook into |
|
private |
creates the generator and sink for the waiting queue
|
protected |
Completely severs connections to and from the passed EventHandler, all sinks, all generators.
handler | The EventHandler instance to disconnect |
bidirectional | Always pass true (default)! This argument is only used to call the function on the opposing handler. |
|
protected |
Returns the EventGenerator on this EventHandler that belongs to the passed event pipe.
pipe | The event pipe of which to retrieve the sink |
returns the EventSink on this EventHandler that belongs to the passed event pipe
pipe | The event pipe of which to retrieve the sink |
|
protectedpure virtual |
Receives all events coming through this EventHandler.
Overload to implement event handling in your inheriting class. The function will receive Events one by one as they are coming through your event sinks, regardless of which pipe they belong to. Return true to consume an event, but be sure it was only meant for you when you do that.
e | The event coming through the event pipe |
Implemented in IMS_Module, IMS_PropulsionManager, IMS_RcsManager, and IMS_ModuleFunction_Thruster.
|
protected |
processes all events in the waiting queue.
The waiting queue stands outside the normal event processing and will only be handled when this method is called. All events in the waiting queue will be processed, regardless of delay, and will be destroyed once finished. The waiting queue will only send events to this eventhandlers processEvent() method.
|
protected |
Relays an event to another event pipe.
Relaying means that the event will be propagated through the designated pipe IMMEDIATELY, but it will not be consumed by it. The event will still exist after its detour, which would not be the case if it was simply added to another event pipe with no delay
_event | The event to relay. |
_pipe | The event pipe the event should be relayed to. |
|
protected |
Tells all event generators in this event handler to advance their event cue.