GEGELATI
Loading...
Searching...
No Matches
tpgGraph.h
1
38#ifndef TPG_GRAPH_H
39#define TPG_GRAPH_H
40
41#include <list>
42#include <set>
43
44#include "environment.h"
45#include "tpg/tpgAction.h"
46#include "tpg/tpgEdge.h"
47#include "tpg/tpgFactory.h"
48#include "tpg/tpgTeam.h"
49#include "tpg/tpgVertex.h"
50#include "util/genericComparator.h"
51
52namespace TPG {
53
58 {
59 public:
67 std::unique_ptr<TPGFactory> f = std::make_unique<TPGFactory>())
68 : env{e}, factory{std::move(f)}
69 {
70 }
71
75 TPGGraph(const TPGGraph& model) = delete;
76
82 TPGGraph(TPGGraph&& model) noexcept : env{model.getEnvironment()}
83 {
84 swap(*this, model);
85 }
86
92 friend inline void swap(TPGGraph& a, TPGGraph& b)
93 {
94 using std::swap;
96 swap(a.edges, b.edges);
97 }
98
103
109 virtual ~TPGGraph();
110
114 void clear();
115
121 const Environment& getEnvironment() const;
122
128 const TPGFactory& getFactory() const;
129
139 const TPGTeam& addNewTeam();
140
151 const TPGAction& addNewAction(uint64_t actionID);
152
158 size_t getNbVertices() const;
159
169 const std::vector<const TPGVertex*> getVertices() const;
170
176 uint64_t getNbRootVertices() const;
177
189 const std::vector<const TPGAction*> getRootActions() const;
190
202 const std::vector<const TPGTeam*> getRootTeams() const;
203
215 const std::vector<const TPGVertex*> getRootVertices() const;
216
224 bool hasVertex(const TPG::TPGVertex& vertex) const;
225
234 void removeVertex(const TPGVertex& vertex);
235
244 const TPGVertex& cloneVertex(const TPGVertex& vertex);
245
265 const TPGEdge& addNewEdge(const TPGVertex& src, const TPGVertex& dest,
266 const std::shared_ptr<Program::Program> prog);
285 const TPGVertex& src, const std::shared_ptr<Program::Program> prog,
286 uint64_t actionClass);
287
293 const std::set<std::unique_ptr<TPG::TPGEdge>, UniqueLess<TPG::TPGEdge>>&
294 getEdges() const;
295
307 void removeEdge(const TPGEdge& edge);
308
320 void removeActionEdge(const TPGEdge& edge);
321
334 const TPGEdge& cloneEdge(const TPGEdge& edge);
335
347 bool setEdgeDestination(const TPGEdge& edge, const TPGVertex& newDest);
348
360 bool setEdgeSource(const TPGEdge& edge, const TPGVertex& newSrc);
361
368 void clearProgramIntrons();
369
376 void setActionClassEdge(const TPGEdge* edge, uint64_t newActionClass);
377
390 void updateAssessedActions(const TPG::TPGVertex* vertex);
391
402
408 void orderActionEdges(const TPG::TPGAction* action);
409
419 void setNewVertexID(const TPG::TPGVertex& vertex, uint64_t newID);
420
430 void setNewEdgeID(const TPG::TPGEdge& edge, uint64_t newID);
431
432 protected:
435
437 const std::unique_ptr<TPGFactory> factory;
438
442 std::set<std::unique_ptr<TPGEdge>, UniqueLess<TPGEdge>> edges;
443
447 std::set<std::unique_ptr<TPGVertex>, UniqueLess<TPGVertex>> vertices;
448 };
449}; // namespace TPG
450
451#endif
The Environment class contains all information needed to execute a Program.
Definition environment.h:86
Class representing an Action of a TPGGraph.
Definition tpgAction.h:55
Class representing edges of the Tangled Program Graphs.
Definition tpgEdge.h:54
Factory for creating all elements constituting a TPG.
Definition tpgFactory.h:71
Class for storing a Tangled-Program-Graph.
Definition tpgGraph.h:58
const std::vector< const TPGVertex * > getVertices() const
Get vector of const pointer to the vertices of the TPGGraph.
Definition tpgGraph.cpp:114
void clear()
Empty the TPGGraph of all its content.
Definition tpgGraph.cpp:57
const TPGEdge & cloneEdge(const TPGEdge &edge)
Definition tpgGraph.cpp:400
const TPGTeam & addNewTeam()
Create a new TPGTeam and add it to the vertices of the TPGGraph.
Definition tpgGraph.cpp:97
TPGGraph(const Environment &e, std::unique_ptr< TPGFactory > f=std::make_unique< TPGFactory >())
Main TPGGraph constructor.
Definition tpgGraph.h:66
void setNewEdgeID(const TPG::TPGEdge &edge, uint64_t newID)
Set a new ID to an edge.
Definition tpgGraph.cpp:253
const std::unique_ptr< TPGFactory > factory
TPGFactory of the TPGGraph.
Definition tpgGraph.h:437
std::set< std::unique_ptr< TPGVertex >, UniqueLess< TPGVertex > > vertices
Set of all vertices currently used in the graph.
Definition tpgGraph.h:447
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:276
bool setEdgeSource(const TPGEdge &edge, const TPGVertex &newSrc)
Change the source of the TPGEdge to the given vertex.
Definition tpgGraph.cpp:450
TPGGraph(TPGGraph &&model) noexcept
TPGGraph move assignment operator.
Definition tpgGraph.h:82
const TPGEdge & addNewActionEdge(const TPGVertex &src, const std::shared_ptr< Program::Program > prog, uint64_t actionClass)
Add a new TPGActionEdge to the TPGGraph.
Definition tpgGraph.cpp:310
TPGGraph & operator=(TPGGraph model)
assignement operator for class TPGGraph
Definition tpgGraph.cpp:51
void orderActionEdges(const TPG::TPGAction *action)
Definition tpgGraph.cpp:541
std::set< std::unique_ptr< TPGEdge >, UniqueLess< TPGEdge > > edges
Set of all edges currently used in the graph.
Definition tpgGraph.h:442
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:169
const TPGFactory & getFactory() const
Get a reference to the TPGFactory of the TPGGraph.
Definition tpgGraph.cpp:68
const std::vector< const TPGVertex * > getRootVertices() const
Get vector of const pointer to the root vertices of the TPGGraph.
Definition tpgGraph.cpp:158
void removeActionEdge(const TPGEdge &edge)
Remove a TPGActionEdge from the TPGGraph.
Definition tpgGraph.cpp:382
virtual ~TPGGraph()
Destructor for the TPGGraph.
Definition tpgGraph.cpp:46
const Environment & env
Environment of the TPGGraph.
Definition tpgGraph.h:434
size_t getNbVertices() const
Get the number of TPGVertex contained in the TPGGraph.
Definition tpgGraph.cpp:109
void removeEdge(const TPGEdge &edge)
Remove a TPGEdge from the TPGGraph.
Definition tpgGraph.cpp:347
void setActionClassEdge(const TPGEdge *edge, uint64_t newActionClass)
set a new action class to a TPGActionEdge
Definition tpgGraph.cpp:482
void removeVertex(const TPGVertex &vertex)
Remove a TPGVertex from the TPGGraph and destroy it.
Definition tpgGraph.cpp:177
void clearProgramIntrons()
Clear all intron instructions in the Program of the TPGGraph.
Definition tpgGraph.cpp:475
void updateAllAssessedActions()
Definition tpgGraph.cpp:529
void updateAssessedActions(const TPG::TPGVertex *vertex)
Definition tpgGraph.cpp:501
const TPGVertex & cloneVertex(const TPGVertex &vertex)
Clone a TPGVertex of the graph and all its outgoing TPGEdge.
Definition tpgGraph.cpp:205
const std::vector< const TPGAction * > getRootActions() const
Get vector of const pointer to the root actions of the TPGGraph.
Definition tpgGraph.cpp:134
friend void swap(TPGGraph &a, TPGGraph &b)
Helper function for move constructor.
Definition tpgGraph.h:92
const Environment & getEnvironment() const
Accessor to the Environment of the TPGGraph.
Definition tpgGraph.cpp:63
bool setEdgeDestination(const TPGEdge &edge, const TPGVertex &newDest)
Change the destination of the Edge to the given target.
Definition tpgGraph.cpp:422
const std::set< std::unique_ptr< TPG::TPGEdge >, UniqueLess< TPG::TPGEdge > > & getEdges() const
Get a const reference to the edges of the TPGGraph.
Definition tpgGraph.cpp:342
const TPGAction & addNewAction(uint64_t actionID)
Create a new TPGAction and add it to the vertices of the TPGGraph.
Definition tpgGraph.cpp:103
void setNewVertexID(const TPG::TPGVertex &vertex, uint64_t newID)
Set a new ID to a vertex.
Definition tpgGraph.cpp:73
uint64_t getNbRootVertices() const
Get the number of rootVertices of the TPGGraph.
Definition tpgGraph.cpp:126
const std::vector< const TPGTeam * > getRootTeams() const
Get vector of const pointer to the root teams of the TPGGraph.
Definition tpgGraph.cpp:146
Definition tpgTeam.h:49
Abstract class representing the vertices of a TPGGraph.
Definition tpgVertex.h:55
Definition executionStats.h:44
A comparator for unique_ptr that compares the pointed-to values.
Definition genericComparator.h:8