WRENCH  1.10
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
DagOfTasks.h
1 
10 #ifndef WRENCH_DAGOFTASKS_H
11 #define WRENCH_DAGOFTASKS_H
12 
13 #include <boost/graph/adjacency_list.hpp>
14 #include <boost/graph/breadth_first_search.hpp>
15 #include <iostream>
16 
17 #include <wrench/workflow/WorkflowTask.h>
18 
19 namespace wrench {
20 
21 /***********************/
23 /***********************/
24 
25  class WorkflowTask;
26 
31 // std::size_t index;
32 // boost::default_color_type color;
35  };
36 
40  typedef boost::adjacency_list<boost::listS, boost::vecS, boost::bidirectionalS, VertexProperties> DAG;
41 
45  typedef unsigned long vertex_t; // To clean up some day...
46 
50  class DagOfTasks {
51 
52  public:
53 
54  void addVertex(const WorkflowTask *task);
55 
56  void removeVertex(WorkflowTask *task);
57 
58  void addEdge(WorkflowTask *src, WorkflowTask *dst);
59 
60  void removeEdge(WorkflowTask *src, WorkflowTask *dst);
61 
62  bool doesPathExist(const WorkflowTask *src, const WorkflowTask *dst);
63  bool doesEdgeExist(const WorkflowTask *src, const WorkflowTask *dst);
64 
65  long getNumberOfChildren(const WorkflowTask *task);
66 
67  std::vector<WorkflowTask *> getChildren(const WorkflowTask *task);
68 
69  long getNumberOfParents(const WorkflowTask *task);
70 
71  std::vector<WorkflowTask *> getParents(const WorkflowTask *task);
72 
73  private:
74 
78  class custom_bfs_visitor : public boost::default_bfs_visitor {
79  public:
80 
81  const WorkflowTask *target_task;
82 
83  explicit custom_bfs_visitor(const WorkflowTask *target_task) : boost::default_bfs_visitor() {
84  this->target_task = target_task;
85  }
86 
87  template<typename Vertex, typename Graph>
88  void discover_vertex(Vertex u, Graph &g) {
89  if (g[u].task == target_task) {
90  throw std::runtime_error("path found");
91  }
92  }
93  };
94 
95  std::vector<const WorkflowTask*> task_list;
96  std::unordered_map<const WorkflowTask *, unsigned long> task_map;
97 
98  DAG dag;
99 
100  };
101 
102 /***********************/
104 /***********************/
105 
106 }
107 
108 
109 #endif //WRENCH_DAGOFTASKS_H
wrench::DagOfTasks
An internal class that uses the Boost Graph Library to implement a DAG of WorkflowTask objects.
Definition: DagOfTasks.h:50
wrench::DagOfTasks::getChildren
std::vector< WorkflowTask * > getChildren(const WorkflowTask *task)
Method to get the children of a task vertex.
Definition: DagOfTasks.cpp:178
wrench::DagOfTasks::removeEdge
void removeEdge(WorkflowTask *src, WorkflowTask *dst)
Remove an edge between two task vertices.
Definition: DagOfTasks.cpp:83
wrench::DagOfTasks::getNumberOfParents
long getNumberOfParents(const WorkflowTask *task)
Method to get the number of parents of a task vertex.
Definition: DagOfTasks.cpp:198
wrench::DagOfTasks::addEdge
void addEdge(WorkflowTask *src, WorkflowTask *dst)
Method to add an edge between to task vertices.
Definition: DagOfTasks.cpp:64
wrench::VertexProperties::task
const WorkflowTask * task
Task attached to the vertex.
Definition: DagOfTasks.h:34
wrench::DagOfTasks::addVertex
void addVertex(const WorkflowTask *task)
Method to add a task vertex to the DAG.
Definition: DagOfTasks.cpp:24
wrench::DagOfTasks::doesPathExist
bool doesPathExist(const WorkflowTask *src, const WorkflowTask *dst)
Method to check whether a path exists between to task vertices.
Definition: DagOfTasks.cpp:102
wrench::vertex_t
unsigned long vertex_t
Convenient vertext_t typedef.
Definition: DagOfTasks.h:45
wrench
Definition: Alarm.cpp:20
wrench::VertexProperties
Data structure to store vertex properties.
Definition: DagOfTasks.h:30
wrench::WorkflowTask
A computational task in a Workflow.
Definition: WorkflowTask.h:31
wrench::DagOfTasks::getParents
std::vector< WorkflowTask * > getParents(const WorkflowTask *task)
Method to get the parents of a task vertex.
Definition: DagOfTasks.cpp:217
wrench::DagOfTasks::getNumberOfChildren
long getNumberOfChildren(const WorkflowTask *task)
Method to get the number of children of a task vertex.
Definition: DagOfTasks.cpp:159
wrench::DagOfTasks::removeVertex
void removeVertex(WorkflowTask *task)
Method to remove a task vertex from the DAG.
Definition: DagOfTasks.cpp:39
wrench::DAG
boost::adjacency_list< boost::listS, boost::vecS, boost::bidirectionalS, VertexProperties > DAG
Convenient DAG typedef.
Definition: DagOfTasks.h:40
wrench::DagOfTasks::doesEdgeExist
bool doesEdgeExist(const WorkflowTask *src, const WorkflowTask *dst)
Method to check whether an edge exists between to task vertices.
Definition: DagOfTasks.cpp:137