diff options
author | Stefan Radomski <github@mintwerk.de> | 2017-01-18 17:15:46 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2017-01-18 17:15:46 (GMT) |
commit | fc78cfdc4d1f5bba8dbd6a412f23651e185cb191 (patch) | |
tree | dd32929c07e6c19250f2e8fde1e73712bab0c6fb /src/uscxml/plugins/ioprocessor/scxml | |
parent | 01ee860a88b5c8cf25fb7dcc145662d2c27f3ebe (diff) | |
download | uscxml-fc78cfdc4d1f5bba8dbd6a412f23651e185cb191.zip uscxml-fc78cfdc4d1f5bba8dbd6a412f23651e185cb191.tar.gz uscxml-fc78cfdc4d1f5bba8dbd6a412f23651e185cb191.tar.bz2 |
Worked on passing even more IRP tests
Diffstat (limited to 'src/uscxml/plugins/ioprocessor/scxml')
-rw-r--r-- | src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp | 40 | ||||
-rw-r--r-- | src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.h | 6 |
2 files changed, 13 insertions, 33 deletions
diff --git a/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp index c53915b..5a82860 100644 --- a/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp +++ b/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.cpp @@ -41,16 +41,16 @@ SCXMLIOProcessor::~SCXMLIOProcessor() { } -std::shared_ptr<IOProcessorImpl> SCXMLIOProcessor::create(InterpreterImpl* interpreter) { +std::shared_ptr<IOProcessorImpl> SCXMLIOProcessor::create(IOProcessorCallbacks* callbacks) { std::shared_ptr<SCXMLIOProcessor> io(new SCXMLIOProcessor()); - io->_interpreter = interpreter; + io->_callbacks = callbacks; return io; } Data SCXMLIOProcessor::getDataModelVariables() { Data data; - data.compound["location"] = Data("#_scxml_" + _interpreter->getSessionId(), Data::VERBATIM); + data.compound["location"] = Data("#_scxml_" + _callbacks->getSessionId(), Data::VERBATIM); return data; } @@ -71,7 +71,7 @@ void SCXMLIOProcessor::eventFromSCXML(const std::string& target, const Event& ev eventCopy.origintype = "http://www.w3.org/TR/scxml/#SCXMLEventProcessor"; // test 336 - eventCopy.origin = "#_scxml_" + _interpreter->getSessionId(); + eventCopy.origin = "#_scxml_" + _callbacks->getSessionId(); if (false) { } else if(target.length() == 0) { @@ -85,14 +85,14 @@ void SCXMLIOProcessor::eventFromSCXML(const std::string& target, const Event& ev // reqCopy.sendid = ""; // test 198 - _interpreter->enqueueExternal(eventCopy); + _callbacks->enqueueExternal(eventCopy); } else if (iequals(target, "#_internal")) { /** * #_internal: If the target is the special term '#_internal', the Processor * must add the event to the internal event queue of the sending session. */ - _interpreter->enqueueInternal(eventCopy); + _callbacks->enqueueInternal(eventCopy); } else if (iequals(target, "#_parent")) { /** @@ -100,13 +100,7 @@ void SCXMLIOProcessor::eventFromSCXML(const std::string& target, const Event& ev * add the event to the external event queue of the SCXML session that invoked * the sending session, if there is one. */ - - if (_interpreter->_parentQueue) { - _interpreter->_parentQueue.enqueue(eventCopy); - } else { - ERROR_COMMUNICATION_THROW("Sending to parent invoker, but none is set"); - } - + _callbacks->enqueueAtParent(eventCopy); } else if (target.length() > 8 && iequals(target.substr(0, 8), "#_scxml_")) { /** * #_scxml_sessionid: If the target is the special term '#_scxml_sessionid', @@ -117,7 +111,7 @@ void SCXMLIOProcessor::eventFromSCXML(const std::string& target, const Event& ev */ std::string sessionId = target.substr(8); - std::lock_guard<std::recursive_mutex> lock(_interpreter->_instanceMutex); + std::lock_guard<std::recursive_mutex> lock(InterpreterImpl::_instanceMutex); std::map<std::string, std::weak_ptr<InterpreterImpl> > instances = InterpreterImpl::getInstances(); if (instances.find(sessionId) != instances.end()) { std::shared_ptr<InterpreterImpl> otherSession = instances[sessionId].lock(); @@ -138,21 +132,7 @@ void SCXMLIOProcessor::eventFromSCXML(const std::string& target, const Event& ev * session. */ std::string invokeId = target.substr(2); - if (_interpreter->_invokers.find(invokeId) != _interpreter->_invokers.end()) { - std::lock_guard<std::recursive_mutex> lock(_interpreter->_instanceMutex); - try { - _interpreter->_invokers[invokeId].eventFromSCXML(eventCopy); - } catch(Event e) { - // Is this the right thing to do? -// _interpreter->enqueueExternal(eventCopy); - } catch (const std::exception &e) { - ERROR_COMMUNICATION_THROW("Exception caught while sending event to invoker '" + invokeId + "': " + e.what()); - } catch(...) { - ERROR_COMMUNICATION_THROW("Exception caught while sending event to invoker '" + invokeId + "'"); - } - } else { - ERROR_COMMUNICATION_THROW("Can not send to invoked component '" + invokeId + "', no such invokeId"); - } + _callbacks->enqueueAtInvoker(invokeId, eventCopy); } else { ERROR_COMMUNICATION_THROW("Not sure what to make of the target '" + target + "' - raising error"); } @@ -160,4 +140,4 @@ void SCXMLIOProcessor::eventFromSCXML(const std::string& target, const Event& ev -}
\ No newline at end of file +} diff --git a/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.h b/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.h index 21fd13a..6494873 100644 --- a/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.h +++ b/src/uscxml/plugins/ioprocessor/scxml/SCXMLIOProcessor.h @@ -32,7 +32,7 @@ class SCXMLIOProcessor : public IOProcessorImpl { public: SCXMLIOProcessor(); virtual ~SCXMLIOProcessor(); - virtual std::shared_ptr<IOProcessorImpl> create(uscxml::InterpreterImpl* interpreter); + virtual std::shared_ptr<IOProcessorImpl> create(uscxml::IOProcessorCallbacks* callbacks); virtual std::list<std::string> getNames() { std::list<std::string> names; @@ -46,7 +46,7 @@ public: Data getDataModelVariables(); protected: - InterpreterImpl* _interpreter; + IOProcessorCallbacks* _callbacks; }; #ifdef BUILD_AS_PLUGINS @@ -55,4 +55,4 @@ PLUMA_INHERIT_PROVIDER(SCXMLIOProcessor, IOProcessorImpl); } -#endif /* end of include guard: SCXMLIOProcessor_H_2CUY93KU */
\ No newline at end of file +#endif /* end of include guard: SCXMLIOProcessor_H_2CUY93KU */ |