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

Abstract base class for storing generic static data of module functions loaded from a config file. More...

Inheritance diagram for IMS_ModuleFunctionData_Base:
IMS_ModuleFunctionData_Animation IMS_ModuleFunctionData_Comm IMS_ModuleFunctionData_Gear IMS_ModuleFunctionData_Pressurised IMS_ModuleFunctionData_Thruster IMS_ModuleFunctionData_Tank IMS_ModuleFunctionData_Rcs

Public Member Functions

virtual bool LoadFromFile (string configfile, IMSFILE cfg)
 Loads the data from config file. More...
 
virtual bool HasGui ()
 This function serves to check whether a module function has a GUI before creating it. More...
 
FUNCTIONTYPE GetType ()
 
string GetName ()
 

Protected Member Functions

virtual bool processConfigLine (vector< string > &tokens)=0
 Receives all lines of the config file that concern this ModuleFunction one by one. More...
 
virtual bool validateData (string configfile)=0
 Validates the data for completeness after loading. More...
 

Protected Attributes

FUNCTIONTYPE type
 Stores the type of the ModuleFunction.
 
string name = ""
 Stores the Name of the ModuleFunction.
 

Detailed Description

Abstract base class for storing generic static data of module functions loaded from a config file.

Every derivative of IMS_ModuleFunction_Base() needs a corresponding derivative of this class to load and store its configfile data.

Module functions are specific abilities that can be added to a module in a config file, like thrusters, tanks, habitat etc. Many modules will have only one module function, but an arbitrary number of modulefunctions can be defined for any module.

Config structure:

An arbitrary number of module functions can be defined for any module. Any module function must be enclosed in a module function block like this:

BEGIN_MODULEFUNCTION <modulefunction-ID>
<modulefunction specific parameter>
.
.
END_MODULEFUNCTION

For a list of valid modulefunction ids, see the documentation for IMS_ModuleFunctionFactory.h

Generic modulefunction parameters

These parameters can be added to any module function

name = <string name> //a name for this module function type that will be used in various displays in the UI
See also
IMS_ModuleFunctionFactory.h

Member Function Documentation

string IMS_ModuleFunctionData_Base::GetName ( )
inline
Returns
The name of this ModuleFunction
FUNCTIONTYPE IMS_ModuleFunctionData_Base::GetType ( )
inline
Returns
The type of the ModuleFunction this data is for
virtual bool IMS_ModuleFunctionData_Base::HasGui ( )
inlinevirtual

This function serves to check whether a module function has a GUI before creating it.

Note
If your ModuleFunction has its own GUI, overload this function and return true, as simple as that.
Returns
Always false

Reimplemented in IMS_ModuleFunctionData_Thruster, IMS_ModuleFunctionData_Rcs, IMS_ModuleFunctionData_Gear, IMS_ModuleFunctionData_Tank, and IMS_ModuleFunctionData_Comm.

virtual bool IMS_ModuleFunctionData_Base::LoadFromFile ( string  configfile,
IMSFILE  cfg 
)
inlinevirtual

Loads the data from config file.

Parameters
configfileThe name of the config file
cfgThe config file itself, wrapped in an IMSFILE structure for oapi independency
Note
This function sends all lines concerning this ModuleFunction to processConfigLine() one by one. In general, it will be much easier to overload processConfigLine(). Overload this function only if you cannot practically load your data on a pure line by line basis.
Returns
True if loading was succesful, false otherwise
See also
processConfigLine()

Reimplemented in IMS_ModuleFunctionData_Animation.

virtual bool IMS_ModuleFunctionData_Base::processConfigLine ( vector< string > &  tokens)
protectedpure virtual

Receives all lines of the config file that concern this ModuleFunction one by one.

Overload this function to receive the relevant data of your module.

Parameters
tokensa vector of strings that contains the individual parts of the line, delimited by whitespace or '='
Note
Throw runtime_error with an error message if you encounter an invalid line! The message will be loged in Orbiter.log together with the name of the config file.
Returns
true if the passed line was processed, false if not.

Implemented in IMS_ModuleFunctionData_Animation, IMS_ModuleFunctionData_Thruster, IMS_ModuleFunctionData_Rcs, IMS_ModuleFunctionData_Gear, IMS_ModuleFunctionData_Tank, IMS_ModuleFunctionData_Comm, and IMS_ModuleFunctionData_Pressurised.

virtual bool IMS_ModuleFunctionData_Base::validateData ( string  configfile)
protectedpure virtual

Validates the data for completeness after loading.

Implement this function to validate your data at the end of the loading process. Check if everything's there that needs to be, and write log messages if it isn't.

Parameters
configfileThe name of the configfile, so you can add it to your messages so config writers find their mistakes faster.
Returns
False if the modulefunction is unable to function, otherwise return true.
Note
If your Implementation returns false, The loading process will be aborted by forcing orbiter to crash, so be sure to keep your loging straight!

Implemented in IMS_ModuleFunctionData_Animation, IMS_ModuleFunctionData_Thruster, IMS_ModuleFunctionData_Rcs, IMS_ModuleFunctionData_Gear, IMS_ModuleFunctionData_Tank, IMS_ModuleFunctionData_Comm, and IMS_ModuleFunctionData_Pressurised.


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