GEGELATI

Loading...
Searching...
No Matches
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 {
59 class TPGGraphDotExporter : TPG::TPGAbstractEngine
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
169 TPGGraphDotExporter(const TPGGraphDotExporter& other) = delete;
170
177 TPGGraphDotExporter& operator=(const TPGGraphDotExporter& other) =
178 delete;
179
185 ~TPGGraphDotExporter()
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
232 void printSubGraph(const TPG::TPGVertex* root);
233 };
234}; // namespace File
235
236#endif
File::TPGGraphDotExporter
Class used to export a TPGGraph into a text file with the dot format.
Definition tpgGraphDotExporter.h:60
File::TPGGraphDotExporter::operator=
TPGGraphDotExporter & operator=(const TPGGraphDotExporter &other)=delete
File::TPGGraphDotExporter::offset
std::string offset
Character chain used to control the indentation of the exported file.
Definition tpgGraphDotExporter.h:71
File::TPGGraphDotExporter::setNewFilePath
void setNewFilePath(const char *newFilePath)
Set a new file for the exporter.
Definition tpgGraphDotExporter.h:200
File::TPGGraphDotExporter::TPGGraphDotExporter
TPGGraphDotExporter(const char *filePath, const TPG::TPGGraph &graph)
Constructor for the exporter.
Definition tpgGraphDotExporter.h:154
File::TPGGraphDotExporter::printTPGGraphHeader
void printTPGGraphHeader()
Prints header content in the dot file.
Definition tpgGraphDotExporter.cpp:188
File::TPGGraphDotExporter::printTPGAction
uint64_t printTPGAction(const TPG::TPGAction &action)
Print the dot content for the given TPGAction.
Definition tpgGraphDotExporter.cpp:59
File::TPGGraphDotExporter::pFile
FILE * pFile
File in which the dot content is written during export.
Definition tpgGraphDotExporter.h:65
File::TPGGraphDotExporter::printTPGEdge
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:99
File::TPGGraphDotExporter::printTPGGraphFooter
void printTPGGraphFooter()
Prints footer content in the dot file.
Definition tpgGraphDotExporter.cpp:211
File::TPGGraphDotExporter::printTPGTeam
void printTPGTeam(const TPG::TPGTeam &team)
Print the dot content for the given TPGTeam.
Definition tpgGraphDotExporter.cpp:45
File::TPGGraphDotExporter::printSubGraph
void printSubGraph(const TPG::TPGVertex *root)
Print a sub-tree of the TPGGraph given when constructing the TPGGraphDotExporter into a dot file.
Definition tpgGraphDotExporter.cpp:285
File::TPGGraphDotExporter::print
void print()
Print the TPGGraph given when constructing the TPGGraphDotExporter into a dot file.
Definition tpgGraphDotExporter.cpp:249
File::TPGGraphDotExporter::~TPGGraphDotExporter
~TPGGraphDotExporter()
Definition tpgGraphDotExporter.h:185
File::TPGGraphDotExporter::printProgram
void printProgram(const Program::Program &program)
Prints the dot content for the given Program.
Definition tpgGraphDotExporter.cpp:160
File::TPGGraphDotExporter::TPGGraphDotExporter
TPGGraphDotExporter(const TPGGraphDotExporter &other)=delete
Program::Program
The Program class contains a list of program lines that can be executed within a well defined Environ...
Definition program.h:57
TPG::TPGAbstractEngine
Abstract Class in charge of managing maps to give a unique ID for vertex and a program of a TPGGraph.
Definition tpgAbstractEngine.h:49
TPG::TPGAbstractEngine::TPGAbstractEngine
TPGAbstractEngine(const TPG::TPGGraph &tpg)
Constructor for the abstract engine.
Definition tpgAbstractEngine.h:79
TPG::TPGAction
Class representing an Action of a TPGGraph.
Definition tpgAction.h:55
TPG::TPGEdge
Class representing edges of the Tangled Program Graphs.
Definition tpgEdge.h:54
TPG::TPGGraph
Class for storing a Tangled-Program-Graph.
Definition tpgGraph.h:58
TPG::TPGTeam
Definition tpgTeam.h:49
TPG::TPGVertex
Abstract class representing the vertices of a TPGGraph.
Definition tpgVertex.h:55
File
Definition parametersParser.h:51
TPG
Definition executionStats.h:44