Ardour  8.12
session_route.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
3  * Copyright (C) 2006-2012 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009 David Robillard <d@drobilla.net>
5  * Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #ifndef __ardour_session_route_h__
23 #define __ardour_session_route_h__
24 
25 #include <iostream>
26 
27 #include <glibmm/threads.h>
28 
29 #include "ardour/session.h"
30 #include "ardour/route.h"
31 
32 namespace ARDOUR {
33 
34 template<class T> void
35 Session::foreach_route (T *obj, void (T::*func)(Route&), bool sort)
36 {
37  std::shared_ptr<RouteList const> r = routes.reader();
38  RouteList public_order (*r);
39 
40  if (sort) {
41  public_order.sort (Stripable::Sorter ());
42  }
43 
44  for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) {
45  (obj->*func) (**i);
46  }
47 }
48 
49 template<class T> void
50 Session::foreach_route (T *obj, void (T::*func)(std::shared_ptr<Route>), bool sort)
51 {
52  std::shared_ptr<RouteList const> r = routes.reader();
53  RouteList public_order (*r);
54 
55  if (sort) {
56  public_order.sort (Stripable::Sorter ());
57  }
58 
59  for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) {
60  (obj->*func) (*i);
61  }
62 }
63 
64 template<class T, class A> void
65 Session::foreach_route (T *obj, void (T::*func)(Route&, A), A arg1, bool sort)
66 {
67  std::shared_ptr<RouteList const> r = routes.reader();
68  RouteList public_order (*r);
69 
70  if (sort) {
71  public_order.sort (Stripable::Sorter ());
72  }
73 
74  for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) {
75  (obj->*func) (**i, arg1);
76  }
77 }
78 
79 
80 template<class A> void
81 Session::foreach_track (void (Track::*method)(A), A arg)
82 {
83  std::shared_ptr<RouteList const> r = routes.reader();
84 
85  for (auto const& i : *r) {
86  std::shared_ptr<Track> tr = std::dynamic_pointer_cast<Track> (i);
87  if (tr) {
88  (tr.get()->*method) (arg);
89  }
90  }
91 }
92 
93 template<class A1, class A2> void
94 Session::foreach_track (void (Track::*method)(A1, A2), A1 arg1, A2 arg2)
95 {
96  std::shared_ptr<RouteList const> r = routes.reader();
97 
98  for (auto const& i : *r) {
99  std::shared_ptr<Track> tr = std::dynamic_pointer_cast<Track> (i);
100  if (tr) {
101  (tr.get()->*method) (arg1, arg2);
102  }
103  }
104 }
105 
106 template<class A> void
107 Session::foreach_route (void (Route::*method)(A), A arg)
108 {
109  std::shared_ptr<RouteList const> r = routes.reader();
110  for (auto const& i : *r) {
111  (i.get()->*method) (arg);
112  }
113 }
114 
115 template<class A1, class A2> void
116 Session::foreach_route (void (Route::*method)(A1, A2), A1 arg1, A2 arg2)
117 {
118  std::shared_ptr<RouteList const> r = routes.reader();
119 
120  for (auto const& i : *r) {
121  (i.get()->*method) (arg1, arg2);
122  }
123 }
124 
125 } /* namespace */
126 
127 #endif /* __ardour_session_route_h__ */
void foreach_route(T *obj, void(T::*func)(Route &), bool sort=true)
Definition: session_route.h:35
void foreach_track(void(Track::*method)(A), A arg)
Definition: session_route.h:81
SerializedRCUManager< RouteList > routes
Definition: session.h:1971
std::shared_ptr< T const > reader() const
Definition: rcu.h:70
std::list< std::shared_ptr< Route > > RouteList