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/controllable.h"
29 #include "pbd/signals.h"
30 #include "pbd/stateful.h"
32 #include "ardour/control_group.h"
33 #include "ardour/types.h"
34 #include "ardour/session_object.h"
36 #include "ardour/libardour_visibility.h"
40 namespace Properties {
41 LIBARDOUR_API extern PBD::PropertyDescriptor<bool> relative;
42 LIBARDOUR_API extern PBD::PropertyDescriptor<bool> active;
43 LIBARDOUR_API extern PBD::PropertyDescriptor<bool> gain;
44 LIBARDOUR_API extern PBD::PropertyDescriptor<bool> mute;
45 LIBARDOUR_API extern PBD::PropertyDescriptor<bool> solo;
46 LIBARDOUR_API extern PBD::PropertyDescriptor<bool> recenable;
47 LIBARDOUR_API extern PBD::PropertyDescriptor<bool> select;
48 LIBARDOUR_API extern PBD::PropertyDescriptor<bool> route_active;
49 LIBARDOUR_API extern PBD::PropertyDescriptor<bool> color;
50 LIBARDOUR_API extern PBD::PropertyDescriptor<bool> monitoring;
51 /* we use this, but its declared in region.cc */
52 LIBARDOUR_API extern PBD::PropertyDescriptor<bool> hidden;
60 /** A group identifier for routes.
62 * RouteGroups permit to define properties which are shared
63 * among all Routes that use the given identifier.
65 * A route can at most be in one group.
67 class LIBARDOUR_API RouteGroup : public SessionObject
70 static void make_property_quarks();
72 RouteGroup (Session& s, const std::string &n);
75 bool is_active () const { return _active.val(); }
76 bool is_relative () const { return _relative.val(); }
77 bool is_hidden () const { return _hidden.val(); }
78 bool is_gain () const { return _gain.val(); }
79 bool is_mute () const { return _mute.val(); }
80 bool is_solo () const { return _solo.val(); }
81 bool is_recenable () const { return _recenable.val(); }
82 bool is_select () const { return _select.val(); }
83 bool is_route_active () const { return _route_active.val(); }
84 bool is_color () const { return _color.val(); }
85 bool is_monitoring() const { return _monitoring.val(); }
87 bool empty() const {return routes->empty();}
88 size_t size() const { return routes->size();}
90 gain_t get_max_factor(gain_t factor);
91 gain_t get_min_factor(gain_t factor);
93 void set_active (bool yn, void *src);
94 void set_relative (bool yn, void *src);
95 void set_hidden (bool yn, void *src);
97 void set_gain (bool yn);
98 void set_mute (bool yn);
99 void set_solo (bool yn);
100 void set_recenable (bool yn);
101 void set_select (bool yn);
102 void set_route_active (bool yn);
103 void set_color (bool yn);
104 void set_monitoring (bool yn);
106 bool enabled_property (PBD::PropertyID);
108 int add (boost::shared_ptr<Route>);
109 int remove (boost::shared_ptr<Route>);
111 template<typename Function>
112 void foreach_route (Function f) {
113 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
118 /* to use these, #include "ardour/route_group_specialized.h" */
120 template<class T> void apply (void (Track::*func)(T, PBD::Controllable::GroupControlDisposition), T val, PBD::Controllable::GroupControlDisposition);
122 /* fills at_set with all members of the group that are AudioTracks */
124 void audio_track_group (std::set<boost::shared_ptr<AudioTrack> >& at_set);
131 bool has_subgroup() const;
132 void make_subgroup (bool, Placement);
133 void destroy_subgroup ();
135 boost::shared_ptr<RouteList> route_list() { return routes; }
137 /** Emitted when a route has been added to this group */
138 PBD::Signal2<void, RouteGroup *, boost::weak_ptr<ARDOUR::Route> > RouteAdded;
139 /** Emitted when a route has been removed from this group */
140 PBD::Signal2<void, RouteGroup *, boost::weak_ptr<ARDOUR::Route> > RouteRemoved;
142 XMLNode& get_state ();
144 int set_state (const XMLNode&, int version);
147 boost::shared_ptr<RouteList> routes;
148 boost::shared_ptr<Route> subgroup_bus;
150 PBD::Property<bool> _relative;
151 PBD::Property<bool> _active;
152 PBD::Property<bool> _hidden;
153 PBD::Property<bool> _gain;
154 PBD::Property<bool> _mute;
155 PBD::Property<bool> _solo;
156 PBD::Property<bool> _recenable;
157 PBD::Property<bool> _select;
158 PBD::Property<bool> _route_active;
159 PBD::Property<bool> _color;
160 PBD::Property<bool> _monitoring;
162 boost::shared_ptr<ControlGroup> _solo_group;
163 boost::shared_ptr<ControlGroup> _mute_group;
164 boost::shared_ptr<ControlGroup> _rec_enable_group;
165 boost::shared_ptr<ControlGroup> _gain_group;
166 boost::shared_ptr<ControlGroup> _monitoring_group;
168 void remove_when_going_away (boost::weak_ptr<Route>);
169 int set_state_2X (const XMLNode&, int);
171 void post_set (PBD::PropertyChange const &);
172 void push_to_groups ();
177 #endif /* __ardour_route_group_h__ */