GEGELATI
tpgGraph.h
1
37#ifndef TPG_GRAPH_H
38#define TPG_GRAPH_H
39
40#include <list>
41
42#include "environment.h"
43#include "tpg/tpgAction.h"
44#include "tpg/tpgEdge.h"
45#include "tpg/tpgFactory.h"
46#include "tpg/tpgTeam.h"
47#include "tpg/tpgVertex.h"
48
49namespace TPG {
54 {
55 public:
63 std::unique_ptr<TPGFactory> f = std::make_unique<TPGFactory>())
64 : env{e}, factory{std::move(f)} {};
65
69 TPGGraph(const TPGGraph& model) = delete;
70
76 TPGGraph(TPGGraph&& model) noexcept : env{model.getEnvironment()}
77 {
78 swap(*this, model);
79 }
80
86 friend inline void swap(TPGGraph& a, TPGGraph& b)
87 {
88 using std::swap;
90 swap(a.edges, b.edges);
91 }
92
97
103 virtual ~TPGGraph();
104
108 void clear();
109
115 const Environment& getEnvironment() const;
116
122 const TPGFactory& getFactory() const;
123
133 const TPGTeam& addNewTeam();
134
145 const TPGAction& addNewAction(uint64_t actionID);
146
152 size_t getNbVertices() const;
153
163 const std::vector<const TPGVertex*> getVertices() const;
164
170 uint64_t getNbRootVertices() const;
171
183 const std::vector<const TPGVertex*> getRootVertices() const;
184
192 bool hasVertex(const TPG::TPGVertex& vertex) const;
193
202 void removeVertex(const TPGVertex& vertex);
203
212 const TPGVertex& cloneVertex(const TPGVertex& vertex);
213
233 const TPGEdge& addNewEdge(const TPGVertex& src, const TPGVertex& dest,
234 const std::shared_ptr<Program::Program> prog);
235
241 const std::list<std::unique_ptr<TPGEdge>>& getEdges() const;
242
254 void removeEdge(const TPGEdge& edge);
255
268 const TPGEdge& cloneEdge(const TPGEdge& edge);
269
281 bool setEdgeDestination(const TPGEdge& edge, const TPGVertex& newDest);
282
294 bool setEdgeSource(const TPGEdge& edge, const TPGVertex& newSrc);
295
302 void clearProgramIntrons();
303
304 protected:
307
309 const std::unique_ptr<TPGFactory> factory;
310
314 std::list<TPGVertex*> vertices;
315
319 std::list<std::unique_ptr<TPGEdge>> edges;
320
330 std::list<TPGVertex*>::iterator findVertex(const TPGVertex* vertex);
331
341 std::list<std::unique_ptr<TPGEdge>>::iterator findEdge(
342 const TPGEdge* edge);
343 };
344}; // namespace TPG
345
346#endif
The Environment class contains all information needed to execute a Program.
Definition: environment.h:84
Class representing an Action of a TPGGraph.
Definition: tpgAction.h:52
Class representing edges of the Tangled Program Graphs.
Definition: tpgEdge.h:51
Factory for creating all elements constituting a TPG.
Definition: tpgFactory.h:34
Class for storing a Tangled-Program-Graph.
Definition: tpgGraph.h:54
const std::vector< const TPGVertex * > getVertices() const
Get vector of const pointer to the vertices of the TPGGraph.
Definition: tpgGraph.cpp:93
void clear()
Empty the TPGGraph of all its content.
Definition: tpgGraph.cpp:58
const TPGEdge & cloneEdge(const TPGEdge &edge)
Definition: tpgGraph.cpp:242
std::list< TPGVertex * > vertices
Set of TPGVertex composing the TPGGraph.
Definition: tpgGraph.h:314
const TPGTeam & addNewTeam()
Create a new TPGTeam and add it to the vertices of the TPGGraph.
Definition: tpgGraph.cpp:76
TPGGraph(const Environment &e, std::unique_ptr< TPGFactory > f=std::make_unique< TPGFactory >())
Main TPGGraph constructor.
Definition: tpgGraph.h:62
const std::unique_ptr< TPGFactory > factory
TPGFactory of the TPGGraph.
Definition: tpgGraph.h:309
const TPGEdge & addNewEdge(const TPGVertex &src, const TPGVertex &dest, const std::shared_ptr< Program::Program > prog)
Add a new TPGEdge to the TPGGraph.
Definition: tpgGraph.cpp:178
bool setEdgeSource(const TPGEdge &edge, const TPGVertex &newSrc)
Change the source of the TPGEdge to the given vertex.
Definition: tpgGraph.cpp:283
TPGGraph(TPGGraph &&model) noexcept
TPGGraph move assignment operator.
Definition: tpgGraph.h:76
TPGGraph & operator=(TPGGraph model)
assignement operator for class TPGGraph
Definition: tpgGraph.cpp:52
std::list< std::unique_ptr< TPGEdge > > edges
Set of TPGEdge composing the TPGGraph.
Definition: tpgGraph.h:319
TPGGraph(const TPGGraph &model)=delete
delete copy constructor
bool hasVertex(const TPG::TPGVertex &vertex) const
Check whether a given vertex exists in the TPGGraph.
Definition: tpgGraph.cpp:118
const TPGFactory & getFactory() const
Get a reference to the TPGFactory of the TPGGraph.
Definition: tpgGraph.cpp:71
const std::vector< const TPGVertex * > getRootVertices() const
Get vector of const pointer to the root vertices of the TPGGraph.
Definition: tpgGraph.cpp:108
virtual ~TPGGraph()
Destructor for the TPGGraph.
Definition: tpgGraph.cpp:43
const Environment & env
Environment of the TPGGraph.
Definition: tpgGraph.h:306
size_t getNbVertices() const
Get the number of TPGVertex contained in the TPGGraph.
Definition: tpgGraph.cpp:88
void removeEdge(const TPGEdge &edge)
Remove a TPGEdge from the TPGGraph.
Definition: tpgGraph.cpp:220
std::list< std::unique_ptr< TPGEdge > >::iterator findEdge(const TPGEdge *edge)
Find the non-const iterator to an edge of the graph from its const pointer.
Definition: tpgGraph.cpp:313
void removeVertex(const TPGVertex &vertex)
Remove a TPGVertex from the TPGGraph and destroy it.
Definition: tpgGraph.cpp:124
void clearProgramIntrons()
Clear all intron instructions in the Program of the TPGGraph.
Definition: tpgGraph.cpp:322
std::list< TPGVertex * >::iterator findVertex(const TPGVertex *vertex)
Find the non-const iterator to a vertex of the graph from its const pointer.
Definition: tpgGraph.cpp:307
const TPGVertex & cloneVertex(const TPGVertex &vertex)
Clone a TPGVertex of the graph and all its outgoing TPGEdge.
Definition: tpgGraph.cpp:148
friend void swap(TPGGraph &a, TPGGraph &b)
Helper function for move constructor.
Definition: tpgGraph.h:86
const std::list< std::unique_ptr< TPGEdge > > & getEdges() const
Get a const reference to the edges of the TPGGraph.
Definition: tpgGraph.cpp:215
const Environment & getEnvironment() const
Accessor to the Environment of the TPGGraph.
Definition: tpgGraph.cpp:66
bool setEdgeDestination(const TPGEdge &edge, const TPGVertex &newDest)
Change the destination of the Edge to the given target.
Definition: tpgGraph.cpp:256
const TPGAction & addNewAction(uint64_t actionID)
Create a new TPGAction and add it to the vertices of the TPGGraph.
Definition: tpgGraph.cpp:82
uint64_t getNbRootVertices() const
Get the number of rootVertices of the TPGGraph.
Definition: tpgGraph.cpp:100
Definition: tpgTeam.h:48
Abstract class representing the vertices of a TPGGraph.
Definition: tpgVertex.h:49
Definition: tpgActionInstrumented.h:8