38#ifndef TPG_GRAPH_DOT_IMPORTER_H
39#define TPG_GRAPH_DOT_IMPORTER_H
50#include "learn/learningEnvironment.h"
51#include "tpg/tpgAction.h"
52#include "tpg/tpgEdge.h"
53#include "tpg/tpgGraph.h"
54#include "tpg/tpgTeam.h"
55#include "tpg/tpgVertex.h"
94 std::map<uint64_t, const TPG::TPGVertex*>
vertexID;
103 std::map<uint64_t, std::shared_ptr<Program::Program>>
programID;
112 std::map<uint64_t, const TPG::TPGVertex*>
actionID;
328 void readLine(std::smatch& matches);
346 void readTeam(std::smatch& matches);
390 :
env{environment},
tpg{tpgref}
392 pFile.open(filePath);
393 if (!
pFile.is_open()) {
394 throw std::runtime_error(
"Could not open file " +
395 std::string(filePath));
413 if (
pFile.is_open()) {
The Environment class contains all information needed to execute a Program.
Definition: environment.h:84
Class used to import a TPG graph from a dot file. It should be able to import a whole Learning agent ...
Definition: tpgGraphDotImporter.h:63
void readLinkTeamProgram(std::smatch &matches)
reads a link declaration and creates a team to program's destination edge.
Definition: tpgGraphDotImporter.cpp:275
void importGraph()
Creates a TPG Graph from its description in a .dot file.
Definition: tpgGraphDotImporter.cpp:309
void readLinkTeamProgramTeam(std::smatch &matches)
reads a link declaration and creates a team to team edge
Definition: tpgGraphDotImporter.cpp:249
TPGGraphDotImporter(const char *filePath, Environment environment, TPG::TPGGraph &tpgref)
Constructor for the importer.
Definition: tpgGraphDotImporter.h:388
void readAction(std::smatch &matches)
reads and creates a TPGAction.
Definition: tpgGraphDotImporter.cpp:203
void readOperands(std::string &str, Program::Line &line)
Reads the content of the operands and puts it in the line passed in parameter.
Definition: tpgGraphDotImporter.cpp:57
static const std::string lineSeparator
string used to spot the end of a line in the program description.
Definition: tpgGraphDotImporter.h:126
TPG::TPGGraph & tpg
TPGGraph imported from dot file.
Definition: tpgGraphDotImporter.h:85
std::ifstream pFile
File in which the dot content is read during import.
Definition: tpgGraphDotImporter.h:68
~TPGGraphDotImporter()
Definition: tpgGraphDotImporter.h:411
void readTeam(std::smatch &matches)
reads and creates a TPGTeam.
Definition: tpgGraphDotImporter.cpp:195
std::string lastLine
last Line read from file
Definition: tpgGraphDotImporter.h:75
void readProgram(std::smatch &matches)
Create a program from its dot content and import its constants.
Definition: tpgGraphDotImporter.cpp:151
static const std::string linkProgramInstructionRegex
contains the regex to identify a Program -> Instruction Link
Definition: tpgGraphDotImporter.h:234
static const std::string addLinkProgramRegex
contains the regex to identify a Team -> Program Link the outgoing program vertex must already have b...
Definition: tpgGraphDotImporter.h:313
static const std::string teamRegex
Contains the regex to identify a team declaration.
Definition: tpgGraphDotImporter.h:147
static const std::string instructionRegex
contains the regex to identify an instruction declaration
Definition: tpgGraphDotImporter.h:190
static const std::string linkProgramTeamRegex
contains the regex to identify a Team -> Program -> Team Link
Definition: tpgGraphDotImporter.h:291
Environment env
The environment in which the TPGGRAPH will be built.
Definition: tpgGraphDotImporter.h:80
std::map< uint64_t, const TPG::TPGVertex * > actionID
Map associating pointers to TPGVertex representing actions to the corresponding action.
Definition: tpgGraphDotImporter.h:112
void readLine(std::smatch &matches)
Reads the content of a line and puts it in the line passed in parameter.
Definition: tpgGraphDotImporter.cpp:85
void dumpTPGGraphHeader()
dumps the header of the dot file
Definition: tpgGraphDotImporter.cpp:186
std::map< uint64_t, std::shared_ptr< Program::Program > > programID
Map associating pointers to Program to an integer ID.
Definition: tpgGraphDotImporter.h:103
std::map< uint64_t, const TPG::TPGVertex * > vertexID
Map associating pointers to TPGVertex to an integer ID.
Definition: tpgGraphDotImporter.h:94
static const std::string actionRegex
contains the regex to identify an action declaration
Definition: tpgGraphDotImporter.h:212
void readLinkTeamProgramAction(std::smatch &matches)
reads a link declaration and creates a team to action edge
Definition: tpgGraphDotImporter.cpp:223
bool readLineFromFile()
Definition: tpgGraphDotImporter.cpp:329
static const std::string linkProgramActionRegex
contains the regex to identify a Team -> Program -> Action Link
Definition: tpgGraphDotImporter.h:263
static const std::string programRegex
Contains the regex to identify a program declaration.
Definition: tpgGraphDotImporter.h:168
void setNewFilePath(const char *newFilePath)
Set a new file for the importer.
Definition: tpgGraphDotImporter.cpp:385
static const unsigned int MAX_READ_SIZE
Maximum number of characters that can be read in a single line.
Definition: tpgGraphDotImporter.h:404
std::map< uint64_t, uint64_t > actionLabel
Map associating actions to the corresponding action ID.
Definition: tpgGraphDotImporter.h:120
Class for storing a Tangled-Program-Graph.
Definition: tpgGraph.h:54
Definition: parametersParser.h:51