summaryrefslogtreecommitdiffstats
path: root/src/uscxml
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2016-08-04 21:57:18 (GMT)
committerStefan Radomski <github@mintwerk.de>2016-08-04 21:57:18 (GMT)
commitdb8418fb9f733ca0147cc225ce0988d7866f15cd (patch)
treed24805c2a17bc01a408d89f7675f66806879fb59 /src/uscxml
parentad2653c30b78b2951eb79d303a9e3ab52f4a2def (diff)
downloaduscxml-db8418fb9f733ca0147cc225ce0988d7866f15cd.zip
uscxml-db8418fb9f733ca0147cc225ce0988d7866f15cd.tar.gz
uscxml-db8418fb9f733ca0147cc225ce0988d7866f15cd.tar.bz2
Changed Monitor signature to take Interpreter facade
Diffstat (limited to 'src/uscxml')
-rw-r--r--src/uscxml/Interpreter.cpp14
-rw-r--r--src/uscxml/debug/Debugger.cpp91
-rw-r--r--src/uscxml/debug/Debugger.h51
-rw-r--r--src/uscxml/interpreter/BasicContentExecutor.cpp1
-rw-r--r--src/uscxml/interpreter/ContentExecutorImpl.h2
-rw-r--r--src/uscxml/interpreter/InterpreterImpl.h8
-rw-r--r--src/uscxml/interpreter/InterpreterMonitor.h69
-rw-r--r--src/uscxml/interpreter/MicroStepImpl.h2
8 files changed, 126 insertions, 112 deletions
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index c16b70c..1d348fd 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -246,19 +246,19 @@ static void printNodeSet(const std::list<XERCESC_NS::DOMElement*> nodes) {
}
#endif
-void StateTransitionMonitor::beforeTakingTransition(InterpreterImpl* impl, const XERCESC_NS::DOMElement* transition) {
+void StateTransitionMonitor::beforeTakingTransition(Interpreter& interpreter, const XERCESC_NS::DOMElement* transition) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
std::cerr << "Transition: " << uscxml::DOMUtils::xPathForNode(transition) << std::endl;
}
-void StateTransitionMonitor::onStableConfiguration(InterpreterImpl* impl) {
+void StateTransitionMonitor::onStableConfiguration(Interpreter& interpreter) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
std::cerr << "Stable Config: { ";
// printNodeSet(_interpreter.getConfiguration());
std::cerr << " }" << std::endl;
}
-void StateTransitionMonitor::beforeProcessingEvent(InterpreterImpl* impl, const uscxml::Event& event) {
+void StateTransitionMonitor::beforeProcessingEvent(Interpreter& interpreter, const uscxml::Event& event) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
switch (event.eventType) {
case uscxml::Event::INTERNAL:
@@ -273,23 +273,23 @@ void StateTransitionMonitor::beforeProcessingEvent(InterpreterImpl* impl, const
}
}
-void StateTransitionMonitor::beforeExecutingContent(InterpreterImpl* impl, const XERCESC_NS::DOMElement* element) {
+void StateTransitionMonitor::beforeExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* element) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
std::cerr << "Executable Content: " << DOMUtils::xPathForNode(element) << std::endl;
}
-void StateTransitionMonitor::beforeExitingState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {
+void StateTransitionMonitor::beforeExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
std::cerr << "Exiting: " << (HAS_ATTR(state, "id") ? ATTR(state, "id") : DOMUtils::xPathForNode(state)) << std::endl;
}
-void StateTransitionMonitor::beforeEnteringState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {
+void StateTransitionMonitor::beforeEnteringState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
std::cerr << "Entering: " << (HAS_ATTR(state, "id") ? ATTR(state, "id") : DOMUtils::xPathForNode(state)) << std::endl;
}
-void StateTransitionMonitor::beforeMicroStep(InterpreterImpl* impl) {
+void StateTransitionMonitor::beforeMicroStep(Interpreter& interpreter) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
std::cerr << "Config: {";
// printNodeSet(_interpreter.getConfiguration());
diff --git a/src/uscxml/debug/Debugger.cpp b/src/uscxml/debug/Debugger.cpp
index 09c21e7..1f13e40 100644
--- a/src/uscxml/debug/Debugger.cpp
+++ b/src/uscxml/debug/Debugger.cpp
@@ -24,7 +24,8 @@
namespace uscxml {
-void Debugger::afterCompletion(InterpreterImpl* impl) {
+void Debugger::afterCompletion(Interpreter& interpreter) {
+ InterpreterImpl* impl = interpreter.getImpl().get();
std::shared_ptr<DebugSession> session = getSession(impl);
if (!session)
return;
@@ -34,7 +35,7 @@ void Debugger::afterCompletion(InterpreterImpl* impl) {
pushData(session, msg);
}
-void Debugger::beforeCompletion(InterpreterImpl* impl) {}
+void Debugger::beforeCompletion(Interpreter& interpreter) {}
std::list<Breakpoint> Debugger::getQualifiedStateBreakpoints(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state, Breakpoint breakpointTemplate) {
std::list<Breakpoint> breakpoints;
@@ -87,59 +88,59 @@ std::list<Breakpoint> Debugger::getQualifiedTransBreakpoints(InterpreterImpl* im
return breakpoints;
}
-void Debugger::beforeTakingTransition(InterpreterImpl* impl, const XERCESC_NS::DOMElement* transition) {
- handleTransition(impl, transition, Breakpoint::BEFORE);
+void Debugger::beforeTakingTransition(Interpreter& interpreter, const XERCESC_NS::DOMElement* transition) {
+ handleTransition(interpreter, transition, Breakpoint::BEFORE);
}
-void Debugger::afterTakingTransition(InterpreterImpl* impl, const XERCESC_NS::DOMElement* transition) {
- handleTransition(impl, transition, Breakpoint::AFTER);
+void Debugger::afterTakingTransition(Interpreter& interpreter, const XERCESC_NS::DOMElement* transition) {
+ handleTransition(interpreter, transition, Breakpoint::AFTER);
}
-void Debugger::beforeExecutingContent(InterpreterImpl* impl, const XERCESC_NS::DOMElement* execContent) {
- handleExecutable(impl, execContent, Breakpoint::BEFORE);
+void Debugger::beforeExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* execContent) {
+ handleExecutable(interpreter, execContent, Breakpoint::BEFORE);
}
-void Debugger::afterExecutingContent(InterpreterImpl* impl, const XERCESC_NS::DOMElement* execContent) {
- handleExecutable(impl, execContent, Breakpoint::AFTER);
+void Debugger::afterExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* execContent) {
+ handleExecutable(interpreter, execContent, Breakpoint::AFTER);
}
-void Debugger::beforeExitingState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {
- handleState(impl, state, Breakpoint::BEFORE, Breakpoint::EXIT);
+void Debugger::beforeExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {
+ handleState(interpreter, state, Breakpoint::BEFORE, Breakpoint::EXIT);
}
-void Debugger::afterExitingState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {
- handleState(impl, state, Breakpoint::AFTER, Breakpoint::EXIT);
+void Debugger::afterExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {
+ handleState(interpreter, state, Breakpoint::AFTER, Breakpoint::EXIT);
}
-void Debugger::beforeEnteringState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {
- handleState(impl, state, Breakpoint::BEFORE, Breakpoint::ENTER);
+void Debugger::beforeEnteringState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {
+ handleState(interpreter, state, Breakpoint::BEFORE, Breakpoint::ENTER);
}
-void Debugger::afterEnteringState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {
- handleState(impl, state, Breakpoint::AFTER, Breakpoint::ENTER);
+void Debugger::afterEnteringState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {
+ handleState(interpreter, state, Breakpoint::AFTER, Breakpoint::ENTER);
}
-void Debugger::beforeUninvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {
- handleInvoke(impl, invokeElem, invokeid, Breakpoint::BEFORE, Breakpoint::UNINVOKE);
+void Debugger::beforeUninvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {
+ handleInvoke(interpreter, invokeElem, invokeid, Breakpoint::BEFORE, Breakpoint::UNINVOKE);
}
-void Debugger::afterUninvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {
- handleInvoke(impl, invokeElem, invokeid, Breakpoint::AFTER, Breakpoint::UNINVOKE);
+void Debugger::afterUninvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {
+ handleInvoke(interpreter, invokeElem, invokeid, Breakpoint::AFTER, Breakpoint::UNINVOKE);
}
-void Debugger::beforeInvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {
- handleInvoke(impl, invokeElem, invokeid, Breakpoint::BEFORE, Breakpoint::INVOKE);
+void Debugger::beforeInvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {
+ handleInvoke(interpreter, invokeElem, invokeid, Breakpoint::BEFORE, Breakpoint::INVOKE);
}
-void Debugger::afterInvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {
- handleInvoke(impl, invokeElem, invokeid, Breakpoint::AFTER, Breakpoint::INVOKE);
+void Debugger::afterInvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid) {
+ handleInvoke(interpreter, invokeElem, invokeid, Breakpoint::AFTER, Breakpoint::INVOKE);
}
-void Debugger::onStableConfiguration(InterpreterImpl* impl) {
- handleStable(impl, Breakpoint::ON);
+void Debugger::onStableConfiguration(Interpreter& interpreter) {
+ handleStable(interpreter, Breakpoint::ON);
}
-void Debugger::beforeMicroStep(InterpreterImpl* impl) {
- handleMicrostep(impl, Breakpoint::BEFORE);
+void Debugger::beforeMicroStep(Interpreter& interpreter) {
+ handleMicrostep(interpreter, Breakpoint::BEFORE);
}
-void Debugger::afterMicroStep(InterpreterImpl* impl) {
- handleMicrostep(impl, Breakpoint::AFTER);
+void Debugger::afterMicroStep(Interpreter& interpreter) {
+ handleMicrostep(interpreter, Breakpoint::AFTER);
}
-void Debugger::beforeProcessingEvent(InterpreterImpl* impl, const Event& event) {
- handleEvent(impl, event, Breakpoint::BEFORE);
+void Debugger::beforeProcessingEvent(Interpreter& interpreter, const Event& event) {
+ handleEvent(interpreter, event, Breakpoint::BEFORE);
}
-void Debugger::handleExecutable(InterpreterImpl* impl,
+void Debugger::handleExecutable(Interpreter& interpreter,
const XERCESC_NS::DOMElement* execContentElem,
Breakpoint::When when) {
- std::shared_ptr<DebugSession> session = getSession(impl);
+ std::shared_ptr<DebugSession> session = getSession(interpreter.getImpl().get());
if (!session)
return;
if (!session->_isRunning)
@@ -158,7 +159,8 @@ void Debugger::handleExecutable(InterpreterImpl* impl,
}
-void Debugger::handleEvent(InterpreterImpl* impl, const Event& event, Breakpoint::When when) {
+void Debugger::handleEvent(Interpreter& interpreter, const Event& event, Breakpoint::When when) {
+ InterpreterImpl* impl = interpreter.getImpl().get();
std::shared_ptr<DebugSession> session = getSession(impl);
if (!session)
return;
@@ -177,7 +179,8 @@ void Debugger::handleEvent(InterpreterImpl* impl, const Event& event, Breakpoint
}
-void Debugger::handleStable(InterpreterImpl* impl, Breakpoint::When when) {
+void Debugger::handleStable(Interpreter& interpreter, Breakpoint::When when) {
+ InterpreterImpl* impl = interpreter.getImpl().get();
std::shared_ptr<DebugSession> session = getSession(impl);
if (!session)
return;
@@ -194,7 +197,8 @@ void Debugger::handleStable(InterpreterImpl* impl, Breakpoint::When when) {
session->checkBreakpoints(breakpoints);
}
-void Debugger::handleMicrostep(InterpreterImpl* impl, Breakpoint::When when) {
+void Debugger::handleMicrostep(Interpreter& interpreter, Breakpoint::When when) {
+ InterpreterImpl* impl = interpreter.getImpl().get();
std::shared_ptr<DebugSession> session = getSession(impl);
if (!session)
return;
@@ -211,7 +215,8 @@ void Debugger::handleMicrostep(InterpreterImpl* impl, Breakpoint::When when) {
session->checkBreakpoints(breakpoints);
}
-void Debugger::handleTransition(InterpreterImpl* impl, const XERCESC_NS::DOMElement* transition, Breakpoint::When when) {
+void Debugger::handleTransition(Interpreter& interpreter, const XERCESC_NS::DOMElement* transition, Breakpoint::When when) {
+ InterpreterImpl* impl = interpreter.getImpl().get();
std::shared_ptr<DebugSession> session = getSession(impl);
if (!session)
return;
@@ -224,7 +229,8 @@ void Debugger::handleTransition(InterpreterImpl* impl, const XERCESC_NS::DOMElem
session->checkBreakpoints(qualifiedBreakpoints);
}
-void Debugger::handleState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state, Breakpoint::When when, Breakpoint::Action action) {
+void Debugger::handleState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state, Breakpoint::When when, Breakpoint::Action action) {
+ InterpreterImpl* impl = interpreter.getImpl().get();
std::shared_ptr<DebugSession> session = getSession(impl);
if (!session)
return;
@@ -239,7 +245,8 @@ void Debugger::handleState(InterpreterImpl* impl, const XERCESC_NS::DOMElement*
}
-void Debugger::handleInvoke(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeId, Breakpoint::When when, Breakpoint::Action action) {
+void Debugger::handleInvoke(Interpreter& interpreter, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeId, Breakpoint::When when, Breakpoint::Action action) {
+ InterpreterImpl* impl = interpreter.getImpl().get();
std::shared_ptr<DebugSession> session = getSession(impl);
if (!session)
return;
diff --git a/src/uscxml/debug/Debugger.h b/src/uscxml/debug/Debugger.h
index 08136d6..4b564cb 100644
--- a/src/uscxml/debug/Debugger.h
+++ b/src/uscxml/debug/Debugger.h
@@ -55,45 +55,45 @@ public:
virtual void pushData(std::shared_ptr<DebugSession> session, Data pushData) = 0;
// InterpreterMonitor
- virtual void beforeProcessingEvent(InterpreterImpl* impl, const Event& event);
- virtual void beforeMicroStep(InterpreterImpl* impl);
- virtual void beforeExitingState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state);
- virtual void afterExitingState(InterpreterImpl* impl, 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 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(InterpreterImpl* impl, const XERCESC_NS::DOMElement* transition);
- virtual void afterTakingTransition(InterpreterImpl* impl, 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 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(InterpreterImpl* impl);
- virtual void onStableConfiguration(InterpreterImpl* impl);
- virtual void beforeCompletion(InterpreterImpl* impl);
- virtual void afterCompletion(InterpreterImpl* impl);
+ virtual void beforeProcessingEvent(Interpreter& interpreter, const Event& event);
+ virtual void beforeMicroStep(Interpreter& interpreter);
+ virtual void beforeExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state);
+ virtual void afterExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state);
+ virtual void beforeExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* execContent);
+ virtual void afterExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* execContent);
+ 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(Interpreter& interpreter, const XERCESC_NS::DOMElement* transition);
+ virtual void afterTakingTransition(Interpreter& interpreter, const XERCESC_NS::DOMElement* transition);
+ virtual void beforeEnteringState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state);
+ virtual void afterEnteringState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state);
+ 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(Interpreter& interpreter);
+ virtual void onStableConfiguration(Interpreter& interpreter);
+ virtual void beforeCompletion(Interpreter& interpreter);
+ virtual void afterCompletion(Interpreter& interpreter);
protected:
- void handleTransition(InterpreterImpl* impl,
+ void handleTransition(Interpreter& interpreter,
const XERCESC_NS::DOMElement* transition,
Breakpoint::When when);
- void handleState(InterpreterImpl* impl,
+ void handleState(Interpreter& interpreter,
const XERCESC_NS::DOMElement* state,
Breakpoint::When when,
Breakpoint::Action action);
- void handleInvoke(InterpreterImpl* impl,
+ void handleInvoke(Interpreter& interpreter,
const XERCESC_NS::DOMElement* invokeElem,
const std::string& invokeId,
Breakpoint::When when,
Breakpoint::Action action);
- void handleExecutable(InterpreterImpl* impl,
+ void handleExecutable(Interpreter& interpreter,
const XERCESC_NS::DOMElement* execContentElem,
Breakpoint::When when);
- void handleStable(InterpreterImpl* impl, Breakpoint::When when);
- void handleMicrostep(InterpreterImpl* impl, Breakpoint::When when);
- void handleEvent(InterpreterImpl* impl, const Event& event, Breakpoint::When when);
+ void handleStable(Interpreter& interpreter, Breakpoint::When when);
+ void handleMicrostep(Interpreter& interpreter, Breakpoint::When when);
+ void handleEvent(Interpreter& interpreter, const Event& event, Breakpoint::When when);
std::list<Breakpoint> getQualifiedTransBreakpoints(InterpreterImpl* impl,
const XERCESC_NS::DOMElement* transition,
@@ -107,6 +107,7 @@ protected:
Breakpoint breakpointTemplate);
std::recursive_mutex _sessionMutex;
+ /// @todo: We ought to change form InterpreterImpl to Interpreter everywhere
std::map<InterpreterImpl*, std::shared_ptr<DebugSession> > _sessionForInterpreter;
};
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;
};
/**