Central class to interpret and process SCXML documents. More...

#include <Interpreter.h>

Public Member Functions

void addMonitor (InterpreterMonitor *monitor)
 Attach a monitor to make more details of the interpreter observable.
 
void cancel ()
 Unblock and mark for finalize.
 
void deserialize (const std::string &encodedState)
 Deserialize the state for the interpreter from a string.
 
ActionLanguagegetActionLanguage ()
 Return ActionLanguage with the instances actually used (i.e. More...
 
std::list< XERCESC_NS::DOMElement * > getConfiguration ()
 Get all state elements that constitute the active configuration. More...
 
std::shared_ptr< InterpreterImplgetImpl () const
 Return the actual implementation of the Interperter.
 
Logger getLogger ()
 Return the logger associated with this interpreter.
 
InterpreterState getState ()
 The current state of the interpreter, not to be confused with its configuration. More...
 
bool isInState (const std::string &stateId)
 Determine whether the state with the given id is in the active configuration. More...
 
 PIMPL_OPERATORS (Interpreter)
 See PIMPL_OPERATORS macro in Common.h.
 
void receive (const Event &event)
 Enqueue an event to the interpreter's external queue. More...
 
void removeMonitor (InterpreterMonitor *monitor)
 Remove a monitor that was attached previously.
 
void reset ()
 Finalize and reset interpeter.
 
std::string serialize ()
 Serialize the interpreter's state in a string.
 
void setActionLanguage (ActionLanguage actionLanguage)
 Adapt the constituting components for a SCXML interpreter.
 
void setFactory (Factory *factory)
 Provide a custom Factory to instantiate dynamic instances for this and invoked state-chart instances.
 
InterpreterState step (size_t blockMs=std::numeric_limits< size_t >::max())
 Advance the state-machine by a single microstep and return. More...
 
std::list< InterpreterIssuevalidate ()
 Return a list of possible syntactic and semantic issues with the interpreter's state-chart. More...
 

Static Public Member Functions

static Interpreter fromClone (const Interpreter &other)
 Instantiate an Interpeter as a copy of another. More...
 
static Interpreter fromDocument (XERCESC_NS::DOMDocument *dom, const std::string &baseURL, bool copy=true)
 Instantiate an Interpeter with a given XML document. More...
 
static Interpreter fromElement (XERCESC_NS::DOMElement *element, const std::string &baseURL)
 Instantiate an Interpeter with a given XML element. More...
 
static Interpreter fromURL (const std::string &url)
 Instantiate an Interpeter with a document located at an URL. More...
 
static Interpreter fromXML (const std::string &xml, const std::string &baseURL)
 Instantiate an Interpeter from a string containined proper XML markup. More...
 

Protected Attributes

std::shared_ptr< InterpreterImpl_impl
 

Detailed Description

Instances of this class are available from the static constructors. In order to use an interpreter instance to actually do things, you will want to provide an ActionLanguage and an InterpreterMonitor.

We did avoid threading primitives within the core interpreter (there is threading for nested interpeters in the USCXMLInvoker, though). As such, you will have to call the <step> function continuously.

Member Function Documentation

static Interpreter uscxml::Interpreter::fromClone ( const Interpreter other)
static
Parameters
otherThe other interpreter.
Interpreter uscxml::Interpreter::fromDocument ( XERCESC_NS::DOMDocument *  dom,
const std::string &  baseURL,
bool  copy = true 
)
static
Parameters
domA pointer to the XML document.
baseURLAn absolute URL to resolve relative URLs in the document.
copyWhether to make a copy of the document, we deallocate it either way.
Interpreter uscxml::Interpreter::fromElement ( XERCESC_NS::DOMElement *  element,
const std::string &  baseURL 
)
static

This constructor will create a new document and copy/import the given element.

Parameters
elementThe element to be copies/imported as the new document element.
baseURLAn absolute URL to resolve relative URLs in the document.
Interpreter uscxml::Interpreter::fromURL ( const std::string &  url)
static
Parameters
urlAn absolute URL to locate the SCXML document.
Interpreter uscxml::Interpreter::fromXML ( const std::string &  xml,
const std::string &  baseURL 
)
static
Parameters
xmlTextual representation of an SCXML document.
baseURLAn absolute URL to resolve relative URLs in the document.
ActionLanguage * uscxml::Interpreter::getActionLanguage ( )

those from the factory).

std::list< XERCESC_NS::DOMElement * > uscxml::Interpreter::getConfiguration ( )
Returns
A list of XML elements of the active states.
InterpreterState uscxml::Interpreter::getState ( )
Returns
The current state of the interpreter object.
bool uscxml::Interpreter::isInState ( const std::string &  stateId)
Parameters
idAn identifier for a state from the SCXML document.
Returns
Whether the interpreter is in state id.
void uscxml::Interpreter::receive ( const Event event)

An event to be enqueued

InterpreterState uscxml::Interpreter::step ( size_t  blockMs = std::numeric_limits<size_t>::max())

This is the central function to drive the state machine. Calling step() will perform one microstep and return the current state of the interpreter. Here, the state is not to be confused with the interpreter's configuration.

InterpreterState state = uscxml::USCXML_UNDEF;
while((state = scxml.step()) != uscxml::USCXML_FINISHED) {
switch (state) {
case USCXML_MICROSTEPPED:
case USCXML_MACROSTEPPED:
/* Interpreter performed a microstep */
break;
default:
break;
}
}
Parameters
blockMsThe maximum duration in milli-seconds to wait for an event to become available.
Returns
The new state of the interpreter object.
std::list< InterpreterIssue > uscxml::Interpreter::validate ( )
Returns
A list of InterpreterIssues

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