export range markers patch (revisited), change selection model, copy-drag tempo+meter...
[ardour.git] / libs / ardour / ardour / route_group.h
1 /*
2     Copyright (C) 2000 Paul Davis 
3
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.
8
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.
13
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.
17
18     $Id$
19 */
20
21 #ifndef __ardour_route_group_h__
22 #define __ardour_route_group_h__
23
24 #include <list>
25 #include <set>
26 #include <string>
27 #include <stdint.h>
28 #include <sigc++/signal.h>
29 #include <ardour/stateful.h>
30 #include <ardour/types.h>
31
32 using std::string;
33 using std::list;
34
35 namespace ARDOUR {
36
37 class Route;
38 class AudioTrack;
39
40 class RouteGroup : public Stateful, public sigc::trackable {
41   public:
42     enum Flag {
43             Relative = 0x1,
44             Active = 0x2,
45             Hidden = 0x4,
46     };
47
48     RouteGroup(const string &n, Flag f = Flag(0)) : _name (n), _flags (f) {}
49
50     const string& name() { return _name; }
51
52     bool is_active () const { return _flags & Active; }
53     bool is_relative () const { return _flags & Relative; }
54     bool is_hidden () const { return _flags & Hidden; }
55     bool empty() const {return routes.empty();}
56
57         gain_t get_max_factor(gain_t factor);
58         gain_t get_min_factor(gain_t factor);
59
60     int size() { return routes.size();}
61     ARDOUR::Route * first () const { return *routes.begin();}
62
63     void set_active (bool yn, void *src);
64     void set_relative (bool yn, void *src);
65     void set_hidden (bool yn, void *src);
66
67
68     int add (Route *);
69
70     int remove (Route *);
71
72     template<class T> void apply (void (Route::*func)(T, void *), T val, void *src) {
73             for (list<Route *>::iterator i = routes.begin(); i != routes.end(); i++) {
74                     ((*i)->*func)(val, this);
75             }
76     }
77
78     template<class T> void foreach_route (T *obj, void (T::*func)(Route&)) {
79             for (list<Route *>::iterator i = routes.begin(); i != routes.end(); i++) {
80                     (obj->*func)(**i);
81             }
82     }
83
84     /* to use these, #include <ardour/route_group_specialized.h> */
85
86     template<class T> void apply (void (AudioTrack::*func)(T, void *), T val, void *src);
87
88     /* fills at_set with all members of the group that are AudioTracks */
89
90     void audio_track_group (std::set<AudioTrack*>& at_set);
91
92     void clear () {
93             routes.clear ();
94             changed();
95     }
96
97     const list<Route*>& route_list() { return routes; }
98     
99     sigc::signal<void> changed;
100     sigc::signal<void,void*> FlagsChanged;
101
102     XMLNode& get_state (void);
103
104     int set_state (const XMLNode&);
105
106  private:
107     list<Route *> routes;
108     string _name;
109     uint32_t _flags;
110
111     void remove_when_going_away (Route*);
112 };
113
114 } /* namespace */
115
116 #endif /* __ardour_route_group_h__ */