|
degate 0.1.1
|
00001 /* -*-c++-*- 00002 00003 This file is part of the IC reverse engineering tool degate. 00004 00005 Copyright 2008, 2009, 2010 by Martin Schobert 00006 00007 Degate is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 any later version. 00011 00012 Degate is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with degate. If not, see <http://www.gnu.org/licenses/>. 00019 00020 */ 00021 00022 #ifndef __DOTEXPORTER_H__ 00023 #define __DOTEXPORTER_H__ 00024 00025 #include "globals.h" 00026 #include "Exporter.h" 00027 #include <string> 00028 #include <list> 00029 #include <map> 00030 #include <iostream> 00031 #include <fstream> 00032 00033 namespace degate { 00034 00035 00036 /** 00037 * Base class for a .dot exporter. 00038 * 00039 * The dot language is a graph description language. 00040 * 00041 * @see http://en.wikipedia.org/wiki/DOT_language 00042 * 00043 */ 00044 class DOTExporter : public Exporter { 00045 00046 private: 00047 00048 std::list<std::string> header_lines; 00049 std::list<std::string> graph_setting_lines; 00050 std::list<std::string> node_lines; 00051 std::list<std::string> edge_lines; 00052 00053 protected: 00054 00055 /** 00056 * Add a header line. 00057 * 00058 * Header lines begin with a hash mark ('#'). It is a comment 00059 * in the dot language. Header lines should be used to write 00060 * comments to the top of a dot file. 00061 * @param header_line A single comment line. You don't have to put the 00062 * hash mark in front of the string. If you pass a multi line string, 00063 * the hash marks for the additional lines are not added automatically. 00064 */ 00065 00066 void add_header_line(std::string header_line); 00067 00068 /** 00069 * Add a setting for a graph 00070 */ 00071 void add_graph_setting(std::string line); 00072 00073 /** 00074 * Add a node into the graph. 00075 */ 00076 00077 void add_node(std::string node_id, std::string node_params); 00078 00079 /** 00080 * Add an edge into the graph. 00081 */ 00082 00083 void add_edge(std::string from_node_id, 00084 std::string to_node_id, 00085 std::string edge_params); 00086 00087 /** 00088 * Dump the content as a string into a file. 00089 * If the file already exists, it will be overwritten. 00090 */ 00091 00092 void dump_to_file(std::string const& filename) const; 00093 00094 /** 00095 * Clear any internally stored data. 00096 */ 00097 00098 void clear(); 00099 00100 public: 00101 00102 /** 00103 * Create a DOTExporter object. 00104 */ 00105 DOTExporter() {}; 00106 00107 /** 00108 * Destroy the DOTExporter object. 00109 */ 00110 virtual ~DOTExporter() {}; 00111 00112 }; 00113 00114 } 00115 #endif
1.7.4