diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-03-20 08:00:41 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-03-20 08:00:41 (GMT) |
commit | c6c1f3e2e333705bf7d54fffd4b18939a56f4ed8 (patch) | |
tree | 92af8be33c602a68d1912790cad657c2a012e2c0 /src/uscxml/plugins/element | |
parent | ccbf595c52fd705ec70abc774a29b153a7281334 (diff) | |
download | uscxml-c6c1f3e2e333705bf7d54fffd4b18939a56f4ed8.zip uscxml-c6c1f3e2e333705bf7d54fffd4b18939a56f4ed8.tar.gz uscxml-c6c1f3e2e333705bf7d54fffd4b18939a56f4ed8.tar.bz2 |
Started Syteminvoker
Diffstat (limited to 'src/uscxml/plugins/element')
-rw-r--r-- | src/uscxml/plugins/element/postpone/PostponeElement.cpp | 25 | ||||
-rw-r--r-- | src/uscxml/plugins/element/postpone/PostponeElement.h | 7 |
2 files changed, 16 insertions, 16 deletions
diff --git a/src/uscxml/plugins/element/postpone/PostponeElement.cpp b/src/uscxml/plugins/element/postpone/PostponeElement.cpp index 96cda6f..53782e1 100644 --- a/src/uscxml/plugins/element/postpone/PostponeElement.cpp +++ b/src/uscxml/plugins/element/postpone/PostponeElement.cpp @@ -40,6 +40,12 @@ void PostponeElement::enterElement(const Arabica::DOM::Node<std::string>& node) } } + // chaining causes the event to fire if the condition was true since postponing + bool chained = false; + if (HAS_ATTR(node, "chaining")) { + chained = boost::iequals(ATTR(node, "chaining"), "true"); + } + // when will we refire the event? std::string until; try { @@ -85,36 +91,29 @@ void PostponeElement::enterElement(const Arabica::DOM::Node<std::string>& node) } #endif Event currEvent = _interpreter->getCurrentEvent(); - Resubmitter::postpone(currEvent, until, 0, _interpreter); + Resubmitter::postpone(currEvent, until, 0, chained, _interpreter); } void PostponeElement::exitElement(const Arabica::DOM::Node<std::string>& node) { } -void PostponeElement::Resubmitter::postpone(const Event& event, std::string until, uint64_t timeout, Interpreter* interpreter) { +void PostponeElement::Resubmitter::postpone(const Event& event, std::string until, uint64_t timeout, bool chained, Interpreter* interpreter) { Resubmitter* resubmitter = getInstance(interpreter); - resubmitter->_postponedEvents.push_back(Postponed(event, until, timeout)); + resubmitter->_postponedEvents.push_back(Postponed(event, until, timeout, chained)); } void PostponeElement::Resubmitter::onStableConfiguration(Interpreter* interpreter) { std::list<Postponed>::iterator eventIter = _postponedEvents.begin(); + bool dispatched = false; while(eventIter != _postponedEvents.end()) { try { // LOG(INFO) << "Reevaluating: >> " << eventIter->first << " <<"; - if (eventIter->timeout > 0 && tthread::chrono::system_clock::now() < eventIter->timeout) { - // TODO: We should use an event queue -// LOG(INFO) << " -> Timeout"; - eventIter->event.name += ".timeout"; - interpreter->receive(eventIter->event, true); - _postponedEvents.erase(eventIter); - break; - } - if (interpreter->getDataModel().evalAsBool(eventIter->until)) { + if ((!dispatched || eventIter->chaining) && interpreter->getDataModel().evalAsBool(eventIter->until)) { // LOG(INFO) << " -> is TRUE"; eventIter->event.name += ".postponed"; interpreter->receive(eventIter->event, true); _postponedEvents.erase(eventIter); - break; + dispatched = true; } // LOG(INFO) << " -> is FALSE"; } catch (Event e) { diff --git a/src/uscxml/plugins/element/postpone/PostponeElement.h b/src/uscxml/plugins/element/postpone/PostponeElement.h index eb7a738..268493f 100644 --- a/src/uscxml/plugins/element/postpone/PostponeElement.h +++ b/src/uscxml/plugins/element/postpone/PostponeElement.h @@ -13,11 +13,12 @@ namespace uscxml { class PostponeElement : public ExecutableContentImpl { public: struct Postponed { - Postponed(const Event& event, const std::string& until, long timeout) : - event(event), until(until), timeout(timeout) {} + Postponed(const Event& event, const std::string& until, long timeout, bool chaining = false) : + event(event), until(until), timeout(timeout), chaining(chaining) {} Event event; std::string until; uint64_t timeout; + bool chaining; }; PostponeElement() {} @@ -48,7 +49,7 @@ protected: } static Resubmitter* getInstance(Interpreter* interpreter); - static void postpone(const Event& event, std::string until, uint64_t timeout, Interpreter* interpreter); + static void postpone(const Event& event, std::string until, uint64_t timeout, bool chained, Interpreter* interpreter); // InterpreterMonitor void onStableConfiguration(Interpreter* interpreter); |