55#include < boost/graph/graphviz.hpp>
66#include < iostream>
77
8- namespace tuttle {
9- namespace host {
10- namespace graph {
8+ namespace tuttle
9+ {
10+ namespace host
11+ {
12+ namespace graph
13+ {
1114
12- namespace detail {
13- template <class T >
14- std::ostream& operator <<( std::ostream& os, const DotEntry<T>& d )
15+ namespace detail
16+ {
17+ template <class T >
18+ std::ostream& operator <<(std::ostream& os, const DotEntry<T>& d)
1519{
16- // os << "[" << d._key << "=\"" << d._value << "\"]";
17- os << d._key << " =\" " << d._value << " \" " ;
18- return os;
20+ // os << "[" << d._key << "=\"" << d._value << "\"]";
21+ os << d._key << " =\" " << d._value << " \" " ;
22+ return os;
1923}
20- template <class T >
21- std::ostream& operator <<( std::ostream& os, const SubDotEntry<T>& d )
24+ template <class T >
25+ std::ostream& operator <<(std::ostream& os, const SubDotEntry<T>& d)
2226{
23- os << d._key << " :\' " << d._value << " \'\\ n" ;
24- return os;
27+ os << d._key << " :\' " << d._value << " \'\\ n" ;
28+ return os;
2529}
2630}
2731
@@ -30,31 +34,35 @@ std::ostream& operator<<( std::ostream& os, const SubDotEntry<T>& d )
3034 * os << dotEntry( "label", "fooNode");
3135 * output: [label="fooNode"]
3236 */
33- template <class T >
34- detail::DotEntry<T> dotEntry ( const std::string& key, const T& value )
37+ template <class T >
38+ detail::DotEntry<T> dotEntry (const std::string& key, const T& value)
3539{
36- return detail::DotEntry<T>( key, value );
40+ return detail::DotEntry<T>(key, value);
3741}
38- template <class T >
39- detail::SubDotEntry<T> subDotEntry ( const std::string& key, const T& value )
42+ template <class T >
43+ detail::SubDotEntry<T> subDotEntry (const std::string& key, const T& value)
4044{
41- return detail::SubDotEntry<T>( key, value );
45+ return detail::SubDotEntry<T>(key, value);
4246}
4347
44- namespace detail {
48+ namespace detail
49+ {
4550template <class Name >
4651class simple_node_writer
4752{
4853public:
49- simple_node_writer ( Name _name ) : name( _name ) {}
50- template <class VertexOrEdge >
51- void operator ()( std::ostream& out, const VertexOrEdge& v ) const
52- {
53- out << " [ " << get ( name, v ) << " ]" ;
54- }
54+ simple_node_writer (Name _name)
55+ : name(_name)
56+ {
57+ }
58+ template <class VertexOrEdge >
59+ void operator ()(std::ostream& out, const VertexOrEdge& v) const
60+ {
61+ out << " [ " << get (name, v) << " ]" ;
62+ }
5563
5664private:
57- Name name;
65+ Name name;
5866};
5967}
6068
@@ -64,105 +72,104 @@ private:
6472 * instead of: [label="fooNode"]
6573 */
6674template <class Name >
67- inline detail::simple_node_writer<Name> make_simple_node_writer ( Name n )
75+ inline detail::simple_node_writer<Name> make_simple_node_writer (Name n)
6876{
69- return detail::simple_node_writer<Name>( n );
77+ return detail::simple_node_writer<Name>(n );
7078}
7179
72- template <typename Vertex, typename ProcessEdge, typename OutEdgeList, typename VertexList, typename EdgeList>
73- inline void exportSimple ( std::ostream& os, const InternalGraph<Vertex, ProcessEdge, OutEdgeList, VertexList, EdgeList>& g )
80+ template <typename Vertex, typename ProcessEdge, typename OutEdgeList, typename VertexList, typename EdgeList>
81+ inline void exportSimple (std::ostream& os, const InternalGraph<Vertex, ProcessEdge, OutEdgeList, VertexList, EdgeList>& g)
7482{
75- using namespace boost ;
76- boost::write_graphviz ( os, g.getGraph (),
77- make_simple_node_writer ( get ( &Vertex::_name, g.getGraph () ) ),
78- make_simple_node_writer ( get ( &ProcessEdge::_name, g.getGraph () ) ) );
83+ using namespace boost ;
84+ boost::write_graphviz (os, g.getGraph (), make_simple_node_writer (get (&Vertex::_name, g.getGraph ())),
85+ make_simple_node_writer (get (&ProcessEdge::_name, g.getGraph ())));
7986}
8087
81- template <typename Vertex, typename ProcessEdge, typename OutEdgeList, typename VertexList, typename EdgeList>
82- inline void exportAsDOT ( std::ostream& os, const InternalGraph<Vertex, ProcessEdge, OutEdgeList, VertexList, EdgeList>& g )
88+ template <typename Vertex, typename ProcessEdge, typename OutEdgeList, typename VertexList, typename EdgeList>
89+ inline void exportAsDOT (std::ostream& os, const InternalGraph<Vertex, ProcessEdge, OutEdgeList, VertexList, EdgeList>& g)
8390{
84- std::map<std::string, std::string> graph_attr, vertex_attr, edge_attr;
85- graph_attr[" size" ] = " 6,6" ;
86- graph_attr[" rankdir" ] = " LR" ;
87- graph_attr[" ratio" ] = " fill" ;
88- graph_attr[" label" ] = " TuttleOFX" ;
89- vertex_attr[" shape" ] = " circle" ;
90- vertex_attr[" color" ] = " dodgerblue4" ;
91- vertex_attr[" fontcolor" ] = " dodgerblue4" ;
92- edge_attr[" style" ] = " dashed" ;
93- edge_attr[" minlen" ] = " 1" ;
94- edge_attr[" color" ] = " darkslategray" ;
95- edge_attr[" fontcolor" ] = " darkslategray" ;
96-
97- using namespace boost ;
98- boost::write_graphviz ( os,
99- g.getGraph (),
100- boost::make_label_writer ( get ( &IVertex::_name, g.getGraph () ) ),
101- boost::make_label_writer ( get ( &IEdge::_name, g.getGraph () ) ),
102- boost::make_graph_attributes_writer ( graph_attr, vertex_attr, edge_attr ) );
103- }
104-
105- template <typename Vertex, typename ProcessEdge, typename OutEdgeList, typename VertexList, typename EdgeList>
106- inline void exportAsDOT ( const std::string& filename, const InternalGraph<Vertex, ProcessEdge, OutEdgeList, VertexList, EdgeList>& g )
91+ std::map<std::string, std::string> graph_attr, vertex_attr, edge_attr;
92+ graph_attr[" size" ] = " 6,6" ;
93+ graph_attr[" rankdir" ] = " LR" ;
94+ graph_attr[" ratio" ] = " fill" ;
95+ graph_attr[" label" ] = " TuttleOFX" ;
96+ vertex_attr[" shape" ] = " circle" ;
97+ vertex_attr[" color" ] = " dodgerblue4" ;
98+ vertex_attr[" fontcolor" ] = " dodgerblue4" ;
99+ edge_attr[" style" ] = " dashed" ;
100+ edge_attr[" minlen" ] = " 1" ;
101+ edge_attr[" color" ] = " darkslategray" ;
102+ edge_attr[" fontcolor" ] = " darkslategray" ;
103+
104+ using namespace boost ;
105+ boost::write_graphviz (os, g.getGraph (), boost::make_label_writer (get (&IVertex::_name, g.getGraph ())),
106+ boost::make_label_writer (get (&IEdge::_name, g.getGraph ())),
107+ boost::make_graph_attributes_writer (graph_attr, vertex_attr, edge_attr));
108+ }
109+
110+ template <typename Vertex, typename ProcessEdge, typename OutEdgeList, typename VertexList, typename EdgeList>
111+ inline void exportAsDOT (const std::string& filename,
112+ const InternalGraph<Vertex, ProcessEdge, OutEdgeList, VertexList, EdgeList>& g)
107113{
108- std::ofstream ofs ( filename.c_str () );
114+ std::ofstream ofs (filename.c_str ());
109115
110- exportAsDOT ( ofs, g );
116+ exportAsDOT (ofs, g);
111117}
112118
113- namespace detail {
119+ namespace detail
120+ {
114121template <class Graph >
115122struct debug_node_writer
116123{
117- debug_node_writer ( const Graph& graph ) : _graph( graph ) {}
118- template <class VertexOrEdge >
119- void operator ()( std::ostream& out, const VertexOrEdge& vd ) const
120- {
121- _graph.instance (vd).exportDotDebug (out);
122- }
123- const Graph& _graph;
124+ debug_node_writer (const Graph& graph)
125+ : _graph(graph)
126+ {
127+ }
128+ template <class VertexOrEdge >
129+ void operator ()(std::ostream& out, const VertexOrEdge& vd) const
130+ {
131+ _graph.instance (vd).exportDotDebug (out);
132+ }
133+ const Graph& _graph;
124134};
125135}
126136
127- template <class Graph >
128- inline detail::debug_node_writer<Graph> make_debug_node_writer ( const Graph g )
137+ template <class Graph >
138+ inline detail::debug_node_writer<Graph> make_debug_node_writer (const Graph g)
129139{
130- return detail::debug_node_writer<Graph>( g );
140+ return detail::debug_node_writer<Graph>(g );
131141}
132142
133- template <typename Vertex, typename ProcessEdge, typename OutEdgeList, typename VertexList, typename EdgeList>
134- inline void exportDebugAsDOT ( std::ostream& os, const InternalGraph<Vertex, ProcessEdge, OutEdgeList, VertexList, EdgeList>& g )
143+ template <typename Vertex, typename ProcessEdge, typename OutEdgeList, typename VertexList, typename EdgeList>
144+ inline void exportDebugAsDOT (std::ostream& os,
145+ const InternalGraph<Vertex, ProcessEdge, OutEdgeList, VertexList, EdgeList>& g)
135146{
136- std::map<std::string, std::string> graph_attr, vertex_attr, edge_attr;
137- graph_attr[" size" ] = " 6,6" ;
138- graph_attr[" rankdir" ] = " LR" ;
139- graph_attr[" ratio" ] = " fill" ;
140- graph_attr[" label" ] = " TuttleOFX" ;
141- vertex_attr[" shape" ] = " circle" ;
142- vertex_attr[" color" ] = " dodgerblue4" ;
143- vertex_attr[" fontcolor" ] = " dodgerblue4" ;
144- edge_attr[" style" ] = " dashed" ;
145- edge_attr[" minlen" ] = " 1" ;
146- edge_attr[" color" ] = " darkslategray" ;
147- edge_attr[" fontcolor" ] = " darkslategray" ;
148-
149- using namespace boost ;
150- boost::write_graphviz ( os,
151- g.getGraph (),
152- make_debug_node_writer (g),
153- make_debug_node_writer (g),
154- boost::make_graph_attributes_writer ( graph_attr, vertex_attr, edge_attr ) );
155- }
156-
157- template <typename Vertex, typename ProcessEdge, typename OutEdgeList, typename VertexList, typename EdgeList>
158- inline void exportDebugAsDOT ( const std::string& filename, const InternalGraph<Vertex, ProcessEdge, OutEdgeList, VertexList, EdgeList>& g )
147+ std::map<std::string, std::string> graph_attr, vertex_attr, edge_attr;
148+ graph_attr[" size" ] = " 6,6" ;
149+ graph_attr[" rankdir" ] = " LR" ;
150+ graph_attr[" ratio" ] = " fill" ;
151+ graph_attr[" label" ] = " TuttleOFX" ;
152+ vertex_attr[" shape" ] = " circle" ;
153+ vertex_attr[" color" ] = " dodgerblue4" ;
154+ vertex_attr[" fontcolor" ] = " dodgerblue4" ;
155+ edge_attr[" style" ] = " dashed" ;
156+ edge_attr[" minlen" ] = " 1" ;
157+ edge_attr[" color" ] = " darkslategray" ;
158+ edge_attr[" fontcolor" ] = " darkslategray" ;
159+
160+ using namespace boost ;
161+ boost::write_graphviz (os, g.getGraph (), make_debug_node_writer (g), make_debug_node_writer (g),
162+ boost::make_graph_attributes_writer (graph_attr, vertex_attr, edge_attr));
163+ }
164+
165+ template <typename Vertex, typename ProcessEdge, typename OutEdgeList, typename VertexList, typename EdgeList>
166+ inline void exportDebugAsDOT (const std::string& filename,
167+ const InternalGraph<Vertex, ProcessEdge, OutEdgeList, VertexList, EdgeList>& g)
159168{
160- std::ofstream ofs ( filename.c_str () );
169+ std::ofstream ofs (filename.c_str ());
161170
162- exportDebugAsDOT ( ofs, g );
171+ exportDebugAsDOT (ofs, g);
163172}
164-
165173}
166174}
167175}
168-
0 commit comments