2 Copyright (C) 2000 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_route_group_h__
21 #define __ardour_route_group_h__
28 #include "pbd/signals.h"
29 #include "pbd/stateful.h"
30 #include "pbd/signals.h"
32 #include "ardour/types.h"
33 #include "ardour/session_object.h"
37 namespace Properties {
38 extern PBD::PropertyDescriptor<bool> relative;
39 extern PBD::PropertyDescriptor<bool> active;
40 extern PBD::PropertyDescriptor<bool> gain;
41 extern PBD::PropertyDescriptor<bool> mute;
42 extern PBD::PropertyDescriptor<bool> solo;
43 extern PBD::PropertyDescriptor<bool> recenable;
44 extern PBD::PropertyDescriptor<bool> select;
45 extern PBD::PropertyDescriptor<bool> edit;
46 /* we use this, but its declared in region.cc */
47 extern PBD::PropertyDescriptor<bool> hidden;
55 class RouteGroup : public SessionObject
58 static void make_property_quarks();
60 RouteGroup (Session& s, const std::string &n);
63 bool is_active () const { return _active.val(); }
64 bool is_relative () const { return _relative.val(); }
65 bool is_hidden () const { return _hidden.val(); }
66 bool is_gain () const { return _gain.val(); }
67 bool is_mute () const { return _mute.val(); }
68 bool is_solo () const { return _solo.val(); }
69 bool is_recenable () const { return _recenable.val(); }
70 bool is_select () const { return _select.val(); }
71 bool is_edit () const { return _edit.val(); }
73 bool empty() const {return routes->empty();}
74 size_t size() const { return routes->size();}
76 gain_t get_max_factor(gain_t factor);
77 gain_t get_min_factor(gain_t factor);
79 void set_active (bool yn, void *src);
80 void set_relative (bool yn, void *src);
81 void set_hidden (bool yn, void *src);
83 void set_gain (bool yn);
84 void set_mute (bool yn);
85 void set_solo (bool yn);
86 void set_recenable (bool yn);
87 void set_select (bool yn);
88 void set_edit (bool yn);
90 bool enabled_property (PBD::PropertyID);
92 int add (boost::shared_ptr<Route>);
93 int remove (boost::shared_ptr<Route>);
95 void apply (void (Route::*func)(void *), void *src) {
96 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
97 ((*i).get()->*func)(src);
101 void apply (void (Route::*func)()) {
102 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
103 ((*i).get()->*func)();
107 template<class T> void apply (void (Route::*func)(T, void *), T val, void *src) {
108 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
109 ((*i).get()->*func)(val, src);
113 template<class T> void apply (void (Route::*func)(T), T val) {
114 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
115 ((*i).get()->*func)(val);
119 template<class T> void foreach_route (T *obj, void (T::*func)(Route&)) {
120 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
125 /* to use these, #include "ardour/route_group_specialized.h" */
127 template<class T> void apply (void (Track::*func)(T, void *), T val, void *src);
129 /* fills at_set with all members of the group that are AudioTracks */
131 void audio_track_group (std::set<boost::shared_ptr<AudioTrack> >& at_set);
138 void make_subgroup ();
139 void destroy_subgroup ();
141 boost::shared_ptr<RouteList> route_list() { return routes; }
143 /** Emitted when a route has been added to or removed from this group */
144 PBD::Signal0<void> MembershipChanged;
146 XMLNode& get_state ();
148 int set_state (const XMLNode&, int version);
151 boost::shared_ptr<RouteList> routes;
152 boost::shared_ptr<Route> subgroup_bus;
154 PBD::Property<bool> _relative;
155 PBD::Property<bool> _active;
156 PBD::Property<bool> _hidden;
157 PBD::Property<bool> _gain;
158 PBD::Property<bool> _mute;
159 PBD::Property<bool> _solo;
160 PBD::Property<bool> _recenable;
161 PBD::Property<bool> _select;
162 PBD::Property<bool> _edit;
164 void remove_when_going_away (boost::weak_ptr<Route>);
165 int set_state_2X (const XMLNode&, int);
170 #endif /* __ardour_route_group_h__ */