summaryrefslogtreecommitdiffstats
path: root/src/uscxml/debug/SCXMLDotWriter.h
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-08-21 15:16:52 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-08-21 15:16:52 (GMT)
commitbd45c688b3d3aad5d62b85457ce943eaadf989ae (patch)
tree831d54da85c85f3e998be70241f8ffc3fed7f924 /src/uscxml/debug/SCXMLDotWriter.h
parenta52fb3364968e31a1a15c85ac45b68d9f531687b (diff)
downloaduscxml-bd45c688b3d3aad5d62b85457ce943eaadf989ae.zip
uscxml-bd45c688b3d3aad5d62b85457ce943eaadf989ae.tar.gz
uscxml-bd45c688b3d3aad5d62b85457ce943eaadf989ae.tar.bz2
Added WebStorage object to document
Some refinements to DotWriter
Diffstat (limited to 'src/uscxml/debug/SCXMLDotWriter.h')
-rw-r--r--src/uscxml/debug/SCXMLDotWriter.h57
1 files changed, 49 insertions, 8 deletions
diff --git a/src/uscxml/debug/SCXMLDotWriter.h b/src/uscxml/debug/SCXMLDotWriter.h
index 0666aa5..07b34b1 100644
--- a/src/uscxml/debug/SCXMLDotWriter.h
+++ b/src/uscxml/debug/SCXMLDotWriter.h
@@ -1,7 +1,9 @@
#ifndef SCXMLDOTWRITER_H_AOP0OHXX
#define SCXMLDOTWRITER_H_AOP0OHXX
+#include "uscxml/Interpreter.h"
#include <DOM/Document.hpp>
+#include <XPath/XPath.hpp>
#include <fstream>
#include <set>
@@ -9,7 +11,28 @@ namespace uscxml {
class Interpreter;
-class SCXMLDotWriter {
+
+
+/**
+ * This writer, added as a monitor will output .dot files.
+ *
+ * # create a set of pdfs form the dot files
+ * $ dot -Tpdf -O *.dot
+ * or
+ * $ find . -name "*.dot" -exec dot -Tpdf -O {} \;
+ *
+ * # create a movie from the pdfs
+ * $ dot -Tgif -O *.dot
+ * or
+ * $ find . -name "*.dot" -exec dot -Tgif -O {} \;
+ *
+ * $ ffmpeg -r 3 -i <NAME>.%06d.dot.gif -r 25 movie.mpg
+ * $ convert -delay 20 *.gif animated.gif
+ *
+ * # unflatten can be used to create more compact graphs
+ * find . -name "*.dot" -exec unflatten -f -l2 -o {}.flat.dot {} \;
+ */
+class SCXMLDotWriter : public InterpreterMonitor {
public:
struct ElemDetails {
@@ -18,25 +41,43 @@ public:
std::string content;
};
- SCXMLDotWriter(InterpreterImpl* interpreter);
+ SCXMLDotWriter();
~SCXMLDotWriter();
- static void toDot(const std::string& filename, InterpreterImpl* interpreter);
- void writeSCXMLElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem);
- void writeStateElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem);
- void writeTransitionElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem);
+ virtual void onStableConfiguration(Interpreter interpreter);
+ virtual void afterCompletion(Interpreter interpreter);
+ virtual void beforeTakingTransitions(Interpreter interpreter, const Arabica::XPath::NodeSet<std::string>& transitions);
+ virtual void beforeMicroStep(Interpreter interpreter);
+
+ static void toDot(const std::string& filename,
+ Interpreter interpreter,
+ const Arabica::XPath::NodeSet<std::string>& transitions = Arabica::XPath::NodeSet<std::string>());
std::string getDetailedLabel(const Arabica::DOM::Element<std::string>& elem, int indentation = 0);
std::string colorForIndent(int indent);
std::string idForNode(const Arabica::DOM::Node<std::string>& node);
std::string nameForNode(const Arabica::DOM::Node<std::string>& node);
+ std::string getPrefix();
- static std::string getPrefix();
static std::string dotEscape(const std::string& text);
+protected:
+
+ SCXMLDotWriter(Interpreter interpreter,
+ const Arabica::XPath::NodeSet<std::string>& transitions);
+
+ void writeSCXMLElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem);
+ void writeStateElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem);
+ void writeTransitionElement(std::ostream& os, const Arabica::DOM::Element<std::string>& elem);
+
+ int _iteration;
std::set<std::string> _knownIds;
- static int _indentation;
+ int _indentation;
+
+ // these are only set in ephemeral instances per monitor call
+ Arabica::XPath::NodeSet<std::string> _transitions;
+ Interpreter _interpreter;
};
}