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
52 namespace TPG {
53
57 class TPGGraph
58 {
59 public:
66 TPGGraph(const Environment& e,
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;
95 swap(a.vertices, b.vertices);
96 swap(a.edges, b.edges);
97 }
98
102 TPGGraph& operator=(TPGGraph model);
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);
284 const TPGEdge& addNewActionEdge(
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
401 void updateAllAssessedActions();
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:
434 const Environment& env;
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
Environment
The Environment class contains all information needed to execute a Program.
Definition environment.h:86
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::TPGFactory
Factory for creating all elements constituting a TPG.
Definition tpgFactory.h:71
TPG::TPGGraph
Class for storing a Tangled-Program-Graph.
Definition tpgGraph.h:58
TPG::TPGGraph::getVertices
const std::vector< const TPGVertex * > getVertices() const
Get vector of const pointer to the vertices of the TPGGraph.
Definition tpgGraph.cpp:114
TPG::TPGGraph::clear
void clear()
Empty the TPGGraph of all its content.
Definition tpgGraph.cpp:57
TPG::TPGGraph::cloneEdge
const TPGEdge & cloneEdge(const TPGEdge &edge)
Definition tpgGraph.cpp:400
TPG::TPGGraph::addNewTeam
const TPGTeam & addNewTeam()
Create a new TPGTeam and add it to the vertices of the TPGGraph.
Definition tpgGraph.cpp:97
TPG::TPGGraph::TPGGraph
TPGGraph(const Environment &e, std::unique_ptr< TPGFactory > f=std::make_unique< TPGFactory >())
Main TPGGraph constructor.
Definition tpgGraph.h:66
TPG::TPGGraph::setNewEdgeID
void setNewEdgeID(const TPG::TPGEdge &edge, uint64_t newID)
Set a new ID to an edge.
Definition tpgGraph.cpp:253
TPG::TPGGraph::factory
const std::unique_ptr< TPGFactory > factory
TPGFactory of the TPGGraph.
Definition tpgGraph.h:437
TPG::TPGGraph::vertices
std::set< std::unique_ptr< TPGVertex >, UniqueLess< TPGVertex > > vertices
Set of all vertices currently used in the graph.
Definition tpgGraph.h:447
TPG::TPGGraph::addNewEdge
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
TPG::TPGGraph::setEdgeSource
bool setEdgeSource(const TPGEdge &edge, const TPGVertex &newSrc)
Change the source of the TPGEdge to the given vertex.
Definition tpgGraph.cpp:450
TPG::TPGGraph::TPGGraph
TPGGraph(TPGGraph &&model) noexcept
TPGGraph move assignment operator.
Definition tpgGraph.h:82
TPG::TPGGraph::addNewActionEdge
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
TPG::TPGGraph::operator=
TPGGraph & operator=(TPGGraph model)
assignement operator for class TPGGraph
Definition tpgGraph.cpp:51
TPG::TPGGraph::orderActionEdges
void orderActionEdges(const TPG::TPGAction *action)
Definition tpgGraph.cpp:541
TPG::TPGGraph::edges
std::set< std::unique_ptr< TPGEdge >, UniqueLess< TPGEdge > > edges
Set of all edges currently used in the graph.
Definition tpgGraph.h:442
TPG::TPGGraph::TPGGraph
TPGGraph(const TPGGraph &model)=delete
delete copy constructor
TPG::TPGGraph::hasVertex
bool hasVertex(const TPG::TPGVertex &vertex) const
Check whether a given vertex exists in the TPGGraph.
Definition tpgGraph.cpp:169
TPG::TPGGraph::getFactory
const TPGFactory & getFactory() const
Get a reference to the TPGFactory of the TPGGraph.
Definition tpgGraph.cpp:68
TPG::TPGGraph::getRootVertices
const std::vector< const TPGVertex * > getRootVertices() const
Get vector of const pointer to the root vertices of the TPGGraph.
Definition tpgGraph.cpp:158
TPG::TPGGraph::removeActionEdge
void removeActionEdge(const TPGEdge &edge)
Remove a TPGActionEdge from the TPGGraph.
Definition tpgGraph.cpp:382
TPG::TPGGraph::~TPGGraph
virtual ~TPGGraph()
Destructor for the TPGGraph.
Definition tpgGraph.cpp:46
TPG::TPGGraph::env
const Environment & env
Environment of the TPGGraph.
Definition tpgGraph.h:434
TPG::TPGGraph::getNbVertices
size_t getNbVertices() const
Get the number of TPGVertex contained in the TPGGraph.
Definition tpgGraph.cpp:109
TPG::TPGGraph::removeEdge
void removeEdge(const TPGEdge &edge)
Remove a TPGEdge from the TPGGraph.
Definition tpgGraph.cpp:347
TPG::TPGGraph::setActionClassEdge
void setActionClassEdge(const TPGEdge *edge, uint64_t newActionClass)
set a new action class to a TPGActionEdge
Definition tpgGraph.cpp:482
TPG::TPGGraph::removeVertex
void removeVertex(const TPGVertex &vertex)
Remove a TPGVertex from the TPGGraph and destroy it.
Definition tpgGraph.cpp:177
TPG::TPGGraph::clearProgramIntrons
void clearProgramIntrons()
Clear all intron instructions in the Program of the TPGGraph.
Definition tpgGraph.cpp:475
TPG::TPGGraph::updateAllAssessedActions
void updateAllAssessedActions()
Definition tpgGraph.cpp:529
TPG::TPGGraph::updateAssessedActions
void updateAssessedActions(const TPG::TPGVertex *vertex)
Definition tpgGraph.cpp:501
TPG::TPGGraph::cloneVertex
const TPGVertex & cloneVertex(const TPGVertex &vertex)
Clone a TPGVertex of the graph and all its outgoing TPGEdge.
Definition tpgGraph.cpp:205
TPG::TPGGraph::getRootActions
const std::vector< const TPGAction * > getRootActions() const
Get vector of const pointer to the root actions of the TPGGraph.
Definition tpgGraph.cpp:134
TPG::TPGGraph::swap
friend void swap(TPGGraph &a, TPGGraph &b)
Helper function for move constructor.
Definition tpgGraph.h:92
TPG::TPGGraph::getEnvironment
const Environment & getEnvironment() const
Accessor to the Environment of the TPGGraph.
Definition tpgGraph.cpp:63
TPG::TPGGraph::setEdgeDestination
bool setEdgeDestination(const TPGEdge &edge, const TPGVertex &newDest)
Change the destination of the Edge to the given target.
Definition tpgGraph.cpp:422
TPG::TPGGraph::getEdges
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
TPG::TPGGraph::addNewAction
const TPGAction & addNewAction(uint64_t actionID)
Create a new TPGAction and add it to the vertices of the TPGGraph.
Definition tpgGraph.cpp:103
TPG::TPGGraph::setNewVertexID
void setNewVertexID(const TPG::TPGVertex &vertex, uint64_t newID)
Set a new ID to a vertex.
Definition tpgGraph.cpp:73
TPG::TPGGraph::getNbRootVertices
uint64_t getNbRootVertices() const
Get the number of rootVertices of the TPGGraph.
Definition tpgGraph.cpp:126
TPG::TPGGraph::getRootTeams
const std::vector< const TPGTeam * > getRootTeams() const
Get vector of const pointer to the root teams of the TPGGraph.
Definition tpgGraph.cpp:146
TPG::TPGTeam
Definition tpgTeam.h:49
TPG::TPGVertex
Abstract class representing the vertices of a TPGGraph.
Definition tpgVertex.h:55
TPG
Definition executionStats.h:44
UniqueLess
A comparator for unique_ptr that compares the pointed-to values.
Definition genericComparator.h:8