move templated foreach methods from TrackSelection into parent (TrackViewList)

This allows the same methods to be used on e.g. Editor::track_views
This commit is contained in:
Paul Davis 2020-04-03 13:23:41 -06:00
parent e954303fec
commit 97d1ee9822
2 changed files with 79 additions and 63 deletions

View File

@ -22,9 +22,6 @@
#define __ardour_gtk_track_selection_h__
#include "track_view_list.h"
#include "route_ui.h"
#include "audio_time_axis.h"
#include "midi_time_axis.h"
class PublicEditor;
@ -36,65 +33,6 @@ public:
virtual ~TrackSelection ();
template <typename Function>
void foreach_time_axis (Function f) {
for (iterator i = begin(); i != end(); ++i) {
f (*i);
}
}
template <typename Function>
void foreach_route_ui (Function f) {
for (iterator i = begin(); i != end(); ) {
iterator tmp = i;
++tmp;
RouteUI* t = dynamic_cast<RouteUI*> (*i);
if (t) {
f (t);
}
i = tmp;
}
}
template <typename Function>
void foreach_route_time_axis (Function f) {
for (iterator i = begin(); i != end(); ) {
iterator tmp = i;
++tmp;
RouteTimeAxisView* t = dynamic_cast<RouteTimeAxisView*> (*i);
if (t) {
f (t);
}
i = tmp;
}
}
template <typename Function>
void foreach_audio_time_axis (Function f) {
for (iterator i = begin(); i != end(); ) {
iterator tmp = i;
++tmp;
AudioTimeAxisView* t = dynamic_cast<AudioTimeAxisView*> (*i);
if (t) {
f (t);
}
i = tmp;
}
}
template <typename Function>
void foreach_midi_time_axis (Function f) {
for (iterator i = begin(); i != end(); ) {
iterator tmp = i;
++tmp;
MidiTimeAxisView* t = dynamic_cast<MidiTimeAxisView*> (*i);
if (t) {
f (t);
}
i = tmp;
}
}
private:
PublicEditor const * _editor;

View File

@ -20,10 +20,15 @@
#ifndef __ardour_gtk_track_view_list_h__
#define __ardour_gtk_track_view_list_h__
#include "ardour/types.h"
#include "ardour/types.h" /* XXX is this here because of some Cocoa nonsense ? */
#include <list>
#include <set>
#include "route_ui.h"
#include "audio_time_axis.h"
#include "midi_time_axis.h"
class TimeAxisView;
class TrackViewList : public std::list<TimeAxisView*>
@ -39,6 +44,79 @@ public:
TrackViewList filter_to_unique_playlists ();
ARDOUR::RouteList routelist () const;
template <typename Function>
void foreach_time_axis (Function f) {
for (iterator i = begin(); i != end(); ++i) {
f (*i);
}
}
template <typename Function>
void foreach_route_ui (Function f) {
for (iterator i = begin(); i != end(); ) {
iterator tmp = i;
++tmp;
RouteUI* t = dynamic_cast<RouteUI*> (*i);
if (t) {
f (t);
}
i = tmp;
}
}
template <typename Function>
void foreach_stripable_time_axis (Function f) {
for (iterator i = begin(); i != end(); ) {
iterator tmp = i;
++tmp;
StripableTimeAxisView* t = dynamic_cast<StripableTimeAxisView*> (*i);
if (t) {
f (t);
}
i = tmp;
}
}
template <typename Function>
void foreach_route_time_axis (Function f) {
for (iterator i = begin(); i != end(); ) {
iterator tmp = i;
++tmp;
RouteTimeAxisView* t = dynamic_cast<RouteTimeAxisView*> (*i);
if (t) {
f (t);
}
i = tmp;
}
}
template <typename Function>
void foreach_audio_time_axis (Function f) {
for (iterator i = begin(); i != end(); ) {
iterator tmp = i;
++tmp;
AudioTimeAxisView* t = dynamic_cast<AudioTimeAxisView*> (*i);
if (t) {
f (t);
}
i = tmp;
}
}
template <typename Function>
void foreach_midi_time_axis (Function f) {
for (iterator i = begin(); i != end(); ) {
iterator tmp = i;
++tmp;
MidiTimeAxisView* t = dynamic_cast<MidiTimeAxisView*> (*i);
if (t) {
f (t);
}
i = tmp;
}
}
};
#endif