diff options
author | Stefan Radomski <github@mintwerk.de> | 2016-06-18 11:55:39 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2016-06-18 11:55:39 (GMT) |
commit | 0e0be07906a720ae54e4572d6ac0cb657424550d (patch) | |
tree | 7d48c87a9142a5dad06570ca4daf0212475d83f1 /src/uscxml/interpreter | |
parent | 84bbbd42c3480c40c0355c64899f99f8d588d5c0 (diff) | |
download | uscxml-0e0be07906a720ae54e4572d6ac0cb657424550d.zip uscxml-0e0be07906a720ae54e4572d6ac0cb657424550d.tar.gz uscxml-0e0be07906a720ae54e4572d6ac0cb657424550d.tar.bz2 |
Started to port Debugger and issue 87
Diffstat (limited to 'src/uscxml/interpreter')
-rw-r--r-- | src/uscxml/interpreter/BasicContentExecutor.cpp | 14 | ||||
-rw-r--r-- | src/uscxml/interpreter/BasicEventQueue.cpp | 20 | ||||
-rw-r--r-- | src/uscxml/interpreter/ContentExecutorImpl.h | 2 | ||||
-rw-r--r-- | src/uscxml/interpreter/FastMicroStep.cpp | 87 | ||||
-rw-r--r-- | src/uscxml/interpreter/FastMicroStep.h | 2 | ||||
-rw-r--r-- | src/uscxml/interpreter/InterpreterImpl.cpp | 2 | ||||
-rw-r--r-- | src/uscxml/interpreter/InterpreterImpl.h | 18 | ||||
-rw-r--r-- | src/uscxml/interpreter/InterpreterMonitor.h | 64 | ||||
-rw-r--r-- | src/uscxml/interpreter/MicroStepImpl.h | 5 |
9 files changed, 104 insertions, 110 deletions
diff --git a/src/uscxml/interpreter/BasicContentExecutor.cpp b/src/uscxml/interpreter/BasicContentExecutor.cpp index 58d3eae..0f5a67f 100644 --- a/src/uscxml/interpreter/BasicContentExecutor.cpp +++ b/src/uscxml/interpreter/BasicContentExecutor.cpp @@ -330,7 +330,7 @@ void BasicContentExecutor::process(XERCESC_NS::DOMElement* block, const X& xmlPr } try { - USCXML_MONITOR_CALLBACK1(_callbacks->getMonitor(), beforeExecutingContent, block); + USCXML_MONITOR_CALLBACK1(_callbacks->getMonitors(), beforeExecutingContent, block); if (false) { } else if (iequals(tagName, xmlPrefix.str() + "raise")) { @@ -358,12 +358,12 @@ void BasicContentExecutor::process(XERCESC_NS::DOMElement* block, const X& xmlPr Event e(exc); _callbacks->enqueueInternal(e); LOG(ERROR) << exc << std::endl; - USCXML_MONITOR_CALLBACK1(_callbacks->getMonitor(), afterExecutingContent, block); + USCXML_MONITOR_CALLBACK1(_callbacks->getMonitors(), afterExecutingContent, block); throw e; // will be catched in microstepper } - USCXML_MONITOR_CALLBACK1(_callbacks->getMonitor(), afterExecutingContent, block); + USCXML_MONITOR_CALLBACK1(_callbacks->getMonitors(), afterExecutingContent, block); } @@ -463,18 +463,18 @@ void BasicContentExecutor::invoke(XERCESC_NS::DOMElement* element) { finalize = finalizes.front(); } - USCXML_MONITOR_CALLBACK2(_callbacks->getMonitor(), beforeUninvoking, element, invokeEvent.invokeid); + USCXML_MONITOR_CALLBACK2(_callbacks->getMonitors(), beforeUninvoking, element, invokeEvent.invokeid); _callbacks->invoke(type, source, autoForward, finalize, invokeEvent); - USCXML_MONITOR_CALLBACK2(_callbacks->getMonitor(), afterUninvoking, element, invokeEvent.invokeid); + USCXML_MONITOR_CALLBACK2(_callbacks->getMonitors(), afterUninvoking, element, invokeEvent.invokeid); } void BasicContentExecutor::uninvoke(XERCESC_NS::DOMElement* invoke) { char* invokeId = (char*)invoke->getUserData(X("invokeid")); assert(invokeId != NULL); - USCXML_MONITOR_CALLBACK2(_callbacks->getMonitor(), beforeUninvoking, invoke, invokeId); + USCXML_MONITOR_CALLBACK2(_callbacks->getMonitors(), beforeUninvoking, invoke, invokeId); _callbacks->uninvoke(invokeId); - USCXML_MONITOR_CALLBACK2(_callbacks->getMonitor(), afterUninvoking, invoke, invokeId); + USCXML_MONITOR_CALLBACK2(_callbacks->getMonitors(), afterUninvoking, invoke, invokeId); invoke->setUserData(X("invokeid"), NULL, NULL); free(invokeId); diff --git a/src/uscxml/interpreter/BasicEventQueue.cpp b/src/uscxml/interpreter/BasicEventQueue.cpp index 7505f46..3cf4daf 100644 --- a/src/uscxml/interpreter/BasicEventQueue.cpp +++ b/src/uscxml/interpreter/BasicEventQueue.cpp @@ -37,24 +37,10 @@ Event BasicEventQueue::dequeue(size_t blockMs) { if (blockMs > 0) { // block for given milliseconds or until queue is filled - std::chrono::time_point<std::chrono::system_clock> updated, now; - std::chrono::milliseconds remain; + auto endTime = std::chrono::system_clock::now() + std::chrono::milliseconds(blockMs); - if (blockMs > (std::chrono::system_clock::duration::max)().count()) { - blockMs = (std::chrono::system_clock::duration::max)().count(); - } - - updated = now = std::chrono::system_clock::now(); - remain = std::chrono::milliseconds(blockMs); - - while (remain.count() > 0 && _queue.empty()) { - _cond.wait_for(_mutex, remain); - - now = std::chrono::system_clock::now(); - - auto elapsed = now - updated; - remain -= std::chrono::duration_cast<std::chrono::milliseconds>(elapsed); - updated = now; + while (_queue.empty()) { + _cond.wait_until(_mutex, endTime); } } diff --git a/src/uscxml/interpreter/ContentExecutorImpl.h b/src/uscxml/interpreter/ContentExecutorImpl.h index e1a7e8c..0e12aff 100644 --- a/src/uscxml/interpreter/ContentExecutorImpl.h +++ b/src/uscxml/interpreter/ContentExecutorImpl.h @@ -65,7 +65,7 @@ public: virtual const Event& getCurrentEvent() = 0; /** Monitoring */ - virtual InterpreterMonitor* getMonitor() = 0; + virtual std::set<InterpreterMonitor*> getMonitors() = 0; }; diff --git a/src/uscxml/interpreter/FastMicroStep.cpp b/src/uscxml/interpreter/FastMicroStep.cpp index ea43c5d..826df93 100644 --- a/src/uscxml/interpreter/FastMicroStep.cpp +++ b/src/uscxml/interpreter/FastMicroStep.cpp @@ -89,68 +89,66 @@ FastMicroStep::~FastMicroStep() { } } -void FastMicroStep::resortStates(DOMNode* node, const X& xmlPrefix) { - if (node->getNodeType() != DOMNode::ELEMENT_NODE) - return; +void FastMicroStep::resortStates(DOMElement* element, const X& xmlPrefix) { - /** + /** initials deep histories shallow histories everything else */ - DOMElement* element = dynamic_cast<DOMElement*>(node); + DOMElement* child = element->getFirstElementChild(); + while(child) { + resortStates(child, xmlPrefix); + child = child->getNextElementSibling(); + } // shallow history states to top - DOMNode* child = element->getFirstChild(); + child = element->getFirstElementChild(); while(child) { - resortStates(child, xmlPrefix); - if (child->getNodeType() == DOMNode::ELEMENT_NODE && - TAGNAME_CAST(child) == xmlPrefix.str() + "history" && - (!HAS_ATTR(element, "type") || iequals(ATTR(element, "type"), "shallow"))) { + if (TAGNAME_CAST(child) == xmlPrefix.str() + "history" && + (!HAS_ATTR(element, "type") || iequals(ATTR(element, "type"), "shallow"))) { - DOMNode* tmp = child->getNextSibling(); + DOMElement* tmp = child->getNextElementSibling(); if (child != element->getFirstChild()) { element->insertBefore(child, element->getFirstChild()); } child = tmp; } else { - child = child->getNextSibling(); + child = child->getNextElementSibling(); } } // deep history states to top - child = element->getFirstChild(); + child = element->getFirstElementChild(); while(child) { - resortStates(child, xmlPrefix); if (child->getNodeType() == DOMNode::ELEMENT_NODE && TAGNAME_CAST(child) == xmlPrefix.str() + "history" && HAS_ATTR(element, "type") && iequals(ATTR(element, "type"), "deep")) { - DOMNode* tmp = child->getNextSibling(); + DOMElement* tmp = child->getNextElementSibling(); if (child != element->getFirstChild()) { element->insertBefore(child, element->getFirstChild()); } child = tmp; } else { - child = child->getNextSibling(); + child = child->getNextElementSibling(); } } // initial states on top of histories even - child = element->getFirstChild(); + child = element->getFirstElementChild(); while(child) { - resortStates(child, xmlPrefix); if (child->getNodeType() == DOMNode::ELEMENT_NODE && LOCALNAME_CAST(child) == "initial") { - DOMNode* tmp = child->getNextSibling(); + DOMElement* tmp = child->getNextElementSibling(); if (child != element->getFirstChild()) { element->insertBefore(child, element->getFirstChild()); } child = tmp; } else { - child = child->getNextSibling(); + child = child->getNextElementSibling(); } } } @@ -193,10 +191,9 @@ void FastMicroStep::init(XERCESC_NS::DOMElement* scxml) { } resortStates(_scxml, _xmlPrefix); - - // TODO: https://github.com/tklab-tud/uscxml/blob/master/src/uscxml/transform/ChartToC.cpp#L244 - - +// assert(false); +// throw NULL; + /** -- All things states -- */ std::list<XERCESC_NS::DOMElement*> tmp; @@ -467,7 +464,7 @@ InterpreterState FastMicroStep::step(size_t blockMs) { return USCXML_FINISHED; if (_flags & USCXML_CTX_TOP_LEVEL_FINAL) { - USCXML_MONITOR_CALLBACK(_callbacks->getMonitor(), beforeCompletion); + USCXML_MONITOR_CALLBACK(_callbacks->getMonitors(), beforeCompletion); /* exit all remaining states */ i = USCXML_NUMBER_STATES; @@ -498,7 +495,7 @@ InterpreterState FastMicroStep::step(size_t blockMs) { _flags |= USCXML_CTX_FINISHED; - USCXML_MONITOR_CALLBACK(_callbacks->getMonitor(), afterCompletion); + USCXML_MONITOR_CALLBACK(_callbacks->getMonitors(), afterCompletion); return USCXML_FINISHED; } @@ -508,7 +505,7 @@ InterpreterState FastMicroStep::step(size_t blockMs) { targetSet |= USCXML_GET_STATE(0).completion; _flags |= USCXML_CTX_SPONTANEOUS | USCXML_CTX_INITIALIZED; - USCXML_MONITOR_CALLBACK(_callbacks->getMonitor(), beforeMicroStep); + USCXML_MONITOR_CALLBACK(_callbacks->getMonitors(), beforeMicroStep); goto ESTABLISH_ENTRYSET; } @@ -520,7 +517,7 @@ InterpreterState FastMicroStep::step(size_t blockMs) { if ((_event = _callbacks->dequeueInternal())) { - USCXML_MONITOR_CALLBACK1(_callbacks->getMonitor(), beforeProcessingEvent, _event); + USCXML_MONITOR_CALLBACK1(_callbacks->getMonitors(), beforeProcessingEvent, _event); goto SELECT_TRANSITIONS; } @@ -551,13 +548,13 @@ InterpreterState FastMicroStep::step(size_t blockMs) { // we dequeued all internal events and ought to signal stable configuration if (!(_flags & USCXML_CTX_STABLE)) { - USCXML_MONITOR_CALLBACK(_callbacks->getMonitor(), onStableConfiguration); + USCXML_MONITOR_CALLBACK(_callbacks->getMonitors(), onStableConfiguration); _microstepConfigurations.clear(); _flags |= USCXML_CTX_STABLE; } if ((_event = _callbacks->dequeueExternal(blockMs))) { - USCXML_MONITOR_CALLBACK1(_callbacks->getMonitor(), beforeProcessingEvent, _event); + USCXML_MONITOR_CALLBACK1(_callbacks->getMonitors(), beforeProcessingEvent, _event); goto SELECT_TRANSITIONS; } @@ -629,7 +626,7 @@ SELECT_TRANSITIONS: return USCXML_MACROSTEPPED; } - USCXML_MONITOR_CALLBACK(_callbacks->getMonitor(), beforeMicroStep); + USCXML_MONITOR_CALLBACK(_callbacks->getMonitors(), beforeMicroStep); #ifdef USCXML_VERBOSE std::cerr << "Targets: "; @@ -793,7 +790,7 @@ ESTABLISH_ENTRYSET: while(i-- > 0) { if (BIT_HAS(i, exitSet) && BIT_HAS(i, _configuration)) { - USCXML_MONITOR_CALLBACK1(_callbacks->getMonitor(), beforeExitingState, USCXML_GET_STATE(i).element); + USCXML_MONITOR_CALLBACK1(_callbacks->getMonitors(), beforeExitingState, USCXML_GET_STATE(i).element); /* call all on exit handlers */ for (auto exitIter = USCXML_GET_STATE(i).onExit.begin(); exitIter != USCXML_GET_STATE(i).onExit.end(); exitIter++) { @@ -805,7 +802,7 @@ ESTABLISH_ENTRYSET: } BIT_CLEAR(i, _configuration); - USCXML_MONITOR_CALLBACK1(_callbacks->getMonitor(), afterExitingState, USCXML_GET_STATE(i).element); + USCXML_MONITOR_CALLBACK1(_callbacks->getMonitors(), afterExitingState, USCXML_GET_STATE(i).element); } } @@ -814,7 +811,7 @@ ESTABLISH_ENTRYSET: i = transSet.find_first(); while(i != boost::dynamic_bitset<>::npos) { if ((USCXML_GET_TRANS(i).type & (USCXML_TRANS_HISTORY | USCXML_TRANS_INITIAL)) == 0) { - USCXML_MONITOR_CALLBACK1(_callbacks->getMonitor(), beforeTakingTransition, USCXML_GET_TRANS(i).element); + USCXML_MONITOR_CALLBACK1(_callbacks->getMonitors(), beforeTakingTransition, USCXML_GET_TRANS(i).element); if (USCXML_GET_TRANS(i).onTrans != NULL) { @@ -826,7 +823,7 @@ ESTABLISH_ENTRYSET: } } - USCXML_MONITOR_CALLBACK1(_callbacks->getMonitor(), afterTakingTransition, USCXML_GET_TRANS(i).element); + USCXML_MONITOR_CALLBACK1(_callbacks->getMonitors(), afterTakingTransition, USCXML_GET_TRANS(i).element); } i = transSet.find_next(i); @@ -856,7 +853,7 @@ ESTABLISH_ENTRYSET: continue; } - USCXML_MONITOR_CALLBACK1(_callbacks->getMonitor(), beforeEnteringState, USCXML_GET_STATE(i).element); + USCXML_MONITOR_CALLBACK1(_callbacks->getMonitors(), beforeEnteringState, USCXML_GET_STATE(i).element); BIT_SET_AT(i, _configuration); @@ -877,7 +874,7 @@ ESTABLISH_ENTRYSET: } } - USCXML_MONITOR_CALLBACK1(_callbacks->getMonitor(), afterEnteringState, USCXML_GET_STATE(i).element); + USCXML_MONITOR_CALLBACK1(_callbacks->getMonitors(), afterEnteringState, USCXML_GET_STATE(i).element); /* take history and initial transitions */ for (j = 0; j < USCXML_NUMBER_TRANS; j++) { @@ -885,7 +882,7 @@ ESTABLISH_ENTRYSET: (USCXML_GET_TRANS(j).type & (USCXML_TRANS_HISTORY | USCXML_TRANS_INITIAL)) && USCXML_GET_STATE(USCXML_GET_TRANS(j).source).parent == i) { - USCXML_MONITOR_CALLBACK1(_callbacks->getMonitor(), beforeTakingTransition, USCXML_GET_TRANS(j).element); + USCXML_MONITOR_CALLBACK1(_callbacks->getMonitors(), beforeTakingTransition, USCXML_GET_TRANS(j).element); /* call executable content in transition */ if (USCXML_GET_TRANS(j).onTrans != NULL) { @@ -896,7 +893,7 @@ ESTABLISH_ENTRYSET: } } - USCXML_MONITOR_CALLBACK1(_callbacks->getMonitor(), afterTakingTransition, USCXML_GET_TRANS(j).element); + USCXML_MONITOR_CALLBACK1(_callbacks->getMonitors(), afterTakingTransition, USCXML_GET_TRANS(j).element); } } @@ -941,15 +938,17 @@ ESTABLISH_ENTRYSET: } } } - USCXML_MONITOR_CALLBACK(_callbacks->getMonitor(), afterMicroStep); + USCXML_MONITOR_CALLBACK(_callbacks->getMonitors(), afterMicroStep); // are we running in circles? if (_microstepConfigurations.find(_configuration) != _microstepConfigurations.end()) { - USCXML_MONITOR_CALLBACK1(_callbacks->getMonitor(), + InterpreterIssue issue("Reentering same configuration during microstep - possible endless loop", + NULL, + InterpreterIssue::USCXML_ISSUE_WARNING); + + USCXML_MONITOR_CALLBACK1(_callbacks->getMonitors(), reportIssue, - InterpreterIssue("Reentering same configuration during microstep - possible endless loop", - NULL, - InterpreterIssue::USCXML_ISSUE_WARNING)); + issue); } _microstepConfigurations.insert(_configuration); diff --git a/src/uscxml/interpreter/FastMicroStep.h b/src/uscxml/interpreter/FastMicroStep.h index a3cdf9c..dd58480 100644 --- a/src/uscxml/interpreter/FastMicroStep.h +++ b/src/uscxml/interpreter/FastMicroStep.h @@ -125,7 +125,7 @@ protected: private: std::list<XERCESC_NS::DOMElement*> getHistoryCompletion(const XERCESC_NS::DOMElement* state); - void resortStates(XERCESC_NS::DOMNode* node, const X& xmlPrefix); + void resortStates(XERCESC_NS::DOMElement* node, const X& xmlPrefix); bool conflictsCached(const XERCESC_NS::DOMElement* t1, const XERCESC_NS::DOMElement* t2, const XERCESC_NS::DOMElement* root); ///< overrides implementation Predicates::conflicts for speed diff --git a/src/uscxml/interpreter/InterpreterImpl.cpp b/src/uscxml/interpreter/InterpreterImpl.cpp index 0547f12..5cbae3c 100644 --- a/src/uscxml/interpreter/InterpreterImpl.cpp +++ b/src/uscxml/interpreter/InterpreterImpl.cpp @@ -69,7 +69,7 @@ void InterpreterImpl::addInstance(std::shared_ptr<InterpreterImpl> interpreterIm _instances[interpreterImpl->getSessionId()] = interpreterImpl; } -InterpreterImpl::InterpreterImpl() : _isInitialized(false), _document(NULL), _scxml(NULL), _state(USCXML_INSTANTIATED), _monitor(NULL) { +InterpreterImpl::InterpreterImpl() : _isInitialized(false), _document(NULL), _scxml(NULL), _state(USCXML_INSTANTIATED) { try { ::xercesc_3_1::XMLPlatformUtils::Initialize(); } catch (const XERCESC_NS::XMLException& toCatch) { diff --git a/src/uscxml/interpreter/InterpreterImpl.h b/src/uscxml/interpreter/InterpreterImpl.h index be33306..6d047ec 100644 --- a/src/uscxml/interpreter/InterpreterImpl.h +++ b/src/uscxml/interpreter/InterpreterImpl.h @@ -97,10 +97,14 @@ public: return _microStepper.getConfiguration(); } - void setMonitor(InterpreterMonitor* monitor) { - _monitor = monitor; + void addMonitor(InterpreterMonitor* monitor) { + _monitors.insert(monitor); } + void removeMonitor(InterpreterMonitor* monitor) { + _monitors.erase(monitor); + } + /** MicrostepCallbacks */ @@ -132,8 +136,8 @@ public: _execContent.uninvoke(invoke); } - virtual InterpreterMonitor* getMonitor() { - return _monitor; + virtual std::set<InterpreterMonitor*> getMonitors() { + return _monitors; } /** @@ -255,7 +259,9 @@ protected: friend class InterpreterIssue; friend class TransformerImpl; friend class USCXMLInvoker; - friend class SCXMLIOProcessor; + friend class SCXMLIOProcessor; + friend class DebugSession; + friend class Debugger; X _xmlPrefix; X _xmlNS; @@ -280,7 +286,7 @@ protected: std::map<std::string, IOProcessor> _ioProcs; std::map<std::string, Invoker> _invokers; std::set<std::string> _autoForwarders; - InterpreterMonitor* _monitor; + std::set<InterpreterMonitor*> _monitors; private: void setupDOM(); diff --git a/src/uscxml/interpreter/InterpreterMonitor.h b/src/uscxml/interpreter/InterpreterMonitor.h index 8dac445..ff2e7cb 100644 --- a/src/uscxml/interpreter/InterpreterMonitor.h +++ b/src/uscxml/interpreter/InterpreterMonitor.h @@ -33,14 +33,14 @@ catch (std::bad_weak_ptr e) { LOG(ERROR) << "Unclean shutdown " << std::endl; } catch (...) { LOG(ERROR) << "An exception occurred when calling " #callback " on monitors"; } \ if (_state == USCXML_DESTROYED) { throw std::bad_weak_ptr(); } -#define USCXML_MONITOR_CALLBACK(callback, function) \ -if (callback) { callback->function(); } +#define USCXML_MONITOR_CALLBACK(callbacks, function) \ +for (auto callback : callbacks) { callback->function(NULL); } -#define USCXML_MONITOR_CALLBACK1(callback, function, arg1) \ -if (callback) { callback->function(arg1); } +#define USCXML_MONITOR_CALLBACK1(callbacks, function, arg1) \ +for (auto callback : callbacks) { callback->function(NULL, arg1); } -#define USCXML_MONITOR_CALLBACK2(callback, function, arg1, arg2) \ -if (callback) { callback->function(arg1, arg2); } +#define USCXML_MONITOR_CALLBACK2(callbacks, function, arg1, arg2) \ +for (auto callback : callbacks) { callback->function(NULL, arg1, arg2); } // forward declare namespace XERCESC_NS { @@ -54,34 +54,34 @@ public: InterpreterMonitor() : _copyToInvokers(false) {} virtual ~InterpreterMonitor() {} - virtual void beforeProcessingEvent(const Event& event) {} - virtual void beforeMicroStep() {} + virtual void beforeProcessingEvent(InterpreterImpl* impl, const Event& event) {} + virtual void beforeMicroStep(InterpreterImpl* impl) {} - virtual void beforeExitingState(const XERCESC_NS::DOMElement* state) {} - virtual void afterExitingState(const XERCESC_NS::DOMElement* state) {} + virtual void beforeExitingState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {} + virtual void afterExitingState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {} - virtual void beforeExecutingContent(const XERCESC_NS::DOMElement* execContent) {} - virtual void afterExecutingContent(const XERCESC_NS::DOMElement* execContent) {} + virtual void beforeExecutingContent(InterpreterImpl* impl, const XERCESC_NS::DOMElement* execContent) {} + virtual void afterExecutingContent(InterpreterImpl* impl, const XERCESC_NS::DOMElement* execContent) {} - virtual void beforeUninvoking(const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {} - virtual void afterUninvoking(const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {} + virtual void beforeUninvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {} + virtual void afterUninvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {} - virtual void beforeTakingTransition(const XERCESC_NS::DOMElement* transition) {} - virtual void afterTakingTransition(const XERCESC_NS::DOMElement* transition) {} + virtual void beforeTakingTransition(InterpreterImpl* impl, const XERCESC_NS::DOMElement* transition) {} + virtual void afterTakingTransition(InterpreterImpl* impl, const XERCESC_NS::DOMElement* transition) {} - virtual void beforeEnteringState(const XERCESC_NS::DOMElement* state) {} - virtual void afterEnteringState(const XERCESC_NS::DOMElement* state) {} + virtual void beforeEnteringState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {} + virtual void afterEnteringState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {} - virtual void beforeInvoking(const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {} - virtual void afterInvoking(const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {} + virtual void beforeInvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {} + virtual void afterInvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {} - virtual void afterMicroStep() {} - virtual void onStableConfiguration() {} + virtual void afterMicroStep(InterpreterImpl* impl) {} + virtual void onStableConfiguration(InterpreterImpl* impl) {} - virtual void beforeCompletion() {} - virtual void afterCompletion() {} + virtual void beforeCompletion(InterpreterImpl* impl) {} + virtual void afterCompletion(InterpreterImpl* impl) {} - virtual void reportIssue(const InterpreterIssue& issue) {} + virtual void reportIssue(InterpreterImpl* impl, const InterpreterIssue& issue) {} void copyToInvokers(bool copy) { _copyToInvokers = copy; @@ -101,13 +101,13 @@ public: StateTransitionMonitor() {} virtual ~StateTransitionMonitor() {} - virtual void beforeTakingTransition(const XERCESC_NS::DOMElement* transition); - virtual void beforeExecutingContent(const XERCESC_NS::DOMElement* element); - virtual void onStableConfiguration(); - virtual void beforeProcessingEvent(const uscxml::Event& event); - virtual void beforeExitingState(const XERCESC_NS::DOMElement* state); - virtual void beforeEnteringState(const XERCESC_NS::DOMElement* state); - virtual void beforeMicroStep(); + virtual void beforeTakingTransition(InterpreterImpl* impl, const XERCESC_NS::DOMElement* transition); + virtual void beforeExecutingContent(InterpreterImpl* impl, const XERCESC_NS::DOMElement* element); + virtual void onStableConfiguration(InterpreterImpl* impl); + virtual void beforeProcessingEvent(InterpreterImpl* impl, const uscxml::Event& event); + virtual void beforeExitingState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state); + virtual void beforeEnteringState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state); + virtual void beforeMicroStep(InterpreterImpl* impl); protected: static std::recursive_mutex _mutex; diff --git a/src/uscxml/interpreter/MicroStepImpl.h b/src/uscxml/interpreter/MicroStepImpl.h index be9d974..cb4aec6 100644 --- a/src/uscxml/interpreter/MicroStepImpl.h +++ b/src/uscxml/interpreter/MicroStepImpl.h @@ -23,6 +23,7 @@ #include "uscxml/config.h" #include <list> +#include <set> #include <string> #include <xercesc/dom/DOM.hpp> @@ -33,6 +34,8 @@ namespace uscxml { +class InterpreterMonitor; + /** * @ingroup microstep * @ingroup callback @@ -57,7 +60,7 @@ public: virtual void uninvoke(XERCESC_NS::DOMElement* invoke) = 0; /** Monitoring */ - virtual InterpreterMonitor* getMonitor() = 0; + virtual std::set<InterpreterMonitor*> getMonitors() = 0; }; /** |