Ardour  8.12
graphnode.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010-2011 David Robillard <d@drobilla.net>
3  * Copyright (C) 2011 Carl Hetherington <carl@carlh.net>
4  * Copyright (C) 2015-2022 Robin Gareus <robin@gareus.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef __ardour_graphnode_h__
22 #define __ardour_graphnode_h__
23 
24 #include <atomic>
25 #include <list>
26 #include <map>
27 #include <memory>
28 #include <set>
29 
30 #include "pbd/rcu.h"
31 
33 
34 namespace ARDOUR
35 {
36 class Graph;
37 class GraphNode;
38 struct GraphChain;
39 
40 typedef std::shared_ptr<GraphNode> node_ptr_t;
41 typedef std::set<node_ptr_t> node_set_t;
42 typedef std::list<node_ptr_t> node_list_t;
43 
45 {
46 public:
47  virtual ~ProcessNode() {}
48  virtual void prep (GraphChain const*) = 0;
49  virtual void run (GraphChain const*) = 0;
50 };
51 
53 {
54 public:
56  virtual ~GraphActivision () {}
57 
58  typedef std::map<GraphChain const*, node_set_t> ActivationMap;
59  typedef std::map<GraphChain const*, int> RefCntMap;
60 
61  node_set_t const& activation_set (GraphChain const* const g) const;
62  int init_refcount (GraphChain const* const g) const;
64 
65 protected:
66  friend struct GraphChain;
67 
72 };
73 
76 {
77 public:
78  GraphNode (std::shared_ptr<Graph> Graph);
79 
80  /* API used by Graph */
81  void prep (GraphChain const*);
82  void run (GraphChain const*);
83 
84  /* API used to sort Nodes and create GraphChain */
85  virtual std::string graph_node_name () const = 0;
86 
87  virtual bool direct_feeds_according_to_reality (std::shared_ptr<GraphNode>, bool* via_send_only = 0) = 0;
88 
89 protected:
90  void trigger ();
91  virtual void process () = 0;
92 
93  std::shared_ptr<Graph> _graph;
94 
95 private:
96  void finish (GraphChain const*);
97 
98  std::atomic<int> _refcount;
99 };
100 
101 } // namespace ARDOUR
102 
103 #endif
std::map< GraphChain const *, int > RefCntMap
Definition: graphnode.h:59
int init_refcount(GraphChain const *const g) const
node_set_t const & activation_set(GraphChain const *const g) const
virtual ~GraphActivision()
Definition: graphnode.h:56
SerializedRCUManager< ActivationMap > _activation_set
Definition: graphnode.h:69
std::map< GraphChain const *, node_set_t > ActivationMap
Definition: graphnode.h:58
SerializedRCUManager< RefCntMap > _init_refcount
Definition: graphnode.h:71
GraphNode(std::shared_ptr< Graph > Graph)
virtual std::string graph_node_name() const =0
virtual bool direct_feeds_according_to_reality(std::shared_ptr< GraphNode >, bool *via_send_only=0)=0
void prep(GraphChain const *)
virtual void process()=0
void run(GraphChain const *)
std::shared_ptr< Graph > _graph
Definition: graphnode.h:93
void finish(GraphChain const *)
std::atomic< int > _refcount
Definition: graphnode.h:98
virtual void run(GraphChain const *)=0
virtual void prep(GraphChain const *)=0
virtual ~ProcessNode()
Definition: graphnode.h:47
A node in the hierarchical graph that represents a multiplicatable export item.
#define LIBARDOUR_API
std::list< node_ptr_t > node_list_t
Definition: graph.h:56
std::shared_ptr< GraphNode > node_ptr_t
Definition: graph.h:52
std::set< node_ptr_t > node_set_t
Definition: graph.h:57
DebugBits Graph