GEGELATI
tpgGraphDotExporter.h
1
38#ifndef TPG_GRAPH_DOT_EXPORTER_H
39#define TPG_GRAPH_DOT_EXPORTER_H
40
41#include <map>
42#include <stdexcept>
43#include <string>
44
45#include "program/line.h"
46#include "program/program.h"
47#include "tpg/tpgAbstractEngine.h"
48#include "tpg/tpgAction.h"
49#include "tpg/tpgEdge.h"
50#include "tpg/tpgGraph.h"
51#include "tpg/tpgTeam.h"
52#include "tpg/tpgVertex.h"
53
54namespace File {
60 {
61 protected:
65 FILE* pFile;
66
71 std::string offset;
72
81 void printTPGTeam(const TPG::TPGTeam& team);
82
96 uint64_t printTPGAction(const TPG::TPGAction& action);
97
108 void printTPGEdge(const TPG::TPGEdge& edge);
109
125 void printProgram(const Program::Program& program);
126
133 void printTPGGraphHeader();
134
141 void printTPGGraphFooter();
142
143 public:
154 TPGGraphDotExporter(const char* filePath, const TPG::TPGGraph& graph)
155 : TPG::TPGAbstractEngine(graph), pFile{NULL}, offset{""}
156 {
157 if ((pFile = fopen(filePath, "w")) == NULL) {
158 throw std::runtime_error("Could not open file " +
159 std::string(filePath));
160 }
161 };
162
170
178 delete;
179
186 {
187 if (pFile != NULL) {
188 fclose(pFile);
189 }
190 }
191
200 void setNewFilePath(const char* newFilePath)
201 {
202 // Close previous file
203 fclose(pFile);
204
205 // open new one;
206 if ((pFile = fopen(newFilePath, "w")) == NULL) {
207 pFile = NULL;
208 throw std::runtime_error("Could not open file " +
209 std::string(newFilePath));
210 }
211 }
212
217 void print();
218 };
219}; // namespace File
220
221#endif
Class used to export a TPGGraph into a text file with the dot format.
Definition: tpgGraphDotExporter.h:60
TPGGraphDotExporter & operator=(const TPGGraphDotExporter &other)=delete
std::string offset
Character chain used to control the indentation of the exported file.
Definition: tpgGraphDotExporter.h:71
void setNewFilePath(const char *newFilePath)
Set a new file for the exporter.
Definition: tpgGraphDotExporter.h:200
TPGGraphDotExporter(const char *filePath, const TPG::TPGGraph &graph)
Constructor for the exporter.
Definition: tpgGraphDotExporter.h:154
void printTPGGraphHeader()
Prints header content in the dot file.
Definition: tpgGraphDotExporter.cpp:134
uint64_t printTPGAction(const TPG::TPGAction &action)
Print the dot content for the given TPGAction.
Definition: tpgGraphDotExporter.cpp:58
FILE * pFile
File in which the dot content is written during export.
Definition: tpgGraphDotExporter.h:65
void printTPGEdge(const TPG::TPGEdge &edge)
Prints the dot content for the given TPGEdge. Prints the program index followed by its contants if th...
Definition: tpgGraphDotExporter.cpp:67
void printTPGGraphFooter()
Prints footer content in the dot file.
Definition: tpgGraphDotExporter.cpp:150
void printTPGTeam(const TPG::TPGTeam &team)
Print the dot content for the given TPGTeam.
Definition: tpgGraphDotExporter.cpp:42
void print()
Print the TPGGraph given when constructing the TPGGraphDotExporter into a dot file.
Definition: tpgGraphDotExporter.cpp:179
~TPGGraphDotExporter()
Definition: tpgGraphDotExporter.h:185
void printProgram(const Program::Program &program)
Prints the dot content for the given Program.
Definition: tpgGraphDotExporter.cpp:105
TPGGraphDotExporter(const TPGGraphDotExporter &other)=delete
The Program class contains a list of program lines that can be executed within a well defined Environ...
Definition: program.h:53
Abstract Class in charge of managing maps to give a unique ID for vertex and a program of a TPGGraph.
Definition: tpgAbstractEngine.h:49
TPGAbstractEngine(const TPG::TPGGraph &tpg)
Constructor for the abstract engine.
Definition: tpgAbstractEngine.h:110
Class representing an Action of a TPGGraph.
Definition: tpgAction.h:52
Class representing edges of the Tangled Program Graphs.
Definition: tpgEdge.h:51
Class for storing a Tangled-Program-Graph.
Definition: tpgGraph.h:54
Definition: tpgTeam.h:48
Definition: parametersParser.h:51
Definition: tpgActionInstrumented.h:8