Lua data-model. More...

#include <LuaDataModel.h>

Inheritance diagram for uscxml::LuaDataModel:
[legend]
Collaboration diagram for uscxml::LuaDataModel:
[legend]

Public Member Functions

virtual std::shared_ptr< DataModelImplcreate (DataModelCallbacks *callbacks)
 The Factory wants to instantiate a new instance. More...
 
virtual void addExtension (DataModelExtension *ext)
 
virtual std::list< std::string > getNames ()
 Return a list of names to be matched by the datamodel attribute in SCXML.
 
virtual bool isValidSyntax (const std::string &expr)
 Determine whether a given string constitutes valid syntax in the data-model's language. More...
 
virtual void setEvent (const Event &event)
 Set the given event as _event in the data-model's global scope. More...
 
virtual uint32_t getLength (const std::string &expr)
 
virtual void setForeach (const std::string &item, const std::string &array, const std::string &index, uint32_t iteration)
 
virtual bool evalAsBool (const std::string &expr)
 Evaluate a given expression as a boolean. More...
 
virtual Data evalAsData (const std::string &expr)
 Return a string as an evaluated Data object. More...
 
virtual Data getAsData (const std::string &content)
 Return a string as an unevaluated Data object. More...
 
virtual bool isDeclared (const std::string &expr)
 Determine whether a given variable / location is declared. More...
 
virtual void assign (const std::string &location, const Data &data)
 Assign a data object to a location in the data-model. More...
 
virtual void init (const std::string &location, const Data &data)
 Initialize a variable / location in the data-model with a given data object. More...
 
virtual std::string andExpressions (std::list< std::string >)
 
- Public Member Functions inherited from uscxml::DataModelImpl
size_t replaceExpressions (std::string &content)
 Experimental extension to have dynamic content in string literals. More...
 

Static Protected Member Functions

static int luaInFunction (lua_State *l)
 

Protected Attributes

lua_State * _luaState
 
- Protected Attributes inherited from uscxml::DataModelImpl
DataModelCallbacks_callbacks
 

Detailed Description

Lua data-model.

Member Function Documentation

void uscxml::LuaDataModel::assign ( const std::string &  location,
const Data data 
)
virtual

Assign a data object to a location in the data-model.

There are different occurences in the SCXML IRP tests, e.g.

test147:
  <data id="Var1" expr="0"/>

test150:
  <data id="Var3">
    [1,2,3]
  </data>

test277:
  <data id="Var1" expr="return"/>
Parameters
locationA variable or locatio to assign to.
dataThe Data object with the respective data.

Implements uscxml::DataModelImpl.

std::shared_ptr< DataModelImpl > uscxml::LuaDataModel::create ( DataModelCallbacks callbacks)
virtual

The Factory wants to instantiate a new instance.

This function will have to initialize the object. The actual constructor is called from within here. The only one who calls the constructor directly is the Factory for the prototype object.

Parameters
callbacksThe callbacks available to the datamodel
Returns
A shared pointer with an initialized instance

Implements uscxml::DataModelImpl.

bool uscxml::LuaDataModel::evalAsBool ( const std::string &  expr)
virtual

Evaluate a given expression as a boolean.

This function is a subset of evalAsData() but saves on creating and copying a Data object.

Parameters
exprAn expression in the data-model's language.
Returns
Whether the expression evaluates as true

Implements uscxml::DataModelImpl.

Data uscxml::LuaDataModel::evalAsData ( const std::string &  content)
virtual

Return a string as an evaluated Data object.

Parameters
contentA string with a literal, eppression or compound data-structure in the data-model's language.
Returns
An evaluated structure representing the given compound or literal.

Implements uscxml::DataModelImpl.

Data uscxml::LuaDataModel::getAsData ( const std::string &  content)
virtual

Return a string as an unevaluated Data object.

Parameters
contentA string with a literal, eppression or compound data-structure in the data-model's language.
Returns
An unevaluated structure representing the given compound or literal.

Implements uscxml::DataModelImpl.

void uscxml::LuaDataModel::init ( const std::string &  location,
const Data data 
)
virtual

Initialize a variable / location in the data-model with a given data object.

This is, semantically, very close to assign() but does not assume the location to be declared first.

Parameters
locationA variable or locatio to assign to.
dataThe Data object with the respective data.

Implements uscxml::DataModelImpl.

bool uscxml::LuaDataModel::isDeclared ( const std::string &  expr)
virtual

Determine whether a given variable / location is declared.

Parameters
exprThe variable / location to check.
Todo:
Is this still used?

Implements uscxml::DataModelImpl.

bool uscxml::LuaDataModel::isValidSyntax ( const std::string &  expr)
virtual

Determine whether a given string constitutes valid syntax in the data-model's language.

Parameters
exprA string, supposedly containing an expression of the data-model.
Returns
Whether expr is in L(DM).

Reimplemented from uscxml::DataModelImpl.

void uscxml::LuaDataModel::setEvent ( const Event event)
virtual

Set the given event as _event in the data-model's global scope.

Parameters
eventThe event as it was dequeued from either the internal or external queue.

Implements uscxml::DataModelImpl.


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