diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-04-12 11:57:08 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-04-12 11:57:08 (GMT) |
commit | ba050afaaad699e60ca657b311d5c34d038bb89c (patch) | |
tree | d4c79e30631c63e8557c6ec893a70dda46aa6cd5 /src/uscxml/interpreter | |
parent | 45ab2909e17f7e0348ccfe4179f23a897a2fd305 (diff) | |
download | uscxml-ba050afaaad699e60ca657b311d5c34d038bb89c.zip uscxml-ba050afaaad699e60ca657b311d5c34d038bb89c.tar.gz uscxml-ba050afaaad699e60ca657b311d5c34d038bb89c.tar.bz2 |
Refactoring for other datamodels
Diffstat (limited to 'src/uscxml/interpreter')
-rw-r--r-- | src/uscxml/interpreter/InterpreterDraft6.cpp | 6 | ||||
-rw-r--r-- | src/uscxml/interpreter/InterpreterDraft7.cpp | 55 |
2 files changed, 4 insertions, 57 deletions
diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp index dfcc457..d3019d9 100644 --- a/src/uscxml/interpreter/InterpreterDraft6.cpp +++ b/src/uscxml/interpreter/InterpreterDraft6.cpp @@ -22,6 +22,8 @@ void InterpreterDraft6::interpret() { // just make sure we have a session id assert(_sessionId.length() > 0); + setupIOProcessors(); + std::string datamodelName; if (datamodelName.length() == 0 && HAS_ATTR(_scxml, "datamodel")) datamodelName = ATTR(_scxml, "datamodel"); @@ -34,11 +36,9 @@ void InterpreterDraft6::interpret() { } if (_dataModel) { - _dataModel.assign("_x.args", _cmdLineOptions, Element<std::string>()); + _dataModel.assign("_x.args", _cmdLineOptions); } - setupIOProcessors(); - _running = true; _binding = (HAS_ATTR(_scxml, "binding") && boost::iequals(ATTR(_scxml, "binding"), "late") ? LATE : EARLY); diff --git a/src/uscxml/interpreter/InterpreterDraft7.cpp b/src/uscxml/interpreter/InterpreterDraft7.cpp index e02a343..2f8c7b2 100644 --- a/src/uscxml/interpreter/InterpreterDraft7.cpp +++ b/src/uscxml/interpreter/InterpreterDraft7.cpp @@ -45,12 +45,7 @@ void InterpreterDraft7::interpret() { } if (_dataModel) { - _dataModel.assign("_x.args", _cmdLineOptions, Element<std::string>()); - if (_httpServlet) { - Data data; - data.compound["location"] = Data(_httpServlet->getURL(), Data::VERBATIM); - _dataModel.assign("_ioprocessors['http']", data, Element<std::string>()); - } + _dataModel.assign("_x.args", _cmdLineOptions); } setupIOProcessors(); @@ -117,54 +112,6 @@ void InterpreterDraft7::interpret() { } /** - * Called with a single data element from the topmost datamodel element. - */ -void InterpreterDraft7::initializeData(const Arabica::DOM::Element<std::string>& data) { - if (!_dataModel) { - LOG(ERROR) << "Cannot initialize data when no datamodel is given!"; - return; - } - try { - if (!HAS_ATTR(data, "id")) { - LOG(ERROR) << "Data element has no id!"; - return; - } - - if (HAS_ATTR(data, "expr")) { - std::string value = ATTR(data, "expr"); - _dataModel.assign(ATTR(data, "id"), value, data); - } else if (HAS_ATTR(data, "src")) { - URL srcURL(ATTR(data, "src")); - if (!srcURL.isAbsolute()) - toAbsoluteURI(srcURL); - - std::stringstream ss; - if (_cachedURLs.find(srcURL.asString()) != _cachedURLs.end()) { - ss << _cachedURLs[srcURL.asString()]; - } else { - ss << srcURL; - _cachedURLs[srcURL.asString()] = srcURL; - } - _dataModel.assign(ATTR(data, "id"), ss.str(), data); - - } else if (data.hasChildNodes()) { - // search for the text node with the actual script - NodeList<std::string> dataChilds = data.getChildNodes(); - for (int i = 0; i < dataChilds.getLength(); i++) { - if (dataChilds.item(i).getNodeType() == Node_base::TEXT_NODE) { - Data value = Data(dataChilds.item(i).getNodeValue()); - _dataModel.assign(ATTR(data, "id"), value, data); - break; - } - } - } - - } catch (Event e) { - LOG(ERROR) << "Syntax error in data element:" << std::endl << e << std::endl; - } -} - -/** procedure mainEventLoop(): while running: enabledTransitions = null |