Planeshift
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes

MathScriptEngine Class Reference

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

#include <mathscript.h>

List of all members.

Classes

union  IDConverter

Public Member Functions

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

Static Public Member Functions

static double CustomCompoundFunc (const double *parms)
 internal function used for callbacks to scriptable objects from fparser.
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.
static CS::StringIDValue GetCompoundFunction (const csString &name)
 retrieve the index of a custom compound function given it's name.
static bool HasString (const char *str)
 check whether a string is present in the global lookup table.
static double RandomGen (const double *dummy)
 rnd(limit) generates a random number between 0 and limit.
static double Request (const char *str)
 request a masked value for a string
static const char * Request (uint32 ID)
 obtain a string literal based on it's actual ID
static const char * Request (double f)
 obtain a string literal based on it's masked value
static uint32 RequestID (const char *str)
 request an ID for a string

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) [inline, static]

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) [inline, static]

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 ( double  f) [inline, static]

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) [inline, static]

request a masked value for a string

Definition at line 146 of file mathscript.h.

static const char* MathScriptEngine::Request ( uint32  ID) [inline, static]

obtain a string literal based on it's actual ID

Definition at line 114 of file mathscript.h.

static uint32 MathScriptEngine::RequestID ( const char *  str) [inline, static]

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 [static, protected]

Definition at line 58 of file mathscript.h.

csString MathScriptEngine::mathScriptTable [protected]

Definition at line 61 of file mathscript.h.

csRandomGen MathScriptEngine::rng [static, protected]

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 [static, protected]

Definition at line 57 of file mathscript.h.


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