IMS2  Pre-Alpha
An Orbiter add-on to allow on-runtime construction of spacecraft from predefined modules
EventGenerator Class Reference

EventGenerators take on events, equip them with additional information about the sender, and process them according to their urgency. More...

Inheritance diagram for EventGenerator:
EventNode

Private Member Functions

 EventGenerator (EventHandler *_host, EVENTPIPE _pipe)
 
void GenerateEvent (Event_Base *_event)
 Pass an event to this function to send it down the eventpipe. More...
 
bool RelayEvent (Event_Base *_event)
 Relays an event to this event pipe. More...
 
void ProcessEvents ()
 Goes through the event queue and sends out the events that are due. More...
 
bool processEvent (Event_Base *e)
 sends an event down the pipe of this generator. More...
 

Private Attributes

deque< Event_Base * > eventqueue
 The eventqueue, containing all events that are waiting to be sent out.
 
EVENTPIPE pipe
 Identifier of the event pipe this generator is part of.
 
bool ignoredelay = false
 

Friends

class EventHandler
 

Additional Inherited Members

- Protected Member Functions inherited from EventNode
void RegisterEventSink (EventSink *sink)
 registers an event sink as a child of this node More...
 
bool UnregisterEventSink (EventSink *sink)
 unregisters an event sink. More...
 
- Protected Attributes inherited from EventNode
EventHandlerhost
 The EventHandler hosting this EventNode.
 
vector< EventSink * > children
 The event nodes connecting directly to this EventNode.
 

Detailed Description

EventGenerators take on events, equip them with additional information about the sender, and process them according to their urgency.

Events that have no delay will be fed into the eventpipe immediately at the moment of their creation. Otherwise an event will be added to the generators event queue, which is advanced every time the ProcessEvents() method on the generator is called, which is called from EventHandler::sendEvents()).

This class is pure private. It cannot be instantiated or used directly. Instead, use the interface provided by EventHandler.

See also
EventHandler.h

Constructor & Destructor Documentation

EventGenerator::EventGenerator ( EventHandler _host,
EVENTPIPE  _pipe 
)
private
Parameters
_hostThe EventHandler instance that is hosting this EventGenerator
_pipeThe event pipe this generator should generate events for
ignoredelayA generator with this set to true will completely ignore event delays, always processing the whole queue at the next call to ProcessEvents().

Member Function Documentation

void EventGenerator::GenerateEvent ( Event_Base _event)
private

Pass an event to this function to send it down the eventpipe.

Depending whether the event is instantaneous or delayed, it gets processed immediately or added to the event queue, which will be emptied the next time ProcessEvents is called on this EventGenerator

Parameters
_eventThe event to be sent through the pipe
ignoredelayIf true, an event with delay 0 is not generated immediately and instead added to the event queue
Note
The _event pointer will be deallocated by the generator when it has finished its run through the pipe.
bool EventGenerator::processEvent ( Event_Base e)
privatevirtual

sends an event down the pipe of this generator.

Also receives the response when propagation has finished and deallocates the event..

Parameters
eThe event to be processed.
Note
All pointers to the event will be invalid after this call

Reimplemented from EventNode.

void EventGenerator::ProcessEvents ( )
private

Goes through the event queue and sends out the events that are due.

if an event is not due, it will stay in the queue until it is.

bool EventGenerator::RelayEvent ( Event_Base _event)
private

Relays an event to this event pipe.

The event pipes are the usual lines of communication. However, every now and then it may be necessary for an event to jump pipes. The necessity for this has to be determined by the ProcessEvent implementation of the respective EventHandler. Then the event can be relayed to another eventgenerator using this method, which will propagate the event instantly through its pipe. This means that the event will propagate through this entire pipe first, before propagation through the original pipe is resumed. RelayEvent will NOT delete the event even if it was consumed, but it will return whether the event was consumed. If it was, the relaying ProcessEvent implementation has to decide whether to consume the event itself or continue propagation through its own pipe.

Parameters
_eventThe event to be relayed.
Note
If you pass an event to this function that did not come from another eventpipe, you create a memory leak!

The documentation for this class was generated from the following files: