Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
22 
23 #include <atomic>
24 #include <list>
25 #include <map>
26 #include <memory>
27 #include <set>
28 
29 #include "pbd/rcu.h"
30 
32 
33 namespace ARDOUR
34 {
35 class Graph;
36 class GraphNode;
37 struct GraphChain;
38 
39 typedef std::shared_ptr<GraphNode> node_ptr_t;
40 typedef std::set<node_ptr_t> node_set_t;
41 typedef std::list<node_ptr_t> node_list_t;
42 
44 {
45 public:
46  virtual ~ProcessNode() {}
47  virtual void prep (GraphChain const*) = 0;
48  virtual void run (GraphChain const*) = 0;
49 };
50 
52 {
53 public:
55  virtual ~GraphActivision () {}
56 
57  typedef std::map<GraphChain const*, node_set_t> ActivationMap;
58  typedef std::map<GraphChain const*, int> RefCntMap;
59 
60  node_set_t const& activation_set (GraphChain const* const g) const;
61  int init_refcount (GraphChain const* const g) const;
63 
64 protected:
65  friend struct GraphChain;
66 
71 };
72 
75 {
76 public:
77  GraphNode (std::shared_ptr<Graph> Graph);
78 
79  /* API used by Graph */
80  void prep (GraphChain const*);
81  void run (GraphChain const*);
82 
83  /* API used to sort Nodes and create GraphChain */
84  virtual std::string graph_node_name () const = 0;
85 
86  virtual bool direct_feeds_according_to_reality (std::shared_ptr<GraphNode>, bool* via_send_only = 0) = 0;
87 
88 protected:
89  void trigger ();
90  virtual void process () = 0;
91 
92  std::shared_ptr<Graph> _graph;
93 
94 private:
95  void finish (GraphChain const*);
96 
97  std::atomic<int> _refcount;
98 };
99 
100 } // namespace ARDOUR
101 
std::map< GraphChain const *, int > RefCntMap
Definition: graphnode.h:58
int init_refcount(GraphChain const *const g) const
node_set_t const & activation_set(GraphChain const *const g) const
virtual ~GraphActivision()
Definition: graphnode.h:55
SerializedRCUManager< ActivationMap > _activation_set
Definition: graphnode.h:68
std::map< GraphChain const *, node_set_t > ActivationMap
Definition: graphnode.h:57
SerializedRCUManager< RefCntMap > _init_refcount
Definition: graphnode.h:70
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:92
void finish(GraphChain const *)
std::atomic< int > _refcount
Definition: graphnode.h:97
virtual void run(GraphChain const *)=0
virtual void prep(GraphChain const *)=0
virtual ~ProcessNode()
Definition: graphnode.h:46
#define LIBARDOUR_API
std::list< node_ptr_t > node_list_t
Definition: graph.h:55
std::shared_ptr< GraphNode > node_ptr_t
Definition: graph.h:51
std::set< node_ptr_t > node_set_t
Definition: graph.h:56
DebugBits Graph