summaryrefslogtreecommitdiffstats
path: root/src
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
parentad2653c30b78b2951eb79d303a9e3ab52f4a2def (diff)
downloaduscxml-db8418fb9f733ca0147cc225ce0988d7866f15cd.zip
uscxml-db8418fb9f733ca0147cc225ce0988d7866f15cd.tar.gz
uscxml-db8418fb9f733ca0147cc225ce0988d7866f15cd.tar.bz2
Changed Monitor signature to take Interpreter facade
Diffstat (limited to 'src')
-rw-r--r--src/bindings/swig/wrapped/WrappedInterpreterMonitor.cpp24
-rw-r--r--src/bindings/swig/wrapped/WrappedInterpreterMonitor.h35
-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
10 files changed, 160 insertions, 137 deletions
diff --git a/src/bindings/swig/wrapped/WrappedInterpreterMonitor.cpp b/src/bindings/swig/wrapped/WrappedInterpreterMonitor.cpp
index a89ff54..cdb46de 100644
--- a/src/bindings/swig/wrapped/WrappedInterpreterMonitor.cpp
+++ b/src/bindings/swig/wrapped/WrappedInterpreterMonitor.cpp
@@ -30,31 +30,31 @@ using namespace XERCESC_NS;
WrappedInterpreterMonitor::WrappedInterpreterMonitor() {}
WrappedInterpreterMonitor::~WrappedInterpreterMonitor() {}
-void WrappedInterpreterMonitor::beforeExitingState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {
+void WrappedInterpreterMonitor::beforeExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {
std::stringstream ss;
ss << *state;
beforeExitingState(ATTR(state, "id"), DOMUtils::xPathForNode(state), ss.str());
}
-void WrappedInterpreterMonitor::afterExitingState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {
+void WrappedInterpreterMonitor::afterExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {
std::stringstream ss;
ss << *state;
afterExitingState(ATTR(state, "id"), DOMUtils::xPathForNode(state), ss.str());
}
-void WrappedInterpreterMonitor::beforeExecutingContent(InterpreterImpl* impl, const XERCESC_NS::DOMElement* content) {
+void WrappedInterpreterMonitor::beforeExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* content) {
std::stringstream ss;
ss << *content;
beforeExecutingContent(TAGNAME(content), DOMUtils::xPathForNode(content), ss.str());
}
-void WrappedInterpreterMonitor::afterExecutingContent(InterpreterImpl* impl, const XERCESC_NS::DOMElement* content) {
+void WrappedInterpreterMonitor::afterExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* content) {
std::stringstream ss;
ss << *content;
afterExecutingContent(TAGNAME(content), DOMUtils::xPathForNode(content), ss.str());
}
-void WrappedInterpreterMonitor::beforeUninvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invoker, const std::string& invokeid) {
+void WrappedInterpreterMonitor::beforeUninvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invoker, const std::string& invokeid) {
std::stringstream ss;
ss << *invoker;
std::string invokeId;
@@ -65,7 +65,7 @@ void WrappedInterpreterMonitor::beforeUninvoking(InterpreterImpl* impl, const XE
beforeUninvoking(DOMUtils::xPathForNode(invoker), invokeId, ss.str());
}
-void WrappedInterpreterMonitor::afterUninvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invoker, const std::string& invokeid) {
+void WrappedInterpreterMonitor::afterUninvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invoker, const std::string& invokeid) {
std::stringstream ss;
ss << *invoker;
std::string invokeId;
@@ -76,7 +76,7 @@ void WrappedInterpreterMonitor::afterUninvoking(InterpreterImpl* impl, const XER
afterUninvoking(DOMUtils::xPathForNode(invoker), invokeId, ss.str());
}
-void WrappedInterpreterMonitor::beforeTakingTransition(InterpreterImpl* impl, const XERCESC_NS::DOMElement* transition) {
+void WrappedInterpreterMonitor::beforeTakingTransition(Interpreter& interpreter, const XERCESC_NS::DOMElement* transition) {
XERCESC_NS::DOMElement* sourceState = getSourceState(transition);
const XERCESC_NS::DOMElement* root = DOMUtils::getNearestAncestor(transition, "scxml");
@@ -93,7 +93,7 @@ void WrappedInterpreterMonitor::beforeTakingTransition(InterpreterImpl* impl, co
beforeTakingTransition(DOMUtils::xPathForNode(transition), ATTR_CAST(sourceState, "id"), targets, ss.str());
}
-void WrappedInterpreterMonitor::afterTakingTransition(InterpreterImpl* impl, const XERCESC_NS::DOMElement* transition) {
+void WrappedInterpreterMonitor::afterTakingTransition(Interpreter& interpreter, const XERCESC_NS::DOMElement* transition) {
XERCESC_NS::DOMElement* sourceState = getSourceState(transition);
const XERCESC_NS::DOMElement* root = DOMUtils::getNearestAncestor(transition, "scxml");
@@ -110,19 +110,19 @@ void WrappedInterpreterMonitor::afterTakingTransition(InterpreterImpl* impl, con
afterTakingTransition(DOMUtils::xPathForNode(transition), ATTR_CAST(sourceState, "id"), targets, ss.str());
}
-void WrappedInterpreterMonitor::beforeEnteringState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {
+void WrappedInterpreterMonitor::beforeEnteringState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {
std::stringstream ss;
ss << *state;
beforeEnteringState(ATTR(state, "id"), DOMUtils::xPathForNode(state), ss.str());
}
-void WrappedInterpreterMonitor::afterEnteringState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state) {
+void WrappedInterpreterMonitor::afterEnteringState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {
std::stringstream ss;
ss << *state;
afterEnteringState(ATTR(state, "id"), DOMUtils::xPathForNode(state), ss.str());
}
-void WrappedInterpreterMonitor::beforeInvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invoker, const std::string& invokeid) {
+void WrappedInterpreterMonitor::beforeInvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invoker, const std::string& invokeid) {
std::stringstream ss;
ss << *invoker;
std::string invokeId;
@@ -133,7 +133,7 @@ void WrappedInterpreterMonitor::beforeInvoking(InterpreterImpl* impl, const XERC
beforeInvoking(DOMUtils::xPathForNode(invoker), invokeId, ss.str());
}
-void WrappedInterpreterMonitor::afterInvoking(InterpreterImpl* impl, const XERCESC_NS::DOMElement* invoker, const std::string& invokeid) {
+void WrappedInterpreterMonitor::afterInvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invoker, const std::string& invokeid) {
std::stringstream ss;
ss << *invoker;
std::string invokeId;
diff --git a/src/bindings/swig/wrapped/WrappedInterpreterMonitor.h b/src/bindings/swig/wrapped/WrappedInterpreterMonitor.h
index c5655cf..e05dad2 100644
--- a/src/bindings/swig/wrapped/WrappedInterpreterMonitor.h
+++ b/src/bindings/swig/wrapped/WrappedInterpreterMonitor.h
@@ -44,31 +44,34 @@ public:
WrappedInterpreterMonitor();
virtual ~WrappedInterpreterMonitor();
- void beforeExitingState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state);
+ virtual void beforeProcessingEvent(Interpreter& interpreter, const Event& event) {}
+ virtual void beforeMicroStep(Interpreter& interpreter) {}
+
+ void beforeExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state);
virtual void beforeExitingState(const std::string& stateId,
const std::string& xpath,
const std::string& stateXML) {}
- void afterExitingState(InterpreterImpl* impl, const XERCESC_NS::DOMElement* state);
+ void afterExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state);
virtual void afterExitingState(const std::string& stateId,
const std::string& xpath,
const std::string& stateXML) {}
- void beforeExecutingContent(InterpreterImpl* impl, const XERCESC_NS::DOMElement* content);
+ void beforeExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* content);
virtual void beforeExecutingContent(const std::string& tagName,
const std::string& xpath,
const std::string& contentXML) {}
- void afterExecutingContent(InterpreterImpl* impl, const XERCESC_NS::DOMElement* content);
+ void afterExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* content);
virtual void afterExecutingContent(const std::string& tagName,
const std::string& xpath,
const std::string& contentXML) {}
- void beforeUninvoking(InterpreterImpl* impl,
+ void beforeUninvoking(Interpreter& interpreter,
const XERCESC_NS::DOMElement* invoker,
const std::string& invokeid);
virtual void beforeUninvoking(const std::string& xpath,
@@ -76,7 +79,7 @@ public:
const std::string& invokerXML) {}
- void afterUninvoking(InterpreterImpl* impl,
+ void afterUninvoking(Interpreter& interpreter,
const XERCESC_NS::DOMElement* invoker,
const std::string& invokeid);
virtual void afterUninvoking(const std::string& xpath,
@@ -84,14 +87,14 @@ public:
const std::string& invokerXML) {}
- void beforeTakingTransition(InterpreterImpl* impl,
+ void beforeTakingTransition(Interpreter& interpreter,
const XERCESC_NS::DOMElement* transition);
virtual void beforeTakingTransition(const std::string& xpath,
const std::string& source,
const std::list<std::string>& targets,
const std::string& transitionXML) {}
- void afterTakingTransition(InterpreterImpl* impl,
+ void afterTakingTransition(Interpreter& interpreter,
const XERCESC_NS::DOMElement* transition);
virtual void afterTakingTransition(const std::string& xpath,
const std::string& source,
@@ -99,35 +102,41 @@ public:
const std::string& transitionXML) {}
- void beforeEnteringState(InterpreterImpl* impl,
+ void beforeEnteringState(Interpreter& interpreter,
const XERCESC_NS::DOMElement* state);
virtual void beforeEnteringState(const std::string& stateId,
const std::string& xpath,
const std::string& stateXML) {}
- void afterEnteringState(InterpreterImpl* impl,
+ void afterEnteringState(Interpreter& interpreter,
const XERCESC_NS::DOMElement* state);
virtual void afterEnteringState(const std::string& stateId,
const std::string& xpath,
const std::string& stateXML) {}
- void beforeInvoking(InterpreterImpl* impl,
+ void beforeInvoking(Interpreter& interpreter,
const XERCESC_NS::DOMElement* invoker,
const std::string& invokeid);
virtual void beforeInvoking(const std::string& xpath,
const std::string& invokeid,
const std::string& invokerXML) {}
- void afterInvoking(InterpreterImpl* impl,
+ void afterInvoking(Interpreter& interpreter,
const XERCESC_NS::DOMElement* invoker,
const std::string& invokeid);
virtual void afterInvoking(const std::string& xpath,
const std::string& invokeid,
const std::string& invokerXML) {}
- virtual void reportIssue(InterpreterImpl* impl,
+ virtual void afterMicroStep(Interpreter& interpreter) {}
+ virtual void onStableConfiguration(Interpreter& interpreter) {}
+
+ virtual void beforeCompletion(Interpreter& interpreter) {}
+ virtual void afterCompletion(Interpreter& interpreter) {}
+
+ virtual void reportIssue(Interpreter& interpreter,
const InterpreterIssue& issue) {}
};
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;
};
/**