Build correctly on mactel systems.
[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 <string>
26 #include <stdint.h>
27 #include <sigc++/signal.h>
28 #include <ardour/stateful.h>
29 #include <ardour/types.h>
30
31 using std::string;
32 using std::list;
33
34 namespace ARDOUR {
35
36 class Route;
37 class AudioTrack;
38
39 class RouteGroup : public Stateful, public sigc::trackable {
40   public:
41     enum Flag {
42             Relative = 0x1,
43             Active = 0x2,
44             Hidden = 0x4,
45     };
46
47     RouteGroup(const string &n, Flag f = Flag(0)) : _name (n), _flags (f) {}
48
49     const string& name() { return _name; }
50
51     bool is_active () const { return _flags & Active; }
52     bool is_relative () const { return _flags & Relative; }
53     bool is_hidden () const { return _flags & Hidden; }
54     bool empty() const {return routes.empty();}
55
56         gain_t get_max_factor(gain_t factor);
57         gain_t get_min_factor(gain_t factor);
58
59     int size() { return routes.size();}
60     ARDOUR::Route * first () const { return *routes.begin();}
61
62     void set_active (bool yn, void *src);
63     void set_relative (bool yn, void *src);
64     void set_hidden (bool yn, void *src);
65
66
67     int add (Route *);
68
69     int remove (Route *);
70
71     template<class T> void apply (void (Route::*func)(T, void *), T val, void *src) {
72             for (list<Route *>::iterator i = routes.begin(); i != routes.end(); i++) {
73                     ((*i)->*func)(val, this);
74             }
75     }
76
77     template<class T> void foreach_route (T *obj, void (T::*func)(Route&)) {
78             for (list<Route *>::iterator i = routes.begin(); i != routes.end(); i++) {
79                     (obj->*func)(**i);
80             }
81     }
82
83     /* to use these, #include <ardour/route_group_specialized.h> */
84
85     template<class T> void apply (void (AudioTrack::*func)(T, void *), T val, void *src);
86
87     void clear () {
88             routes.clear ();
89             changed();
90     }
91
92     const list<Route*>& route_list() { return routes; }
93     
94     sigc::signal<void> changed;
95     sigc::signal<void,void*> FlagsChanged;
96
97     XMLNode& get_state (void);
98
99     int set_state (const XMLNode&);
100
101  private:
102     list<Route *> routes;
103     string _name;
104     uint32_t _flags;
105
106     void remove_when_going_away (Route*);
107 };
108
109 } /* namespace */
110
111 #endif /* __ardour_route_group_h__ */