20 #ifndef INTERPRETERIMPL_H_2A79C83D
21 #define INTERPRETERIMPL_H_2A79C83D
44 class InterpreterMonitor;
45 class InterpreterIssue;
58 public std::enable_shared_from_this<InterpreterImpl> {
69 void cloneFrom(std::shared_ptr<InterpreterImpl> other);
71 virtual InterpreterState step(
size_t blockMs);
74 virtual void cancel();
76 virtual void deserialize(
const std::string& encodedState);
77 virtual std::string serialize();
79 InterpreterState getState() {
83 std::list<XERCESC_NS::DOMElement*> getConfiguration() {
84 return _microStepper.getConfiguration();
88 _monitors.insert(monitor);
92 _monitors.erase(monitor);
99 _currEvent = _internalQueue.dequeue(0);
101 _dataModel.setEvent(_currEvent);
104 virtual Event dequeueExternal(
size_t blockMs);
105 virtual bool isTrue(
const std::string& expr);
107 virtual void raiseDoneEvent(XERCESC_NS::DOMElement* state, XERCESC_NS::DOMElement* doneData) {
108 _execContent.raiseDoneEvent(state, doneData);
111 virtual void process(XERCESC_NS::DOMElement* block) {
112 _execContent.process(block);
115 virtual bool isMatched(
const Event& event,
const std::string& eventDesc);
116 virtual void initData(XERCESC_NS::DOMElement* element);
118 virtual void invoke(XERCESC_NS::DOMElement* invoke) {
119 _execContent.invoke(invoke);
122 virtual void uninvoke(XERCESC_NS::DOMElement* invoke) {
123 _execContent.uninvoke(invoke);
144 virtual const std::string& getSessionId() {
147 virtual const std::map<std::string, IOProcessor>& getIOProcessors() {
150 virtual const std::map<std::string, Invoker>& getInvokers() {
154 virtual bool isInState(
const std::string& stateId) {
155 return _microStepper.isInState(stateId);
157 virtual XERCESC_NS::DOMDocument* getDocument()
const {
166 return _internalQueue.enqueue(event);
168 virtual void enqueueExternal(
const Event& event) {
169 return _externalQueue.enqueue(event);
171 virtual void enqueueExternalDelayed(
const Event& event,
size_t delayMs,
const std::string& eventUUID) {
172 return _delayQueue.enqueueDelayed(event, delayMs, eventUUID);
174 virtual void cancelDelayed(
const std::string& eventId);
176 virtual size_t getLength(
const std::string& expr) {
177 return _dataModel.getLength(expr);
180 virtual void setForeach(
const std::string& item,
181 const std::string& array,
182 const std::string& index,
183 uint32_t iteration) {
184 return _dataModel.setForeach(item, array, index, iteration);
186 virtual Data evalAsData(
const std::string& expr) {
187 return _dataModel.evalAsData(expr);
190 virtual Data getAsData(
const std::string& expr) {
191 return _dataModel.getAsData(expr);
194 virtual void assign(
const std::string& location,
const Data& data,
const std::map<std::string, std::string>& attrs);
196 virtual std::string getInvokeId() {
199 virtual std::string getBaseURL() {
203 virtual bool checkValidSendType(
const std::string& type,
const std::string& target);
204 virtual void invoke(
const std::string& type,
const std::string& src,
bool autoForward, XERCESC_NS::DOMElement* finalize,
const Event& invokeEvent);
205 virtual void uninvoke(
const std::string& invokeId);
206 virtual void enqueue(
const std::string& type,
const std::string& target,
size_t delayMs,
const Event& sendEvent);
208 virtual const Event& getCurrentEvent() {
215 virtual void enqueueAtInvoker(
const std::string& invokeId,
const Event& event);
216 virtual void enqueueAtParent(
const Event& event);
222 virtual void eventReady(Event& event,
const std::string& eventUUID);
239 _al.execContent = _execContent;
240 _al.microStepper = _microStepper;
241 _al.dataModel = _dataModel;
242 _al.internalQueue = _internalQueue;
243 _al.externalQueue = _externalQueue;
244 _al.delayQueue = _delayQueue;
248 void setFactory(Factory* factory) {
252 virtual Logger getLogger() {
256 static std::map<std::string, std::weak_ptr<InterpreterImpl> > getInstances();
258 virtual XERCESC_NS::DOMDocument* getDocument() {
263 static void addInstance(std::shared_ptr<InterpreterImpl> instance);
268 std::string _sessionId;
270 std::string _invokeId;
273 XERCESC_NS::DOMDocument* _document;
274 XERCESC_NS::DOMElement* _scxml;
276 std::map<std::string, std::tuple<std::string, std::string, std::string> > _delayedEventTargets;
280 static std::map<std::string, std::weak_ptr<InterpreterImpl> > _instances;
281 static std::recursive_mutex _instanceMutex;
282 std::recursive_mutex _delayMutex;
283 std::recursive_mutex _serializationMutex;
285 friend class Interpreter;
286 friend class InterpreterIssue;
287 friend class TransformerImpl;
288 friend class USCXMLInvoker;
289 friend class SCXMLIOProcessor;
290 friend class DebugSession;
291 friend class Debugger;
293 std::string _xmlPrefix;
300 MicroStep _microStepper;
301 DataModel _dataModel;
302 ContentExecutor _execContent;
303 Logger _logger = Logger::getDefault();
305 InterpreterState _state;
307 EventQueue _internalQueue;
308 EventQueue _externalQueue;
309 EventQueue _parentQueue;
310 DelayedEventQueue _delayQueue;
315 std::map<std::string, IOProcessor> _ioProcs;
316 std::map<std::string, Invoker> _invokers;
317 std::map<std::string, XERCESC_NS::DOMElement*> _finalize;
318 std::set<std::string> _autoForwarders;
319 std::set<InterpreterMonitor*> _monitors;
EventQueue internalQueue
The queue where internal events will be enqueued.
Definition: Interpreter.h:59
Definition: Breakpoint.cpp:26
Definition: InterpreterMonitor.h:57
virtual Event dequeueInternal()
MicrostepCallbacks.
Definition: InterpreterImpl.h:98
Definition: MicroStepImpl.h:40
void setActionLanguage(const ActionLanguage &al)
Definition: InterpreterImpl.h:226
virtual void process(XERCESC_NS::DOMElement *block)
Executable Content.
Definition: InterpreterImpl.h:111
virtual std::set< InterpreterMonitor * > getMonitors()
Monitoring.
Definition: InterpreterImpl.h:126
Central class to interpret and process SCXML documents.
Definition: Interpreter.h:79
Definition: EventQueueImpl.h:53
EventQueue externalQueue
The queue for external events.
Definition: Interpreter.h:60
MicroStep microStepper
The microstepper instance to use.
Definition: Interpreter.h:56
virtual const std::string & getName()
DataModelCallbacks.
Definition: InterpreterImpl.h:141
Collection of instances for interpreter that constitute its action language.
Definition: Interpreter.h:53
DataModel dataModel
The datamodel to use.
Definition: Interpreter.h:57
Definition: InterpreterImpl.h:51
virtual void enqueueInternal(const Event &event)
ContentExecutorCallbacks.
Definition: InterpreterImpl.h:165
ContentExecutor execContent
To process executable content elements.
Definition: Interpreter.h:58
virtual Data & getCache()
Cache Data.
Definition: InterpreterImpl.h:134
Callbacks available for every invoker.
Definition: InvokerImpl.h:43
Logger logger
The logger instance to use for messages.
Definition: Interpreter.h:55
Callbacks available for every data-model.
Definition: DataModelImpl.h:47
Definition: ContentExecutorImpl.h:46
DelayedEventQueue delayQueue
The queue for delayed events.
Definition: Interpreter.h:61
virtual void invoke(XERCESC_NS::DOMElement *invoke)
Invocations.
Definition: InterpreterImpl.h:118
Callbacks available for every IO processor.
Definition: IOProcessorImpl.h:36