From d9abe5a5480dd3f2c0fd0110b02c1a370f5a3b02 Mon Sep 17 00:00:00 2001 From: Andreas Gansen Date: Sun, 13 Mar 2016 15:05:30 +0100 Subject: return reachable targets / valid events as vector --- src/uscxml/Interpreter.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h index c65c8f7..420e685 100644 --- a/src/uscxml/Interpreter.h +++ b/src/uscxml/Interpreter.h @@ -46,6 +46,8 @@ #include "uscxml/plugins/Invoker.h" #include "uscxml/plugins/ExecutableContent.h" +#include "dom/DOMUtils.h" + #ifndef TIME_BLOCK # ifdef BUILD_PROFILING # include "uscxml/concurrency/Timer.h" @@ -402,6 +404,38 @@ public: virtual void handleDOMEvent(Arabica::DOM::Events::Event& event); + std::vector getReachableTargets() { + + std::vector e; + tthread::lock_guard lock(_mutex); + Arabica::XPath::NodeSet possibleTransitions = DOMUtils::filterChildElements( "transition", _configuration, false); + + for( size_t i = 0; i < possibleTransitions.size(); i++ ) { + Arabica::DOM::Node transitions = possibleTransitions[ i ]; + Arabica::DOM::NamedNodeMap attributes = transitions.getAttributes(); + Arabica::DOM::Node events = attributes.getNamedItem("target"); + e.push_back( std::string( events.getNodeValue() ) ); + } + return e; + + } + + std::vector getValidEvents() { + + std::vector e; + tthread::lock_guard lock(_mutex); + Arabica::XPath::NodeSet possibleTransitions = DOMUtils::filterChildElements( "transition", _configuration, false); + + for( size_t i = 0; i < possibleTransitions.size(); i++ ) { + Arabica::DOM::Node transitions = possibleTransitions[ i ]; + Arabica::DOM::NamedNodeMap attributes = transitions.getAttributes(); + Arabica::DOM::Node events = attributes.getNamedItem("event"); + e.push_back( std::string( events.getNodeValue() ) ); + } + return e; + + } + protected: static void run(void*); // static method for thread to run @@ -589,6 +623,14 @@ public: return _impl->reset(); } + std::vector getReachableTargets() { + return _impl->getReachableTargets(); + } + + std::vector getValidEvents() { + return _impl->getValidEvents(); + } + void start() { return _impl->start(); } @@ -807,6 +849,7 @@ public: Timer timer; #endif + protected: void setInvokeRequest(const InvokeRequest& req) { -- cgit v0.12