Variables manager, which can interpret the types on the fly.
More...
#include <Variable.h>
|
| Variables () |
|
| ~Variables () |
|
void | registerVariable (const std::string name, const std::string type, const std::string length, const std::string value) |
|
Variable * | get (unsigned int index) |
|
Variable * | get (const std::string name) |
|
std::vector< Variable * > | getAll () |
|
unsigned int | size () const |
|
size_t | allocatedMemory () |
|
bool | isSameType (const std::string type_a, const std::string type_b, bool ignore_asterisk=true) |
|
void | solve (const std::string type_name, const std::string value, void *data, const std::string name="NULL") |
|
void | populate (const std::string name="") |
| Populate variables in order that the tokenizer may get the updated value.
|
|
void | populate (Variable *var) |
| Populate a variable in order that the tokenizer may know the updated value.
|
|
|
static size_t | typeToBytes (const std::string type) |
|
static unsigned int | typeToN (const std::string type) |
|
Variables manager, which can interpret the types on the fly.
◆ Variables()
Aqua::InputOutput::Variables::Variables |
( |
| ) |
|
◆ ~Variables()
Aqua::InputOutput::Variables::~Variables |
( |
| ) |
|
◆ allocatedMemory()
size_t Aqua::InputOutput::Variables::allocatedMemory |
( |
| ) |
|
Get the allocated memory.
- Returns
- Allocated memory on device. Just the arrays can contribute to this value.
◆ get() [1/2]
Variable * Aqua::InputOutput::Variables::get |
( |
const std::string |
name | ) |
|
Get a variable.
- Parameters
-
name | Name of the variable. |
- Returns
- Variable, NULL if the variable cannot be found.
◆ get() [2/2]
Variable * Aqua::InputOutput::Variables::get |
( |
unsigned int |
index | ) |
|
Get a variable.
- Parameters
-
index | Index of the variable. |
- Returns
- Variable, NULL if the variable cannot be found.
◆ getAll()
std::vector< Variable * > Aqua::InputOutput::Variables::getAll |
( |
| ) |
|
|
inline |
Get all the registered variables.
- Returns
- Variable, NULL if the variable cannot be found.
◆ isSameType()
bool Aqua::InputOutput::Variables::isSameType |
( |
const std::string |
type_a, |
|
|
const std::string |
type_b, |
|
|
bool |
ignore_asterisk = true |
|
) |
| |
Get if two types strings are the same one.
- Parameters
-
type_a | First type name. |
type_b | Second type name. |
ignore_asterisk | true to ignore the asterisk of arrays. |
- Returns
- true if it is the same type, false otherwise.
◆ populate() [1/2]
void Aqua::InputOutput::Variables::populate |
( |
const std::string |
name = "" | ) |
|
Populate variables in order that the tokenizer may get the updated value.
- Parameters
-
name | Name of the variable to be populated, "" if all the variables should be populated. |
◆ populate() [2/2]
void Aqua::InputOutput::Variables::populate |
( |
Variable * |
var | ) |
|
Populate a variable in order that the tokenizer may know the updated value.
- Parameters
-
◆ registerVariable()
void Aqua::InputOutput::Variables::registerVariable |
( |
const std::string |
name, |
|
|
const std::string |
type, |
|
|
const std::string |
length, |
|
|
const std::string |
value |
|
) |
| |
Register a new variable.
- Parameters
-
name | Name of the variable. |
type | Type of the variable. |
length | Array length, 1 for scalars, 0 for arrays that will not be allocated at the start (for instance the heads of chains, which requires the number of cells). |
value | Variable value, NULL for arrays. It is optional for scalar variables. |
◆ size()
unsigned int Aqua::InputOutput::Variables::size |
( |
| ) |
const |
|
inline |
Get the number of variables.
- Returns
- Number of registered variables.
◆ solve()
void Aqua::InputOutput::Variables::solve |
( |
const std::string |
type_name, |
|
|
const std::string |
value, |
|
|
void * |
data, |
|
|
const std::string |
name = "NULL" |
|
) |
| |
Solve a string, interpreting the variables.
- Parameters
-
type_name | Type of the output desired value. |
value | Expression to evaluate. |
data | Allocated memory where the result should be stored. |
name | Variable name to register in the tokenizer. |
- Note
- typeToBytes(type) bytes should be allocated in data.
◆ typeToBytes()
size_t Aqua::InputOutput::Variables::typeToBytes |
( |
const std::string |
type | ) |
|
|
static |
Convert a type name to bytes.
- Parameters
-
- Returns
- Type size in bytes, 0 if the type is not recognized.
◆ typeToN()
unsigned int Aqua::InputOutput::Variables::typeToN |
( |
const std::string |
type | ) |
|
|
static |
Get the number of components of a type name.
- Parameters
-
- Returns
- Number of components (1 for not recognized types).
The documentation for this class was generated from the following files: