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

abstract class that defines the API for module functionalities. More...

Inheritance diagram for IMS_ModuleFunction_Base:
EventHandler IMS_ModuleFunction_Thruster

Public Member Functions

 IMS_ModuleFunction_Base (IMS_ModuleFunctionData_Base *_data, IMS_Module *_module, FUNCTIONTYPE _type)
 Constructor. More...
 
virtual void PostLoad ()=0
 called on SimStart, after LoadState() but before AddFunctionToVessel() More...
 
virtual void SaveState (FILEHANDLE scn)=0
 overload to save modulefunction specific stuff to scenario. More...
 
void LoadState (FILEHANDLE scn)
 Sends every scenario line concerning this modulefunction function to processScenarioLine(). More...
 
virtual void AddFunctionToVessel (IMS2 *vessel)=0
 Everything that needs to be done when the modulefunction is removed from a vessel should be implemented in an overload of this function. More...
 
virtual void RemoveFunctionFromVessel (IMS2 *vessel)=0
 Everything that needs to be done when the module is removed from a vessel should be implemented in an overload of this function. More...
 
virtual double GetMass ()
 Returns the current modulefunctions mass. More...
 
virtual void PreStep (double simdt, IMS2 *vessel)
 gets called at every clbkPreStep of the containing vessel. More...
 
virtual GUI_ModuleFunction_BaseGetGui ()
 returns the GUI of this module function, or NULL if this module function doesn't have a user interface. More...
 
IMS_ModuleGetModule ()
 
- Public Member Functions inherited from EventHandler
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

virtual bool processScenarioLine (string line)=0
 receives all scenario lines concerning this modulefunction, one after the other. More...
 
- Protected Member Functions inherited from EventHandler
EventGeneratorcreateEventGenerator (EVENTPIPE pipe)
 Creates a new EventGenerator for this handler instance. More...
 
EventSinkcreateEventSink (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...
 
EventSinkgetEventSink (EVENTPIPE pipe)
 returns the EventSink on this EventHandler that belongs to the passed event pipe More...
 
EventGeneratorgetEventGenerator (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

FUNCTIONTYPE type
 An identifier for the type of this module function.
 
IMS_Modulemodule = NULL
 Pointer to the IMS_Module containing this module function.
 
- Protected Attributes inherited from EventHandler
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 Attributes

IMS_ModuleFunctionData_Basedata
 Pointer to the config file data for this ModuleFunction.
 

Detailed Description

abstract class that defines the API for module functionalities.

A module function is an object that does things for a module which not every module must be capable of doing. In General, these things should have some relation to the Orbiter API. If this is not the case, the functionality should be implemented as a component instead (Compnent Interface not yet implemented, we'll get there...)

Note
Apart from defining the interface between its implementations and IMS_Module, it also handles registration of the EventHandler for the module function and abstracts loading states from scenario.

Constructor & Destructor Documentation

IMS_ModuleFunction_Base::IMS_ModuleFunction_Base ( IMS_ModuleFunctionData_Base _data,
IMS_Module _module,
FUNCTIONTYPE  _type 
)

Constructor.

Parameters
_datathe IMS_ModuleFunctionData object containing the static config data for this module function
_moduleThe IMS_Module object containing this module function
_typeAn identifer for the type of this module function

Member Function Documentation

virtual void IMS_ModuleFunction_Base::AddFunctionToVessel ( IMS2 *  vessel)
pure virtual

Everything that needs to be done when the modulefunction is removed from a vessel should be implemented in an overload of this function.

Parameters
vesselThe vessel the module is to be added to
Note
This function gets called every time the module is added to a new vessel, which happens on startup (whether loaded from scenario or not), at integration and at splitting.

Implemented in IMS_ModuleFunction_Thruster.

virtual GUI_ModuleFunction_Base* IMS_ModuleFunction_Base::GetGui ( )
inlinevirtual

returns the GUI of this module function, or NULL if this module function doesn't have a user interface.

Note
Overload this function to return the specific GUI of your module function, otherwise the core will think that the module function has no user input.

Reimplemented in IMS_ModuleFunction_Thruster.

virtual double IMS_ModuleFunction_Base::GetMass ( )
inlinevirtual

Returns the current modulefunctions mass.

Note
A ModuleFunction should only have a mass if that mass is not static.
So if you have for example a propellant tank, the propellant mass should be part of the ModuleFunction, while the mass of the tankage should not be.
IMS_Module* IMS_ModuleFunction_Base::GetModule ( )
inline
Returns
The module containing this ModuleFunction
void IMS_ModuleFunction_Base::LoadState ( FILEHANDLE  scn)

Sends every scenario line concerning this modulefunction function to processScenarioLine().

Parameters
scnthe FILEHANDLE to the opened scenario file
Note
Overload processScenarioLine() to implement loading from scenario!
See also
processScenarioLine()
Returns
virtual void IMS_ModuleFunction_Base::PostLoad ( )
pure virtual
void IMS_ModuleFunction_Base::PreStep ( double  simdt,
IMS2 *  vessel 
)
virtual

gets called at every clbkPreStep of the containing vessel.

Parameters
simdtelapsed time since the last frame
vesselthe vessel this module function belongs to

Reimplemented in IMS_ModuleFunction_Thruster.

virtual bool IMS_ModuleFunction_Base::processScenarioLine ( string  line)
protectedpure virtual

receives all scenario lines concerning this modulefunction, one after the other.

Parameters
lineA string object containing the line read from the scenario use this function to implement state initialisation when your module function is loaded from scenario

Implemented in IMS_ModuleFunction_Thruster.

virtual void IMS_ModuleFunction_Base::RemoveFunctionFromVessel ( IMS2 *  vessel)
pure virtual

Everything that needs to be done when the module is removed from a vessel should be implemented in an overload of this function.

Parameters
vesselThe vessel the module is being removed from
Note
This function only gets called on splitting, one frame before AddFunctionToVessel() is called to add it to the new vessel

Implemented in IMS_ModuleFunction_Thruster.

virtual void IMS_ModuleFunction_Base::SaveState ( FILEHANDLE  scn)
pure virtual

overload to save modulefunction specific stuff to scenario.

Parameters
scnthe FILEHANDLE to the opened scenario file
Note
The BEGIN_MODULEFUNC and END_MODULEFUNC tags are written by the module, so you really just have to write the data.

Implemented in IMS_ModuleFunction_Thruster.


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