Cpp-Taskflow  2.1.0
framework.hpp
1 #pragma once
2 
3 #include "flow_builder.hpp"
4 
5 namespace tf {
6 
17 class Framework : public FlowBuilder {
18 
19  template <template<typename...> typename E>
20  friend class BasicTaskflow;
21 
22  friend class Topology;
23 
24  public:
25 
29  Framework();
30 
34  virtual ~Framework();
35 
41  void dump(std::ostream& ostream) const;
42 
46  std::string dump() const;
47 
51  size_t num_nodes() const;
52 
53  private:
54 
55  Graph _graph;
56 
57  std::mutex _mtx;
58  std::list<Topology*> _topologies;
59 };
60 
61 // Constructor
62 inline Framework::Framework() : FlowBuilder{_graph} {
63 }
64 
65 // Destructor
67  assert(_topologies.empty());
68 }
69 
70 // Function: num_noces
71 inline size_t Framework::num_nodes() const {
72  return _graph.size();
73 }
74 
75 // Procedure: dump
76 inline void Framework::dump(std::ostream& os) const {
77  os << "digraph Framework {\n";
78  for(const auto& n: _graph) {
79  n.dump(os);
80  }
81  os << "}\n";
82 }
83 
84 // Function: dump
85 inline std::string Framework::dump() const {
87  dump(os);
88  return os.str();
89 }
90 
91 } // end of namespace tf. ---------------------------------------------------
92 
The base class to derive a taskflow class.
Definition: basic_taskflow.hpp:38
size_t num_nodes() const
queries the number of nodes in the framework
Definition: framework.hpp:71
Definition: taskflow.hpp:6
A reusable task dependency graph.
Definition: framework.hpp:17
virtual ~Framework()
destroy the framework (virtual call)
Definition: framework.hpp:66
std::string dump() const
dumps the framework in DOT format to a std::string
Definition: framework.hpp:85
The building blocks of task dependency graphs.
Definition: flow_builder.hpp:13
Framework()
constructs the framework with an empty task dependency graph
Definition: framework.hpp:62