diff options
Diffstat (limited to 'src/uscxml/interpreter')
-rw-r--r-- | src/uscxml/interpreter/BasicContentExecutor.cpp | 1 | ||||
-rw-r--r-- | src/uscxml/interpreter/ContentExecutorImpl.h | 2 | ||||
-rw-r--r-- | src/uscxml/interpreter/InterpreterImpl.h | 8 | ||||
-rw-r--r-- | src/uscxml/interpreter/InterpreterMonitor.h | 69 | ||||
-rw-r--r-- | src/uscxml/interpreter/MicroStepImpl.h | 2 |
5 files changed, 44 insertions, 38 deletions
diff --git a/src/uscxml/interpreter/BasicContentExecutor.cpp b/src/uscxml/interpreter/BasicContentExecutor.cpp index 2582bb0..f85e2b8 100644 --- a/src/uscxml/interpreter/BasicContentExecutor.cpp +++ b/src/uscxml/interpreter/BasicContentExecutor.cpp @@ -18,6 +18,7 @@ */ #include "BasicContentExecutor.h" +#include "uscxml/Interpreter.h" #include "uscxml/util/String.h" #include "uscxml/util/Predicates.h" #include "uscxml/util/UUID.h" diff --git a/src/uscxml/interpreter/ContentExecutorImpl.h b/src/uscxml/interpreter/ContentExecutorImpl.h index d23b7be..ad4d695 100644 --- a/src/uscxml/interpreter/ContentExecutorImpl.h +++ b/src/uscxml/interpreter/ContentExecutorImpl.h @@ -66,7 +66,7 @@ public: /** Monitoring */ virtual std::set<InterpreterMonitor*> getMonitors() = 0; - virtual InterpreterImpl* getInterpreter() = 0; + virtual Interpreter getInterpreter() = 0; }; diff --git a/src/uscxml/interpreter/InterpreterImpl.h b/src/uscxml/interpreter/InterpreterImpl.h index 26f117d..d6dbd1a 100644 --- a/src/uscxml/interpreter/InterpreterImpl.h +++ b/src/uscxml/interpreter/InterpreterImpl.h @@ -50,8 +50,8 @@ class USCXML_API InterpreterImpl : public MicroStepCallbacks, public DataModelCallbacks, public ContentExecutorCallbacks, - public DelayedEventQueueCallbacks -// public std::enable_shared_from_this<InterpreterImpl> + public DelayedEventQueueCallbacks, + public std::enable_shared_from_this<InterpreterImpl> { public: enum Binding { @@ -140,8 +140,8 @@ public: return _monitors; } - virtual InterpreterImpl* getInterpreter() { - return this; + virtual Interpreter getInterpreter() { + return Interpreter(shared_from_this()); } /** diff --git a/src/uscxml/interpreter/InterpreterMonitor.h b/src/uscxml/interpreter/InterpreterMonitor.h index aae4296..10cc6ac 100644 --- a/src/uscxml/interpreter/InterpreterMonitor.h +++ b/src/uscxml/interpreter/InterpreterMonitor.h @@ -33,14 +33,17 @@ 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(callbacks, function) \ -for (auto callback : callbacks) { callback->function(_callbacks->getInterpreter()); } +#define USCXML_MONITOR_CALLBACK(callbacks, function) { \ +Interpreter inptr = _callbacks->getInterpreter(); \ +for (auto callback : callbacks) { callback->function(inptr); } } -#define USCXML_MONITOR_CALLBACK1(callbacks, function, arg1) \ -for (auto callback : callbacks) { callback->function(_callbacks->getInterpreter(), arg1); } +#define USCXML_MONITOR_CALLBACK1(callbacks, function, arg1) { \ +Interpreter inptr = _callbacks->getInterpreter(); \ +for (auto callback : callbacks) { callback->function(inptr, arg1); } } -#define USCXML_MONITOR_CALLBACK2(callbacks, function, arg1, arg2) \ -for (auto callback : callbacks) { callback->function(_callbacks->getInterpreter(), arg1, arg2); } +#define USCXML_MONITOR_CALLBACK2(callbacks, function, arg1, arg2) { \ +Interpreter inptr = _callbacks->getInterpreter(); \ +for (auto callback : callbacks) { callback->function(inptr, arg1, arg2); } } // forward declare namespace XERCESC_NS { @@ -49,39 +52,41 @@ namespace XERCESC_NS { namespace uscxml { +class Interpreter; + class USCXML_API InterpreterMonitor { public: InterpreterMonitor() : _copyToInvokers(false) {} virtual ~InterpreterMonitor() {} - virtual void beforeProcessingEvent(InterpreterImpl* impl, const Event& event) {} - virtual void beforeMicroStep(InterpreterImpl* impl) {} + virtual void beforeProcessingEvent(Interpreter& interpreter, const Event& event) {} + virtual void beforeMicroStep(Interpreter& interpreter) {} - virtual void beforeExitingState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {} - virtual void afterExitingState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {} + virtual void beforeExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {} + virtual void afterExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {} - virtual void beforeExecutingContent(InterpreterImpl* impl, const XERCESC_NS::DOMElement* execContent) {} - virtual void afterExecutingContent(InterpreterImpl* impl, const XERCESC_NS::DOMElement* execContent) {} + virtual void beforeExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* execContent) {} + virtual void afterExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* execContent) {} - 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 beforeUninvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {} + virtual void afterUninvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {} - virtual void beforeTakingTransition(InterpreterImpl* impl, const XERCESC_NS::DOMElement* transition) {} - virtual void afterTakingTransition(InterpreterImpl* impl, const XERCESC_NS::DOMElement* transition) {} + virtual void beforeTakingTransition(Interpreter& interpreter, const XERCESC_NS::DOMElement* transition) {} + virtual void afterTakingTransition(Interpreter& interpreter, const XERCESC_NS::DOMElement* transition) {} - virtual void beforeEnteringState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {} - virtual void afterEnteringState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {} + virtual void beforeEnteringState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {} + virtual void afterEnteringState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {} - 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 beforeInvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {} + virtual void afterInvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {} - virtual void afterMicroStep(InterpreterImpl* impl) {} - virtual void onStableConfiguration(InterpreterImpl* impl) {} + virtual void afterMicroStep(Interpreter& interpreter) {} + virtual void onStableConfiguration(Interpreter& interpreter) {} - virtual void beforeCompletion(InterpreterImpl* impl) {} - virtual void afterCompletion(InterpreterImpl* impl) {} + virtual void beforeCompletion(Interpreter& interpreter) {} + virtual void afterCompletion(Interpreter& interpreter) {} - virtual void reportIssue(InterpreterImpl* impl, const InterpreterIssue& issue) {} + virtual void reportIssue(Interpreter& interpreter, const InterpreterIssue& issue) {} void copyToInvokers(bool copy) { _copyToInvokers = copy; @@ -101,13 +106,13 @@ public: StateTransitionMonitor() {} virtual ~StateTransitionMonitor() {} - 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); + virtual void beforeTakingTransition(Interpreter& interpreter, const XERCESC_NS::DOMElement* transition); + virtual void beforeExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* element); + virtual void onStableConfiguration(Interpreter& interpreter); + virtual void beforeProcessingEvent(Interpreter& interpreter, const uscxml::Event& event); + virtual void beforeExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state); + virtual void beforeEnteringState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state); + virtual void beforeMicroStep(Interpreter& interpreter); protected: static std::recursive_mutex _mutex; diff --git a/src/uscxml/interpreter/MicroStepImpl.h b/src/uscxml/interpreter/MicroStepImpl.h index a9287aa..40f065c 100644 --- a/src/uscxml/interpreter/MicroStepImpl.h +++ b/src/uscxml/interpreter/MicroStepImpl.h @@ -61,7 +61,7 @@ public: /** Monitoring */ virtual std::set<InterpreterMonitor*> getMonitors() = 0; - virtual InterpreterImpl* getInterpreter() = 0; + virtual Interpreter getInterpreter() = 0; }; /** |