39#ifndef TPG_GRAPH_DOT_IMPORTER_H
40#define TPG_GRAPH_DOT_IMPORTER_H
51#include "learn/learningEnvironment.h"
52#include "tpg/tpgAction.h"
53#include "tpg/tpgEdge.h"
54#include "tpg/tpgGraph.h"
55#include "tpg/tpgTeam.h"
56#include "tpg/tpgVertex.h"
57#include "util/counterReset.h"
96 std::map<uint64_t, const TPG::TPGVertex*>
vertexID;
111 std::map<uint64_t, std::shared_ptr<Program::Program>>
programID;
120 std::map<uint64_t, const TPG::TPGAction*>
actionID;
352 void readLine(std::smatch& matches);
381 void readTeam(std::smatch& matches);
439 :
env{environment},
tpg{tpgref}
441 pFile.open(filePath);
442 if (!
pFile.is_open()) {
443 throw std::runtime_error(
"Could not open file " +
444 std::string(filePath));
462 if (
pFile.is_open()) {
The Environment class contains all information needed to execute a Program.
Definition environment.h:86
Class used to import a TPG graph from a dot file. It should be able to import a whole Learning agent ...
Definition tpgGraphDotImporter.h:65
void readLinkTeamProgram(std::smatch &matches)
reads a link declaration and creates a team to program's destination edge.
Definition tpgGraphDotImporter.cpp:367
void importGraph()
Creates a TPG Graph from its description in a .dot file.
Definition tpgGraphDotImporter.cpp:402
void readLinkTeamProgramTeam(std::smatch &matches)
reads a link declaration and creates a team to team edge
Definition tpgGraphDotImporter.cpp:341
TPGGraphDotImporter(const char *filePath, Environment environment, TPG::TPGGraph &tpgref)
Constructor for the importer.
Definition tpgGraphDotImporter.h:437
std::map< uint64_t, const TPG::TPGAction * > actionID
Map associating pointers to TPGVertex representing actions to the corresponding action.
Definition tpgGraphDotImporter.h:120
void readAction(std::smatch &matches)
reads and creates a TPGAction.
Definition tpgGraphDotImporter.cpp:247
static const std::string linkActionProgramRegex
contains the regex to identify a Team -> Program -> Action Link
Definition tpgGraphDotImporter.h:315
bool getExportedVersion(int &major, int &minor, int &patch)
reads the version of the dot file and returns it in the parameters.
Definition tpgGraphDotImporter.cpp:198
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:60
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:87
std::ifstream pFile
File in which the dot content is read during import.
Definition tpgGraphDotImporter.h:70
~TPGGraphDotImporter()
Definition tpgGraphDotImporter.h:460
void readTeam(std::smatch &matches)
reads and creates a TPGTeam.
Definition tpgGraphDotImporter.cpp:236
std::string lastLine
last Line read from file
Definition tpgGraphDotImporter.h:77
void readLinkActionProgram(std::smatch &matches)
reads a link declaration and creates a action edge
Definition tpgGraphDotImporter.cpp:292
void readProgram(std::smatch &matches)
Create a program from its dot content and import its constants.
Definition tpgGraphDotImporter.cpp:155
static const int supportedPatchVersion
The patch version supported by the importer.
Definition tpgGraphDotImporter.h:423
static const int supportedMajorVersion
The major version supported by the importer.
Definition tpgGraphDotImporter.h:419
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:337
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:82
void readLine(std::smatch &matches)
Reads the content of a line and puts it in the line passed in parameter.
Definition tpgGraphDotImporter.cpp:88
void dumpTPGGraphHeader()
dumps the header of the dot file
Definition tpgGraphDotImporter.cpp:219
std::map< uint64_t, std::shared_ptr< Program::Program > > programID
Map associating pointers to Program to an integer ID.
Definition tpgGraphDotImporter.h:111
std::map< uint64_t, const TPG::TPGVertex * > vertexID
Map associating pointers to TPGVertex to an integer ID.
Definition tpgGraphDotImporter.h:96
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:316
bool readLineFromFile()
Definition tpgGraphDotImporter.cpp:453
static const std::string linkProgramActionRegex
contains the regex to identify a Team -> Program -> Action Link
Definition tpgGraphDotImporter.h:263
static const int supportedMinorVersion
The minor version supported by the importer.
Definition tpgGraphDotImporter.h:421
std::map< const TPG::TPGAction *, std::vector< uint64_t > > actionClasses
Map associating pointers to TPGAction to a vector of integer action class.
Definition tpgGraphDotImporter.h:102
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:513
static const unsigned int MAX_READ_SIZE
Maximum number of characters that can be read in a single line.
Definition tpgGraphDotImporter.h:453
Class for storing a Tangled-Program-Graph.
Definition tpgGraph.h:58
Definition parametersParser.h:51