Schnek
schnek::BlockVariables Class Reference

#include <variables.hpp>

Public Member Functions

 BlockVariables (std::string name_, std::string className_, pBlockVariables parent_)
 Costruct using the block's name and class name.
 
bool exists (std::string name)
 returns true if the variable exists
 
pVariable getVariable (std::string name)
 
bool addVariable (std::string name, pVariable variable)
 
bool addChild (pBlockVariables child)
 
std::string getBlockName ()
 returns the block's name
 
std::string getClassName ()
 returns the block's class name
 
pBlockVariables getParent ()
 returns the parent (enclosing) block of this block
 
const BlockVariablesList & getChildren ()
 returns the children of the block
 
const VariableMap & getVariables ()
 returns the variables stored in the block
 

Detailed Description

Contains all the variables within a block together and is part of the block hierarchy

The children are those blocks contained within the block, the parent is the surrounding block. When searching for a variable, first the block itself is searched, then the parent blocks successively all the way to the root.

When a query contains a . the name is expanded to a block path

Member Function Documentation

◆ addChild()

bool BlockVariables::addChild ( pBlockVariables  child)

Adds a new child block Returns true on success and false if the block name already exists

◆ addVariable()

bool BlockVariables::addVariable ( std::string  name,
pVariable  variable 
)

Adds a new variable to the current block Returns true on success and false if the variable name already exists

◆ getVariable()

pVariable BlockVariables::getVariable ( std::string  name)

Returns the variable specified by the name. If the variable is not found, a fixed integer variable with value one is returned.

Use exists() to find out if the name is valid


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