Namespace
A namespace of variables that can be accessed from formulas attached to it.
Members
-
ReadWriteMutex
mtx
— Mutex that governs reading and writing on this namespace.
int
lookup(
string&
name,
bool
create = true
)
Lookup the index of a variable in the namespace.
-
string&
name — Name of the variable.
-
bool
create — If true, create the variable if it does not exist.
Returns
int
: Index of the variable. -1 if it does not exist and was not created.
double
get(
string&
name
)
Get or calculate the value of a variable by name.
-
string&
name — Name of the variable.
Returns
double
: Value of that variable.
double
get(
int
index
)
Get or calculate the value of a variable by index.
-
int
index — Index of the variable.
Returns
double
: Value of that variable.
bool
has(
string&
name
)
-
string&
name — Name of the variable to check for.
Returns
bool
: True if a variable with this name exists.
void
setConstant(
string&
name,
double
value
)
Set a constant value for a variable.
-
string&
name — Name of the variable to set.
-
double
value — Value to set the variable to.
void
setFormula(
string&
name,
string&
formula
)
Set a formula to evaluate for a variable. Formula is evaluated in this namespace.
-
string&
name — Name of the variable to set.
-
string&
formula — Formula to set the variable to.
void
setFormula(
int
index,
string&
formula
)
Set a formula to evaluate for a variable. Formula is evaluated in this namespace.
-
int
index — Index of the variable to set.
-
string&
formula — Formula to set the variable to.