InFact
Interpreter and factory for easily creating C++ objects at run-time
|
A partial implementation of the VarMapBase interface that is common to both VarMap<T> and the VarMap<vector<T> > partial specialization. More...
#include <environment.h>
Public Member Functions | |
VarMapImpl (const string &name, Environment *env, bool is_primitive=true) | |
virtual | ~VarMapImpl () |
bool | Get (const string &varname, T *value) const |
Assigns the value of the specified variable to the object pointed to by the value parameter. More... | |
virtual bool | Defined (const string &varname) const |
Returns whether the specified variable has a definition in this environment. More... | |
void | Set (const string &varname, T value) |
Sets the specified variable to the specified value. More... | |
virtual void | Print (ostream &os) const |
Prints out a human-readable string to the specified output stream containing the variables, their type and, if primitive, their values. More... | |
virtual VarMapBase * | Copy (Environment *env) const |
Returns a newly constructed copy of this VarMap. More... | |
Public Member Functions inherited from infact::VarMapBase | |
VarMapBase (const string &name, Environment *env, bool is_primitive) | |
Constructs a base class for a concrete implementation providing a mapping from variables of a particular type to their values. More... | |
virtual | ~VarMapBase () |
virtual bool | IsPrimitive () const |
Returns whether this instance contains primitive or primtive vector variables. More... | |
virtual const string & | Name () const |
Returns the type name of the variables of this instance. More... | |
virtual void | ReadAndSet (const string &varname, StreamTokenizer &st)=0 |
Reads the next value (primitive or spec for constructing a Factory-constructible object) from the specified stream tokenizer and sets the specified variable to that value. More... | |
Protected Member Functions | |
bool | ReadAndSetFromExistingVariable (const string &varname, StreamTokenizer &st) |
Checks if the next token is an identifier and is a variable in the environment, and, if so, sets varname to the variable’s value. More... | |
Environment * | env () |
A protected method to access the environment contained by this VarMapBase instance, for the two concrete VarMap implementations, below. More... | |
Protected Member Functions inherited from infact::VarMapBase | |
void | SetMembers (const string &name, Environment *env, bool is_primitive) |
To allow proper implementation of Copy in VarMapBase implementation, since we don't get copying of base class' members for free. More... | |
Additional Inherited Members | |
Protected Attributes inherited from infact::VarMapBase | |
string | name_ |
The type name of this VarMap. More... | |
Environment * | env_ |
The Environment that holds this VarMap instance. More... | |
bool | is_primitive_ |
Whether this VarMap instance holds variables of primitive type or vector of primitives. More... | |
A partial implementation of the VarMapBase interface that is common to both VarMap<T> and the VarMap<vector<T> > partial specialization.
In a delightful twist, this partial implementation of VarMapBase uses the curiously recurring template pattern (CRTP) in order to implement the VarMapBase::Copy method, as well as the protected method ReadAndSetFromExistingVariable.
T | the type of variables stored in this (partial implementation of a) variable map |
Derived | the type of the class using this as its base class (a.k.a. CRTP, or the "curiously recurring template pattern") |
Definition at line 266 of file environment.h.
|
inline |
Definition at line 268 of file environment.h.
|
inlinevirtual |
Definition at line 271 of file environment.h.
|
inlinevirtual |
Returns a newly constructed copy of this VarMap.
Implements infact::VarMapBase.
Definition at line 316 of file environment.h.
|
inlinevirtual |
Returns whether the specified variable has a definition in this environment.
Implements infact::VarMapBase.
Definition at line 291 of file environment.h.
|
inlineprotected |
A protected method to access the environment contained by this VarMapBase instance, for the two concrete VarMap implementations, below.
Definition at line 373 of file environment.h.
|
inline |
Assigns the value of the specified variable to the object pointed to by the value
parameter.
Definition at line 280 of file environment.h.
|
inlinevirtual |
Prints out a human-readable string to the specified output stream containing the variables, their type and, if primitive, their values.
Implements infact::VarMapBase.
Definition at line 301 of file environment.h.
|
inlineprotected |
Checks if the next token is an identifier and is a variable in the environment, and, if so, sets varname to the variable’s value.
Definition at line 329 of file environment.h.
|
inline |
Sets the specified variable to the specified value.
Definition at line 296 of file environment.h.