18 class VarBlockCreator;
39 d = std::move(other.d);
40 s = std::move(other.s);
55 return reinterpret_cast<double *&
>(
_dataPtrs[variableOffset]);
59 return reinterpret_cast<char **&
>(
_dataPtrs[variableOffset]);
70 std::vector<double>
d;
73 std::vector<char *>
s;
117 void eval(
const char **)
override
127 throw std::runtime_error(
"Already registered a variable named " + name);
131 _vars.insert(std::make_pair(name,
Ref(type, offset, type.
dim())));
153 auto it =
_vars.find(name);
154 if (it !=
_vars.end())
155 return const_cast<Ref*
>(&it->second);
abstract class for implementing variable references
virtual ExprType type() const
returns (current) type
Internally implemented var ref used by SeExpr.
Ref(const ExprType &type, uint32_t offset, uint32_t stride)
void eval(double *) override
returns this variable's value by setting result
void eval(const char **) override
A class that lets you register for the variables used by one or more expressions.
VarBlock create(bool makeThreadSafe=false) const
int registerVariable(const std::string &name, const ExprType &type)
Register a variable and return a handle.
ExprVarRef * resolveVar(const std::string &name) const
Resolve the variable using anything in the data block (call from resolveVar in Expr subclass)
std::map< std::string, Ref > _vars
A thread local evaluation context. Just allocate and fill in with data.
VarBlock(int size, bool makeThreadSafe)
Allocate an VarBlock.
VarBlock & operator=(VarBlock &&other)=delete
VarBlock(VarBlock &&other) noexcept
Move semantics is the only allowed way to change the structure.
int indirectIndex
indirect index to add to pointer based data
VarBlock(const VarBlock &)=delete
Don't allow copying and operator='ing'.
std::vector< char * > s
copy of Interpreter's str data
std::vector< char * > _dataPtrs
This stores double* or char** ptrs to variables.
std::vector< double > d
copy of Interpreter's double data
char ** data()
Raw data of the data block pointer (used by compiler)
VarBlock & operator=(const VarBlock &)=delete
bool threadSafe
if true, interpreter's data will be copied to this instance before evaluation.
double *& Pointer(uint32_t variableOffset)
Get a reference to the data block pointer which can be modified.
char **& CharPointer(uint32_t variableOffset)