Remove most using declarations from header files.
[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 */
19
20 #ifndef __ardour_route_group_h__
21 #define __ardour_route_group_h__
22
23 #include <list>
24 #include <set>
25 #include <string>
26 #include <stdint.h>
27 #include <sigc++/signal.h>
28 #include "pbd/stateful.h" 
29 #include "ardour/types.h"
30
31 namespace ARDOUR {
32
33 class Route;
34 class Track;
35 class AudioTrack;
36 class Session;
37
38 class RouteGroup : public PBD::Stateful, public sigc::trackable {
39   public:
40     enum Flag {
41             Relative = 0x1,
42             Active = 0x2,
43             Hidden = 0x4
44     };
45
46     RouteGroup (Session& s, const std::string &n, Flag f = Flag(0));
47
48     const std::string& name() { return _name; }
49     void set_name (std::string str);
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     int add (Route *);
67
68     int remove (Route *);
69
70     void apply (void (Route::*func)(void *), void *src) {
71             for (std::list<Route *>::iterator i = routes.begin(); i != routes.end(); i++) {
72                     ((*i)->*func)(src);
73             }
74     }
75
76     template<class T> void apply (void (Route::*func)(T, void *), T val, void *src) {
77             for (std::list<Route *>::iterator i = routes.begin(); i != routes.end(); i++) {
78                     ((*i)->*func)(val, src);
79             }
80     }
81
82     template<class T> void foreach_route (T *obj, void (T::*func)(Route&)) {
83             for (std::list<Route *>::iterator i = routes.begin(); i != routes.end(); i++) {
84                     (obj->*func)(**i);
85             }
86     }
87
88     /* to use these, #include "ardour/route_group_specialized.h" */
89
90     template<class T> void apply (void (Track::*func)(T, void *), T val, void *src);
91
92     /* fills at_set with all members of the group that are AudioTracks */
93
94     void audio_track_group (std::set<AudioTrack*>& at_set);
95
96     void clear () {
97             routes.clear ();
98             changed();
99     }
100
101     const std::list<Route*>& route_list() { return routes; }
102     
103     sigc::signal<void> changed;
104     sigc::signal<void,void*> FlagsChanged;
105
106     XMLNode& get_state (void);
107
108     int set_state (const XMLNode&);
109
110  private:
111     Session& _session;
112     std::list<Route *> routes;
113     std::string _name;
114     Flag _flags;
115
116     void remove_when_going_away (Route*);
117 };
118
119 } /* namespace */
120
121 #endif /* __ardour_route_group_h__ */