graph_writer.h
Go to the documentation of this file.
1 #ifndef ROSTATE_MACHINE_GRAPH_WRITER_H_INCLUDED
2 #define ROSTATE_MACHINE_GRAPH_WRITER_H_INCLUDED
3 
4 #include <ros/ros.h>
5 
6 using std::map;
7 template <typename Map>
8 struct NodeWriter
9 {
10  NodeWriter(Map& g_,std::string current_state_)
11  : g (g_), current_state(current_state_) {};
12  template <class Vertex>
13  void operator()(std::ostream& out, Vertex v)
14  {
15  if(g[v].name == current_state)
16  {
17  out << " [color=blue,fontsize=12,shape=ellipse,label=\"" << g[v].name << "\"]" << std::endl;
18  out << "[fontcolor=blue]" << std::endl;
19  }
20  else
21  {
22  out << " [color=black,fontsize=12,shape=ellipse,label=\"" << g[v].name << "\"]" << std::endl;
23  }
24  };
25  Map g;
26  std::string current_state;
27 };
28 
29 template <typename Map>
30 struct EdgeWriter
31 {
32  EdgeWriter(Map& g_) : g (g_) {};
33  template <class Edge>
34  void operator()(std::ostream& out, Edge e)
35  {
36  out << "[color=gray]" << std::endl;
37  out << "[fontsize=12]" << std::endl;
38  out << "[style=solid]" << std::endl;
39  out << "[fontcolor=black]" << std::endl;
40  out << "[label=\"" << g[e].trigger_event << "\"]" << std::endl;
41  };
42  Map g;
43 };
44 
46 {
47  void operator()(std::ostream& out) const
48  {
49  out << "graph [bgcolor=white]" << std::endl;
50  }
51 };
52 
53 #endif //ROSTATE_MACHINE_GRAPH_WRITER_H_INCLUDED
std::string current_state
Definition: graph_writer.h:26
void operator()(std::ostream &out, Vertex v)
Definition: graph_writer.h:13
void operator()(std::ostream &out) const
Definition: graph_writer.h:47
void operator()(std::ostream &out, Edge e)
Definition: graph_writer.h:34
NodeWriter(Map &g_, std::string current_state_)
Definition: graph_writer.h:10
EdgeWriter(Map &g_)
Definition: graph_writer.h:32


rostate_machine
Author(s):
autogenerated on Wed Sep 4 2019 05:19:52