degate  0.1.2
Public Member Functions | Protected Member Functions | Private Attributes
degate::DOTExporter Class Reference

Base class for a .dot exporter. More...

#include <DOTExporter.h>

Inheritance diagram for degate::DOTExporter:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 DOTExporter ()
 Create a DOTExporter object.
virtual ~DOTExporter ()
 Destroy the DOTExporter object.

Protected Member Functions

void add_header_line (std::string header_line)
 Add a header line.
void add_graph_setting (std::string line)
 Add a setting for a graph.
void add_node (std::string node_id, std::string node_params)
 Add a node into the graph.
void add_edge (std::string from_node_id, std::string to_node_id, std::string edge_params)
 Add an edge into the graph.
void dump_to_file (std::string const &filename) const
 Dump the content as a string into a file.
void clear ()
 Clear any internally stored data.

Private Attributes

std::list< std::string > header_lines
std::list< std::string > graph_setting_lines
std::list< std::string > node_lines
std::list< std::string > edge_lines

Detailed Description

Base class for a .dot exporter.

The dot language is a graph description language.

See also:
http://en.wikipedia.org/wiki/DOT_language

Definition at line 44 of file DOTExporter.h.


Constructor & Destructor Documentation

Create a DOTExporter object.

Definition at line 105 of file DOTExporter.h.

{};
virtual degate::DOTExporter::~DOTExporter ( ) [inline, virtual]

Destroy the DOTExporter object.

Definition at line 110 of file DOTExporter.h.

{};

Member Function Documentation

void DOTExporter::add_edge ( std::string  from_node_id,
std::string  to_node_id,
std::string  edge_params 
) [protected]

Add an edge into the graph.

Definition at line 43 of file DOTExporter.cc.

References edge_lines.

                                                  {
  std::string txt(from_node_id);
  txt += std::string(" -- ");
  txt += to_node_id;
  txt += edge_params;
  edge_lines.push_back(txt);
}
void DOTExporter::add_graph_setting ( std::string  line) [protected]

Add a setting for a graph.

Definition at line 33 of file DOTExporter.cc.

References graph_setting_lines.

                                                  {
  graph_setting_lines.push_back(line);
}
void DOTExporter::add_header_line ( std::string  header_line) [protected]

Add a header line.

Header lines begin with a hash mark ('#'). It is a comment in the dot language. Header lines should be used to write comments to the top of a dot file.

Parameters:
header_lineA single comment line. You don't have to put the hash mark in front of the string. If you pass a multi line string, the hash marks for the additional lines are not added automatically.

Definition at line 29 of file DOTExporter.cc.

References header_lines.

                                                       {
  header_lines.push_back(std::string("# ") + header_line);
}
void DOTExporter::add_node ( std::string  node_id,
std::string  node_params 
) [protected]

Add a node into the graph.

Definition at line 38 of file DOTExporter.cc.

References node_lines.

                                                                   {
  node_lines.push_back(node_id + node_params);
}
void DOTExporter::clear ( ) [protected]

Clear any internally stored data.

Definition at line 91 of file DOTExporter.cc.

References edge_lines, graph_setting_lines, header_lines, and node_lines.

                        {
  header_lines.clear();
  graph_setting_lines.clear();
  node_lines.clear();
  edge_lines.clear();
}
void DOTExporter::dump_to_file ( std::string const &  filename) const [protected]

Dump the content as a string into a file.

If the file already exists, it will be overwritten.

Definition at line 54 of file DOTExporter.cc.

References edge_lines, graph_setting_lines, header_lines, and node_lines.

                                                              {

  std::ofstream dot_file;

  dot_file.open(filename.c_str(), std::ios::trunc | std:: ios::out);

  // write header

  for(std::list<std::string>::const_iterator iter = header_lines.begin();
      iter != header_lines.end(); ++iter) {
    dot_file << *iter << std::endl;
  }

  dot_file << "graph LogicModel {" << std::endl;

  for(std::list<std::string>::const_iterator iter = graph_setting_lines.begin();
      iter != graph_setting_lines.end(); ++iter) {
    dot_file << "\t" << *iter << std::endl;
  }


  // nodes
  for(std::list<std::string>::const_iterator iter = node_lines.begin();
      iter != node_lines.end(); ++iter)
    dot_file << "\t" << *iter << std::endl;

  // edges
  for(std::list<std::string>::const_iterator iter = edge_lines.begin();
      iter != edge_lines.end(); ++iter)
    dot_file << "\t" << *iter << std::endl;


  dot_file << "}" << std::endl;

  dot_file.close();
}

Member Data Documentation

std::list<std::string> degate::DOTExporter::edge_lines [private]

Definition at line 51 of file DOTExporter.h.

Referenced by add_edge(), clear(), and dump_to_file().

std::list<std::string> degate::DOTExporter::graph_setting_lines [private]

Definition at line 49 of file DOTExporter.h.

Referenced by add_graph_setting(), clear(), and dump_to_file().

std::list<std::string> degate::DOTExporter::header_lines [private]

Definition at line 48 of file DOTExporter.h.

Referenced by add_header_line(), clear(), and dump_to_file().

std::list<std::string> degate::DOTExporter::node_lines [private]

Definition at line 50 of file DOTExporter.h.

Referenced by add_node(), clear(), and dump_to_file().


The documentation for this class was generated from the following files: