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 TPGVertex*> getRootVertices() const;
190
198 bool hasVertex(const TPG::TPGVertex& vertex) const;
199
208 void removeVertex(const TPGVertex& vertex);
209
218 const TPGVertex& cloneVertex(const TPGVertex& vertex);
219
239 const TPGEdge& addNewEdge(const TPGVertex& src, const TPGVertex& dest,
240 const std::shared_ptr<Program::Program> prog);
258 const TPGEdge& addNewActionEdge(
259 const TPGVertex& src, const std::shared_ptr<Program::Program> prog,
260 uint64_t actionClass);
261
267 const std::set<std::unique_ptr<TPG::TPGEdge>, UniqueLess<TPG::TPGEdge>>&
268 getEdges() const;
269
281 void removeEdge(const TPGEdge& edge);
282
294 void removeActionEdge(const TPGEdge& edge);
295
308 const TPGEdge& cloneEdge(const TPGEdge& edge);
309
321 bool setEdgeDestination(const TPGEdge& edge, const TPGVertex& newDest);
322
334 bool setEdgeSource(const TPGEdge& edge, const TPGVertex& newSrc);
335
342 void clearProgramIntrons();
343
350 void setActionClassEdge(const TPGEdge* edge, uint64_t newActionClass);
351
364 void updateAssessedActions(const TPG::TPGVertex* vertex);
365
375 void updateAllAssessedActions();
376
382 void orderActionEdges(const TPG::TPGAction* action);
383
389 void setToBeDeleted(const TPG::TPGVertex* vertex);
390
400 void setNewVertexID(const TPG::TPGVertex& vertex, uint64_t newID);
401
411 void setNewEdgeID(const TPG::TPGEdge& edge, uint64_t newID);
412
413 protected:
415 const Environment& env;
416
418 const std::unique_ptr<TPGFactory> factory;
419
423 std::set<std::unique_ptr<TPGEdge>, UniqueLess<TPGEdge>> edges;
424
428 std::set<std::unique_ptr<TPGVertex>, UniqueLess<TPGVertex>> vertices;
429 };
430}; // namespace TPG
431
432#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:376
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:229
TPG::TPGGraph::factory
const std::unique_ptr< TPGFactory > factory
TPGFactory of the TPGGraph.
Definition tpgGraph.h:418
TPG::TPGGraph::vertices
std::set< std::unique_ptr< TPGVertex >, UniqueLess< TPGVertex > > vertices
Set of all vertices currently used in the graph.
Definition tpgGraph.h:428
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:252
TPG::TPGGraph::setEdgeSource
bool setEdgeSource(const TPGEdge &edge, const TPGVertex &newSrc)
Change the source of the TPGEdge to the given vertex.
Definition tpgGraph.cpp:426
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:286
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:529
TPG::TPGGraph::edges
std::set< std::unique_ptr< TPGEdge >, UniqueLess< TPGEdge > > edges
Set of all edges currently used in the graph.
Definition tpgGraph.h:423
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:145
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:134
TPG::TPGGraph::removeActionEdge
void removeActionEdge(const TPGEdge &edge)
Remove a TPGActionEdge from the TPGGraph.
Definition tpgGraph.cpp:358
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:415
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:323
TPG::TPGGraph::setActionClassEdge
void setActionClassEdge(const TPGEdge *edge, uint64_t newActionClass)
set a new action class to a TPGActionEdge
Definition tpgGraph.cpp:458
TPG::TPGGraph::removeVertex
void removeVertex(const TPGVertex &vertex)
Remove a TPGVertex from the TPGGraph and destroy it.
Definition tpgGraph.cpp:153
TPG::TPGGraph::clearProgramIntrons
void clearProgramIntrons()
Clear all intron instructions in the Program of the TPGGraph.
Definition tpgGraph.cpp:451
TPG::TPGGraph::updateAllAssessedActions
void updateAllAssessedActions()
Definition tpgGraph.cpp:505
TPG::TPGGraph::updateAssessedActions
void updateAssessedActions(const TPG::TPGVertex *vertex)
Definition tpgGraph.cpp:477
TPG::TPGGraph::cloneVertex
const TPGVertex & cloneVertex(const TPGVertex &vertex)
Clone a TPGVertex of the graph and all its outgoing TPGEdge.
Definition tpgGraph.cpp:181
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::setToBeDeleted
void setToBeDeleted(const TPG::TPGVertex *vertex)
Definition tpgGraph.cpp:516
TPG::TPGGraph::setEdgeDestination
bool setEdgeDestination(const TPGEdge &edge, const TPGVertex &newDest)
Change the destination of the Edge to the given target.
Definition tpgGraph.cpp:398
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:318
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::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