AQUAgpusph 4.1.2
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions
Aqua::InputOutput::Variables Class Reference

Variables manager, which can interpret the types on the fly. More...

#include <Variable.h>

Public Member Functions

 Variables ()
 
 ~Variables ()
 
void registerVariable (const std::string name, const std::string type, const std::string length, const std::string value)
 
Variableget (unsigned int index)
 
Variableget (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 Public Member Functions

static size_t typeToBytes (const std::string type)
 
static unsigned int typeToN (const std::string type)
 

Detailed Description

Variables manager, which can interpret the types on the fly.

Constructor & Destructor Documentation

◆ Variables()

Aqua::InputOutput::Variables::Variables ( )

Constructor.

◆ ~Variables()

Aqua::InputOutput::Variables::~Variables ( )

Destructor.

Member Function Documentation

◆ 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
nameName 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
indexIndex 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_aFirst type name.
type_bSecond type name.
ignore_asterisktrue to ignore the asterisk of arrays.
Returns
true if it is the same type, false otherwise.
Here is the call graph for this function:

◆ 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
nameName of the variable to be populated, "" if all the variables should be populated.
Here is the call graph for this function:

◆ populate() [2/2]

void Aqua::InputOutput::Variables::populate ( Variable var)

Populate a variable in order that the tokenizer may know the updated value.

Parameters
varVariable to be populated.
Here is the call graph for this function:

◆ 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
nameName of the variable.
typeType of the variable.
lengthArray 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).
valueVariable value, NULL for arrays. It is optional for scalar variables.
Here is the call graph for this function:

◆ 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_nameType of the output desired value.
valueExpression to evaluate.
dataAllocated memory where the result should be stored.
nameVariable name to register in the tokenizer.
Note
typeToBytes(type) bytes should be allocated in data.
Here is the call graph for this function:

◆ typeToBytes()

size_t Aqua::InputOutput::Variables::typeToBytes ( const std::string  type)
static

Convert a type name to bytes.

Parameters
typeType name.
Returns
Type size in bytes, 0 if the type is not recognized.
Here is the call graph for this function:

◆ typeToN()

unsigned int Aqua::InputOutput::Variables::typeToN ( const std::string  type)
static

Get the number of components of a type name.

Parameters
typeType name.
Returns
Number of components (1 for not recognized types).

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