19 #ifndef __MATHSCRIPT_H__    20 #define __MATHSCRIPT_H__    22 #include <../tools/fparser/fparser.h>    23 #include <csutil/csstring.h>    24 #include <csutil/hash.h>    25 #include <csutil/randomgen.h>    26 #include <csutil/set.h>    27 #include <csutil/strset.h>    29 #include <csutil/weakreferenced.h>    30 #include <csutil/weakref.h>    33 double round(
double value);
    38 struct iDataConnection;
    55     static csRandomGen 
rng;
    69 #ifdef CS_LITTLE_ENDIAN    70             CS_ALIGNED_MEMBER(uint32 value,1); 
    71             CS_ALIGNED_MEMBER(uint16 ignored,1); 
    72             CS_ALIGNED_MEMBER(uint16 mask,1); 
    74             CS_ALIGNED_MEMBER(uint16 mask,1); 
    75             CS_ALIGNED_MEMBER(uint16 ignored,1); 
    76             CS_ALIGNED_MEMBER(uint32 value,1); 
   110         return customCompoundFunctions.Request(name);
   116         return stringLiterals.Request(ID);
   125         ID.
ID.mask &= 0xFFF0;
   128         if(ID.
ID.mask != 0xFFF0)
   142         return stringLiterals.Request(str);
   167         return stringLiterals.Contains(str);
   177     static double RandomGen(
const double *dummy);
   180     static csString 
FormatMessage(
const csString& formatString, 
size_t arg_count, 
const double* parms);
   191     MathVar* GetVar(
const char* name);
   196     csHash<iScriptableVar*,uint32> scriptableVariables;
   198     csHash<uint32,iScriptableVar*> scriptableRegistry;
   204     csHash<MathVar*, csString> variables;
   224     void Define(
const char *name, 
double value);
   230     void Define(
const char *name, 
const char* str);
   239     csString GetString(
double id) 
const;
   250     MathVar* Lookup(
const char *name) 
const;
   251     void DumpAllVars() 
const;
   254     void InterpolateString(csString & str) 
const;
   276     typedef void (*MathScriptVarCallback)(
void* arg);
   282                                        changedVarCallback(NULL),
   283                                        changedVarCallbackArg(NULL)
   289         changedVarCallback = callback;
   290         changedVarCallbackArg = arg;
   293     void SetValue(
double v);
   295     void SetString(
const char* p);
   319     csString ToString() 
const;
   320     csString Dump() 
const;
   343         MATH_WHILE = MATH_COND | MATH_EXP | MATH_LOOP,
   344         MATH_IF    = MATH_COND | MATH_EXP,
   345         MATH_ELSE  = MATH_COND,
   346         MATH_DO    = MATH_EXP | MATH_LOOP
   352     bool Parse(
const char *expression);
   362             return (
object+
":"+property).GetHash();
   381     static MathExpression* Create(
const char *expression, 
const char *name = 
"");
   412     static MathStatement* Create(
const csString & expression, 
const char *name);
   450     static MathScript* Create(
const char *name, 
const csString & script);
 MathEnvironment(const MathEnvironment *parent)
csSet< csString > requiredObjs
a subset of requiredVars which are known to be objects; for type checking 
csHash< MathScript *, csString > scripts
static uint32 RequestID(const char *str)
request an ID for a string 
MathScriptEngine(iDataConnection *db, const csString &mathScriptTable)
csString assignee
variable the result will be assinged to 
static double RandomGen(const double *dummy)
rnd(limit) generates a random number between 0 and limit. 
const csString & Name() const 
csSet< csString > requiredVars
variables required to execute this expression 
csString GetString(double id) const 
retrieve a string literal based on it's id. 
This holds an empty statement that shall not be executed but is used for control flow statements...
A specific MathEnvironment to be used in a MathScript. 
A MathScript is a mini-program to run. 
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...
double Evaluate(MathEnvironment *) const 
iScriptableVar * GetPointer(double id) const 
retrieve a pointer to a scriptable object based on it's id. 
void UnloadScripts()
Cleans up all the script and data loaded. 
void * changedVarCallbackArg
MathScript * FindScript(const csString &name)
retrieve a MathScript given it's name. 
int GetRoundValue() const 
static csStringSet customCompoundFunctions
static csStringSet stringLiterals
The base expression class. 
static const char * Request(double f)
obtain a string literal based on it's masked value 
static double Request(const char *str)
request a masked value for a string 
csString GetString() const 
csArray< MathExpression * > scriptLines
MathVar(MathEnvironment *parent)
void SetChangedCallback(MathScriptVarCallback callback, void *arg)
iDataConnection * db
Global connection to the Database. Set from the psDatabase class. 
bool LoadScripts(iDataConnection *db, bool reload=false)
Loads all the scripts from the database. 
This holds information about a specific variable in a specific MathEnvironment to be used for MathScr...
MathScriptVarCallback changedVarCallback
bool operator<(const PropertyRef &rhs) const 
void ReloadScripts(iDataConnection *db)
Triggers a cleanup and reload of all the scripts. 
MathType
possible types of variables. 
void SetOpcode(size_t newOpcode)
iScriptableVar * GetObject() const 
csSet< PropertyRef > propertyRefs
properties that have to be resolved prior to evaluation 
MathScript(const char *name)
bool GetValue(const char *name)
This holds one line of a (potentially) multi-line script. 
static double CustomCompoundFunc(const double *parms)
internal function used for callbacks to scriptable objects from fparser. 
struct MathScriptEngine::IDConverter::@35 ID
virtual ~MathExpression()
static bool HasString(const char *str)
check whether a string is present in the global lookup table. 
static const char * Request(uint32 ID)
obtain a string literal based on it's actual ID 
This holds all the formulas loaded from the MathScript table and provides a container for them...
static CS::StringIDValue GetCompoundFunction(const csString &name)
retrieve the index of a custom compound function given it's name.