VISR  0.11.1
Versatile Interactive Scene Renderer
scheduling_graph.hpp
Go to the documentation of this file.
1 /* Copyright Institute of Sound and Vibration Research - All rights reserved */
2 
3 #ifndef VISR_LIBRRL_SCHEDULING_GRAPH_HPP_INCLUDED
4 #define VISR_LIBRRL_SCHEDULING_GRAPH_HPP_INCLUDED
5 
7 
8 #include <libvisr/constants.hpp>
9 // #include <libvisr/parameter_port_base.hpp> // Temporary fix (otherwise
10 
11 #include <ciso646>
12 #include <iosfwd>
13 #include <map>
14 #include <memory>
15 #include <ostream>
16 #include <stdexcept>
17 #include <tuple>
18 #include <vector>
19 
20 #include <boost/graph/adjacency_list.hpp>
21 
22 namespace visr
23 {
24 // Forward declarations
25 class AtomicComponent; // TODO: Replace by ExecutableInterface at some point?
26 namespace impl
27 {
28 class ComponentImplementation;
29 class ParameterPortBaseImplementation;
30 }
31 
32 namespace rrl
33 {
34 // Forward declarations
35 class AudioConnectionMap;
36 class AudioChannel;
37 
39 {
40 public:
42 
47 
48  void initialise( impl::ComponentImplementation const & flow,
49  AudioConnectionMap const & audioConnections,
50  ParameterConnectionMap const & parameterConnections );
51 
52  std::vector<AtomicComponent *> sequentialSchedule() const;
53 
54 private:
55 
61  bool checkAcyclicGraph( std::ostream & messages ) const;
62 
63  enum class NodeType
64  {
65  Source,
66  Sink,
67  Processor
68  };
69 
70  struct ProcessingNode: public std::tuple<NodeType, impl::ComponentImplementation const *>
71  {
72  public:
73  ProcessingNode();
74 
75  explicit ProcessingNode( NodeType nodeType );
76 
77  explicit ProcessingNode( impl::ComponentImplementation const * atom );
78 
79  explicit ProcessingNode( NodeType nodeType, impl::ComponentImplementation const * atom );
80 
81  impl::ComponentImplementation const * node() const { return std::get<1>(*this); }
82 
83  NodeType type() const { return std::get<0>(*this); }
84 
85  private:
86  };
87 
88  using GraphType = boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, ProcessingNode >;
89 
90  GraphType mDependencyGraph;
91 
92  ProcessingNode const & getNode( GraphType::vertex_descriptor vertex ) const;
93 
94  std::string nodeName( ProcessingNode const & node ) const;
95 
101  void insertDependencyEdge( GraphType::vertex_descriptor sourceVertex, GraphType::vertex_descriptor destVertex );
102 
103 // using VertexMap = std::map<ProcessingNode, GraphType::vertex_descriptor, CompareProcessingNodes >;
104  using VertexMap = std::map<ProcessingNode, GraphType::vertex_descriptor >;
105 
106  VertexMap mVertexLookup;
107 
108  GraphType::vertex_descriptor mSourceVertex;
109 
110  GraphType::vertex_descriptor mSinkVertex;
111 };
112 
113 } // namespace rrl
114 } // namespace visr
115 
116 #endif // #ifndef VISR_LIBRRL_SCHEDULING_GRAPH_HPP_INCLUDED
Definition: component_implementation.hpp:34
~SchedulingGraph()
Definition: scheduling_graph.cpp:181
void initialise(impl::ComponentImplementation const &flow, AudioConnectionMap const &audioConnections, ParameterConnectionMap const &parameterConnections)
Definition: scheduling_graph.cpp:72
SchedulingGraph()
Definition: scheduling_graph.cpp:38
Definition: options.cpp:10
Definition: audio_connection_map.hpp:64
Definition: scheduling_graph.hpp:38
std::vector< AtomicComponent * > sequentialSchedule() const
Definition: scheduling_graph.cpp:253
Definition: parameter_connection_map.hpp:28