AQUAgpusph 5.0.4
Loading...
Searching...
No Matches
Aqua::InputOutput::Variables Class Reference

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

#include <Variable.hpp>

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 () const
unsigned int size () const
size_t allocatedMemory ()
std::vector< Variable * > exprVariables (const std::string &expr)
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)
static bool isSameType (const std::string type_a, const std::string type_b, bool ignore_asterisk=true)
static std::string typeAlias (const std::string &t)
 Resolve some type aliases.

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.

◆ exprVariables()

std::vector< Variable * > Aqua::InputOutput::Variables::exprVariables ( const std::string & expr)

Get the list of variables called on a expression.

Parameters
exprExpression to parse.
Returns
The list of input variables.
See also
Aqua::Tokenizer::exprVariables()
Here is the call graph for this function:

◆ 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 ( ) const
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 )
static

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.

◆ 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:

◆ typeAlias()

std::string Aqua::InputOutput::Variables::typeAlias ( const std::string & t)
static

Resolve some type aliases.

Several types have aliases to make them easier to use, which might depend on the device arch:

  • "int32" = "int"
  • "int64" = "long"
  • "uint32" = "unsigned int"
  • "uint64" = "unsigned long"
  • "size_t" = Either "unsigned int" or "unsigned long"
  • "ssize_t" = Either "int" or "long"
  • "svec" = Either "uivec" or "ulvec"
  • "svec2" = Either "uivec2" or "ulvec2"
  • "svec3" = Either "uivec3" or "ulvec3"
  • "svec4" = Either "uivec4" or "ulvec4"
  • "svec8" = Either "uivec8" or "ulvec8"
  • "ssvec" = Either "ivec" or "lvec"
  • "ssvec2" = Either "ivec2" or "lvec2"
  • "ssvec3" = Either "ivec3" or "lvec3"
  • "ssvec4" = Either "ivec4" or "lvec4"
  • "ssvec8" = Either "ivec8" or "lvec8"
    Parameters
    tInput aliased type
    Returns
    Base type
    See also
    Aqua::CalcServer::CalcServer::device_addr_bits()
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).
Here is the call graph for this function:

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