1 /*
2  * Copyright (C) 2010-2011 David Robillard <d@drobilla.net>
3  * Copyright (C) 2013-2016 Robin Gareus <robin@gareus.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef __ardour_gtk_track_view_list_h__
21 #define __ardour_gtk_track_view_list_h__
22 
23 #include "ardour/types.h" /* XXX is this here because of some Cocoa nonsense ? */
24 
25 #include <list>
26 #include <set>
27 
28 #include "route_ui.h"
29 #include "audio_time_axis.h"
30 #include "midi_time_axis.h"
31 
32 class TimeAxisView;
33 
34 class TrackViewList : public std::list<TimeAxisView*>
35 {
36 public:
TrackViewList()37 	TrackViewList () {}
38 	TrackViewList (std::list<TimeAxisView*> const &);
39 
40 	virtual ~TrackViewList ();
41 
42 	virtual TrackViewList add (TrackViewList const &);
43 	bool contains (TimeAxisView const *) const;
44 
45 	TrackViewList filter_to_unique_playlists ();
46 	ARDOUR::RouteList routelist () const;
47 
48 	template <typename Function>
foreach_time_axis(Function f)49 	void foreach_time_axis (Function f) {
50 		for (iterator i = begin(); i != end(); ++i) {
51 			f (*i);
52 		}
53 	}
54 
55 	template <typename Function>
foreach_route_ui(Function f)56 	void foreach_route_ui (Function f) {
57 		for (iterator i = begin(); i != end(); ) {
58 			iterator tmp = i;
59 			++tmp;
60 
61 			RouteUI* t = dynamic_cast<RouteUI*> (*i);
62 			if (t) {
63 				f (t);
64 			}
65 			i = tmp;
66 		}
67 	}
68 
69 	template <typename Function>
foreach_stripable_time_axis(Function f)70 	void foreach_stripable_time_axis (Function f) {
71 		for (iterator i = begin(); i != end(); ) {
72 			iterator tmp = i;
73 			++tmp;
74 			StripableTimeAxisView* t = dynamic_cast<StripableTimeAxisView*> (*i);
75 			if (t) {
76 				f (t);
77 			}
78 			i = tmp;
79 		}
80 	}
81 
82 	template <typename Function>
foreach_route_time_axis(Function f)83 	void foreach_route_time_axis (Function f) {
84 		for (iterator i = begin(); i != end(); ) {
85 			iterator tmp = i;
86 			++tmp;
87 			RouteTimeAxisView* t = dynamic_cast<RouteTimeAxisView*> (*i);
88 			if (t) {
89 				f (t);
90 			}
91 			i = tmp;
92 		}
93 	}
94 
95 	template <typename Function>
foreach_audio_time_axis(Function f)96 	void foreach_audio_time_axis (Function f) {
97 		for (iterator i = begin(); i != end(); ) {
98 			iterator tmp = i;
99 			++tmp;
100 			AudioTimeAxisView* t = dynamic_cast<AudioTimeAxisView*> (*i);
101 			if (t) {
102 				f (t);
103 			}
104 			i = tmp;
105 		}
106 	}
107 
108 	template <typename Function>
foreach_midi_time_axis(Function f)109 	void foreach_midi_time_axis (Function f) {
110 		for (iterator i = begin(); i != end(); ) {
111 			iterator tmp = i;
112 			++tmp;
113 			MidiTimeAxisView* t = dynamic_cast<MidiTimeAxisView*> (*i);
114 			if (t) {
115 				f (t);
116 			}
117 			i = tmp;
118 		}
119 	}
120 };
121 
122 #endif
123 
124