Planeshift
MathScriptEngine Class Reference

This holds all the formulas loaded from the MathScript table and provides a container for them. More...

#include <mathscript.h>

Classes

union  IDConverter
 

Public Member Functions

MathScriptFindScript (const csString &name)
 retrieve a MathScript given it's name. More...
 
bool LoadScripts (iDataConnection *db, bool reload=false)
 Loads all the scripts from the database. More...
 
 MathScriptEngine (iDataConnection *db, const csString &mathScriptTable)
 
void ReloadScripts (iDataConnection *db)
 Triggers a cleanup and reload of all the scripts. More...
 
void UnloadScripts ()
 Cleans up all the script and data loaded. More...
 
 ~MathScriptEngine ()
 

Static Public Member Functions

static double CustomCompoundFunc (const double *parms)
 internal function used for callbacks to scriptable objects from fparser. More...
 
static csString FormatMessage (const csString &formatString, size_t arg_count, const double *parms)
 format a message using csString's Format given a string ID and a number of floating points. More...
 
static CS::StringIDValue GetCompoundFunction (const csString &name)
 retrieve the index of a custom compound function given it's name. More...
 
static bool HasString (const char *str)
 check whether a string is present in the global lookup table. More...
 
static double RandomGen (const double *dummy)
 rnd(limit) generates a random number between 0 and limit. More...
 
static const char * Request (uint32 ID)
 obtain a string literal based on it's actual ID More...
 
static const char * Request (double f)
 obtain a string literal based on it's masked value More...
 
static double Request (const char *str)
 request a masked value for a string More...
 
static uint32 RequestID (const char *str)
 request an ID for a string More...
 

Protected Attributes

csString mathScriptTable
 
csHash< MathScript *, csString > scripts
 

Static Protected Attributes

static csStringSet customCompoundFunctions
 
static csRandomGen rng
 
static csStringSet stringLiterals
 

Detailed Description

This holds all the formulas loaded from the MathScript table and provides a container for them.

It also enables adding of some needed functions not built-in to the formula parser. On top of that it may be used to format a message based on variables retrieved from a MathEnvironment.

Definition at line 51 of file mathscript.h.

Constructor & Destructor Documentation

MathScriptEngine::MathScriptEngine ( iDataConnection *  db,
const csString &  mathScriptTable 
)
MathScriptEngine::~MathScriptEngine ( )

Member Function Documentation

static double MathScriptEngine::CustomCompoundFunc ( const double *  parms)
static

internal function used for callbacks to scriptable objects from fparser.

do not call this manually.

MathScript* MathScriptEngine::FindScript ( const csString &  name)

retrieve a MathScript given it's name.

static csString MathScriptEngine::FormatMessage ( const csString &  formatString,
size_t  arg_count,
const double *  parms 
)
static

format a message using csString's Format given a string ID and a number of floating points.

static CS::StringIDValue MathScriptEngine::GetCompoundFunction ( const csString &  name)
inlinestatic

retrieve the index of a custom compound function given it's name.

for internal use only, do not call this manually.

Definition at line 108 of file mathscript.h.

static bool MathScriptEngine::HasString ( const char *  str)
inlinestatic

check whether a string is present in the global lookup table.

Definition at line 165 of file mathscript.h.

bool MathScriptEngine::LoadScripts ( iDataConnection *  db,
bool  reload = false 
)

Loads all the scripts from the database.

Returns
TRUE if it was possible to retrieve successfully the data.
static double MathScriptEngine::RandomGen ( const double *  dummy)
static

rnd(limit) generates a random number between 0 and limit.

void MathScriptEngine::ReloadScripts ( iDataConnection *  db)

Triggers a cleanup and reload of all the scripts.

static const char* MathScriptEngine::Request ( uint32  ID)
inlinestatic

obtain a string literal based on it's actual ID

Definition at line 114 of file mathscript.h.

static const char* MathScriptEngine::Request ( double  f)
inlinestatic

obtain a string literal based on it's masked value

Definition at line 120 of file mathscript.h.

static double MathScriptEngine::Request ( const char *  str)
inlinestatic

request a masked value for a string

Definition at line 146 of file mathscript.h.

static uint32 MathScriptEngine::RequestID ( const char *  str)
inlinestatic

request an ID for a string

Definition at line 140 of file mathscript.h.

void MathScriptEngine::UnloadScripts ( )

Cleans up all the script and data loaded.

Member Data Documentation

csStringSet MathScriptEngine::customCompoundFunctions
staticprotected

Definition at line 58 of file mathscript.h.

csString MathScriptEngine::mathScriptTable
protected

Definition at line 61 of file mathscript.h.

csRandomGen MathScriptEngine::rng
staticprotected

Definition at line 55 of file mathscript.h.

csHash<MathScript*, csString> MathScriptEngine::scripts
protected

Definition at line 54 of file mathscript.h.

csStringSet MathScriptEngine::stringLiterals
staticprotected

Definition at line 57 of file mathscript.h.


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