summaryrefslogtreecommitdiffstats
path: root/src/uscxml
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2017-05-22 19:17:48 (GMT)
committerStefan Radomski <github@mintwerk.de>2017-05-22 19:17:48 (GMT)
commit9a70ea561fecf533451f08ee3a490e2a5ba21372 (patch)
tree6ca253c6aa8640d50ca93d104a19421ec8ec2e3f /src/uscxml
parentecdefbdbb55c800f9ceed67f77592b5d64927225 (diff)
downloaduscxml-9a70ea561fecf533451f08ee3a490e2a5ba21372.zip
uscxml-9a70ea561fecf533451f08ee3a490e2a5ba21372.tar.gz
uscxml-9a70ea561fecf533451f08ee3a490e2a5ba21372.tar.bz2
Fixed issue 135 custom executable content
Diffstat (limited to 'src/uscxml')
-rw-r--r--src/uscxml/interpreter/BasicContentExecutor.cpp17
-rw-r--r--src/uscxml/interpreter/BasicContentExecutor.h2
-rw-r--r--src/uscxml/interpreter/ContentExecutorImpl.h3
-rw-r--r--src/uscxml/interpreter/InterpreterImpl.h6
-rw-r--r--src/uscxml/plugins/ExecutableContentImpl.h4
5 files changed, 31 insertions, 1 deletions
diff --git a/src/uscxml/interpreter/BasicContentExecutor.cpp b/src/uscxml/interpreter/BasicContentExecutor.cpp
index 696b575..8d278ec 100644
--- a/src/uscxml/interpreter/BasicContentExecutor.cpp
+++ b/src/uscxml/interpreter/BasicContentExecutor.cpp
@@ -369,6 +369,23 @@ void BasicContentExecutor::process(XERCESC_NS::DOMElement* block) {
processLog(block);
} else if (iequals(tagName, xmlPrefix + "script")) {
processScript(block);
+ } else if (Factory::getInstance()->hasExecutableContent(LOCALNAME(block), X(block->getNamespaceURI()))) {
+ // custom executable content, ask the factory about it!
+ if (_customExecContent.find(block) == _customExecContent.end()) {
+ _customExecContent[block] = _callbacks->createExecutableContent(LOCALNAME(block), X(block->getNamespaceURI()));
+ }
+ _customExecContent[block].enterElement(block);
+
+ // process custom element's children?
+ if (_customExecContent[block].processChildren()) {
+ std::list<DOMNode*> childElems = DOMUtils::filterChildType(DOMNode::ELEMENT_NODE, block, false);
+ if(childElems.size() > 0) {
+ for(auto elemIter = childElems.begin(); elemIter != childElems.end(); elemIter++) {
+ process(static_cast<DOMElement*>(*elemIter));
+ }
+ }
+ }
+ _customExecContent[block].exitElement(block);
} else {
LOG(_callbacks->getLogger(), USCXML_ERROR) << tagName << std::endl;
assert(false);
diff --git a/src/uscxml/interpreter/BasicContentExecutor.h b/src/uscxml/interpreter/BasicContentExecutor.h
index 9019b23..469c28e 100644
--- a/src/uscxml/interpreter/BasicContentExecutor.h
+++ b/src/uscxml/interpreter/BasicContentExecutor.h
@@ -21,6 +21,7 @@
#define BASICCONTENTEXECUTOR_H_B873199D
#include "ContentExecutorImpl.h"
+#include "uscxml/plugins/ExecutableContent.h"
namespace uscxml {
@@ -58,6 +59,7 @@ protected:
void processNameLists(std::map<std::string, Data>& nameMap, XERCESC_NS::DOMElement* element);
void processParams(std::multimap<std::string, Data>& paramMap, XERCESC_NS::DOMElement* element);
+ std::map<XERCESC_NS::DOMElement*, ExecutableContent> _customExecContent;
};
}
diff --git a/src/uscxml/interpreter/ContentExecutorImpl.h b/src/uscxml/interpreter/ContentExecutorImpl.h
index 5b39108..d837273 100644
--- a/src/uscxml/interpreter/ContentExecutorImpl.h
+++ b/src/uscxml/interpreter/ContentExecutorImpl.h
@@ -25,6 +25,7 @@
#include "uscxml/messages/Event.h"
#include "uscxml/interpreter/InterpreterMonitor.h"
#include "uscxml/interpreter/Logging.h"
+#include "uscxml/plugins/ExecutableContent.h"
#include <string>
#include <set>
@@ -78,6 +79,8 @@ public:
virtual Interpreter getInterpreter() = 0;
virtual Logger getLogger() = 0;
+ virtual ExecutableContent createExecutableContent(const std::string& localName, const std::string& nameSpace) = 0;
+
};
/**
diff --git a/src/uscxml/interpreter/InterpreterImpl.h b/src/uscxml/interpreter/InterpreterImpl.h
index fd6d393..42d61f2 100644
--- a/src/uscxml/interpreter/InterpreterImpl.h
+++ b/src/uscxml/interpreter/InterpreterImpl.h
@@ -33,6 +33,7 @@
#include "uscxml/plugins/DataModelImpl.h"
#include "uscxml/plugins/IOProcessorImpl.h"
#include "uscxml/plugins/InvokerImpl.h"
+#include "uscxml/plugins/ExecutableContent.h"
#include "uscxml/interpreter/MicroStepImpl.h"
#include "uscxml/interpreter/ContentExecutorImpl.h"
#include "uscxml/interpreter/EventQueue.h"
@@ -213,6 +214,11 @@ public:
return _currEvent;
}
+ virtual ExecutableContent createExecutableContent(const std::string& localName, const std::string& nameSpace) {
+ return Factory::getInstance()->createExecutableContent(localName, nameSpace, this);
+ }
+
+
/**
IOProcessorCallbacks
*/
diff --git a/src/uscxml/plugins/ExecutableContentImpl.h b/src/uscxml/plugins/ExecutableContentImpl.h
index f186e84..81aedf1 100644
--- a/src/uscxml/plugins/ExecutableContentImpl.h
+++ b/src/uscxml/plugins/ExecutableContentImpl.h
@@ -57,7 +57,9 @@ public:
}
virtual void enterElement(XERCESC_NS::DOMElement* node) = 0; ///< Invoked when entering the element as part of evaluating executable content.
virtual void exitElement(XERCESC_NS::DOMElement* node) = 0; ///< Invoked when exiting the element as part of evaluating executable content.
- virtual bool processChildren() = 0; ///< Whether or not the interpreter should process this elements children.
+ virtual bool processChildren() {
+ return false; ///< Whether or not the interpreter should process this elements children.
+ }
protected:
InterpreterImpl* _interpreter;