summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-06-03 00:23:34 +0000
committerCarl Hetherington <carl@carlh.net>2009-06-03 00:23:34 +0000
commita75e811edb7aa1da6359f5e2a104e582e2848e47 (patch)
treeecce91c408e9ef9cade62c2f055b73e67a648809
parent27915ccdc07d4463daa1fbf61d3d6764e0aea67e (diff)
Use sigc::slots rather than templates + function ptrs for a foreach_region and foreach_crossfade.
git-svn-id: svn://localhost/ardour2/branches/3.0@5118 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/audio_streamview.cc14
-rw-r--r--gtk2_ardour/automation_streamview.cc3
-rw-r--r--gtk2_ardour/crossfade_edit.cc3
-rw-r--r--gtk2_ardour/midi_streamview.cc8
-rw-r--r--libs/ardour/ardour/audioplaylist.h2
-rw-r--r--libs/ardour/ardour/playlist.h4
-rw-r--r--libs/ardour/ardour/playlist_templates.h48
-rw-r--r--libs/ardour/audio_playlist.cc8
-rw-r--r--libs/ardour/playlist.cc20
9 files changed, 46 insertions, 64 deletions
diff --git a/gtk2_ardour/audio_streamview.cc b/gtk2_ardour/audio_streamview.cc
index 19e2e2368b..03f3d3d8bd 100644
--- a/gtk2_ardour/audio_streamview.cc
+++ b/gtk2_ardour/audio_streamview.cc
@@ -29,7 +29,6 @@
#include "ardour/audiofilesource.h"
#include "ardour/audio_diskstream.h"
#include "ardour/audio_track.h"
-#include "ardour/playlist_templates.h"
#include "ardour/source.h"
#include "ardour/region_factory.h"
#include "ardour/profile.h"
@@ -401,13 +400,16 @@ AudioStreamView::redisplay_diskstream ()
if (_trackview.is_audio_track()) {
_trackview.get_diskstream()->playlist()->foreach_region(
- static_cast<StreamView*>(this),
- &StreamView::add_region_view);
+ sigc::mem_fun (*this, &StreamView::add_region_view)
+ );
boost::shared_ptr<AudioPlaylist> apl = boost::dynamic_pointer_cast<AudioPlaylist>(
- _trackview.get_diskstream()->playlist());
- if (apl)
- apl->foreach_crossfade (this, &AudioStreamView::add_crossfade);
+ _trackview.get_diskstream()->playlist()
+ );
+
+ if (apl) {
+ apl->foreach_crossfade (sigc::mem_fun (*this, &AudioStreamView::add_crossfade));
+ }
}
// Remove invalid crossfade views
diff --git a/gtk2_ardour/automation_streamview.cc b/gtk2_ardour/automation_streamview.cc
index c36085a77c..0ba49fd2d9 100644
--- a/gtk2_ardour/automation_streamview.cc
+++ b/gtk2_ardour/automation_streamview.cc
@@ -167,7 +167,8 @@ AutomationStreamView::redisplay_diskstream ()
// Add and display region views, and flag them as valid
if (_trackview.is_track()) {
_trackview.get_diskstream()->playlist()->foreach_region (
- static_cast<StreamView*>(this), &StreamView::add_region_view);
+ sigc::mem_fun (*this, &StreamView::add_region_view)
+ );
}
// Stack regions by layer, and remove invalid regions
diff --git a/gtk2_ardour/crossfade_edit.cc b/gtk2_ardour/crossfade_edit.cc
index 6b6c47f218..e239ad9fdf 100644
--- a/gtk2_ardour/crossfade_edit.cc
+++ b/gtk2_ardour/crossfade_edit.cc
@@ -34,7 +34,6 @@
#include "ardour/auditioner.h"
#include "ardour/audioplaylist.h"
#include "ardour/audiosource.h"
-#include "ardour/playlist_templates.h"
#include "ardour/region_factory.h"
#include "ardour/profile.h"
@@ -1234,7 +1233,7 @@ CrossfadeEditor::audition (Audition which)
}
/* there is only one ... */
- pl.foreach_crossfade (this, &CrossfadeEditor::setup);
+ pl.foreach_crossfade (sigc::mem_fun (*this, &CrossfadeEditor::setup));
session.audition_playlist ();
}
diff --git a/gtk2_ardour/midi_streamview.cc b/gtk2_ardour/midi_streamview.cc
index 047020ea62..b7fa88404e 100644
--- a/gtk2_ardour/midi_streamview.cc
+++ b/gtk2_ardour/midi_streamview.cc
@@ -243,8 +243,8 @@ MidiStreamView::redisplay_diskstream ()
_data_note_min = 127;
_data_note_max = 0;
_trackview.get_diskstream()->playlist()->foreach_region(
- static_cast<StreamView*>(this),
- &StreamView::update_contents_metrics);
+ sigc::mem_fun (*this, &StreamView::update_contents_metrics)
+ );
// No notes, use default range
if (!_range_dirty) {
@@ -266,8 +266,8 @@ MidiStreamView::redisplay_diskstream ()
// Add and display region views, and flag them as valid
_trackview.get_diskstream()->playlist()->foreach_region(
- static_cast<StreamView*>(this),
- &StreamView::add_region_view);
+ sigc::mem_fun (*this, &StreamView::add_region_view)
+ );
// Stack regions by layer, and remove invalid regions
layer_regions();
diff --git a/libs/ardour/ardour/audioplaylist.h b/libs/ardour/ardour/audioplaylist.h
index b2e36a10f7..1d4118cf83 100644
--- a/libs/ardour/ardour/audioplaylist.h
+++ b/libs/ardour/ardour/audioplaylist.h
@@ -54,7 +54,7 @@ class AudioPlaylist : public ARDOUR::Playlist
sigc::signal<void,boost::shared_ptr<Crossfade> > NewCrossfade;
- template<class T> void foreach_crossfade (T *t, void (T::*func)(boost::shared_ptr<Crossfade>));
+ void foreach_crossfade (sigc::slot<void, boost::shared_ptr<Crossfade> >);
void crossfades_at (nframes_t frame, Crossfades&);
bool destroy_region (boost::shared_ptr<Region>);
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index 8be95ca74b..1671d685d5 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -120,8 +120,8 @@ class Playlist : public SessionObject,
nframes64_t find_next_transient (nframes64_t position, int dir);
- template<class T> void foreach_region (T *t, void (T::*func)(boost::shared_ptr<Region>, void *), void *arg);
- template<class T> void foreach_region (T *t, void (T::*func)(boost::shared_ptr<Region>));
+ void foreach_region (sigc::slot<void, boost::shared_ptr<Region>, void *>, void *);
+ void foreach_region (sigc::slot<void, boost::shared_ptr<Region> >);
XMLNode& get_state ();
int set_state (const XMLNode&);
diff --git a/libs/ardour/ardour/playlist_templates.h b/libs/ardour/ardour/playlist_templates.h
deleted file mode 100644
index bf072a71c1..0000000000
--- a/libs/ardour/ardour/playlist_templates.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- Copyright (C) 2003 Paul Davis
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef __ardour_playlist_templates_h__
-#define __ardour_playlist_templates_h__
-
-namespace ARDOUR {
-
-template<class T> void AudioPlaylist::foreach_crossfade (T *t, void (T::*func)(boost::shared_ptr<Crossfade>)) {
- RegionLock rlock (this, false);
- for (Crossfades::iterator i = _crossfades.begin(); i != _crossfades.end(); i++) {
- (t->*func) (*i);
- }
-}
-
-template<class T> void Playlist::foreach_region (T *t, void (T::*func)(boost::shared_ptr<Region>, void *), void *arg) {
- RegionLock rlock (this, false);
- for (RegionList::iterator i = regions.begin(); i != regions.end(); i++) {
- (t->*func) ((*i), arg);
- }
- }
-
-template<class T> void Playlist::foreach_region (T *t, void (T::*func)(boost::shared_ptr<Region>)) {
- RegionLock rlock (this, false);
- for (RegionList::const_iterator i = regions.begin(); i != regions.end(); i++) {
- (t->*func) (*i);
- }
-}
-
-}
-
-#endif /* __ardour_playlist_templates_h__ */
diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc
index 6439c1b917..7f89091fdd 100644
--- a/libs/ardour/audio_playlist.cc
+++ b/libs/ardour/audio_playlist.cc
@@ -786,3 +786,11 @@ AudioPlaylist::crossfades_at (nframes_t frame, Crossfades& clist)
}
}
+void
+AudioPlaylist::foreach_crossfade (sigc::slot<void, boost::shared_ptr<Crossfade> > s)
+{
+ RegionLock rl (this, false);
+ for (Crossfades::iterator i = _crossfades.begin(); i != _crossfades.end(); ++i) {
+ s (*i);
+ }
+}
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index 4942485a70..22dacc69a0 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -2395,3 +2395,23 @@ Playlist::update_after_tempo_map_change ()
thaw ();
}
+
+void
+Playlist::foreach_region (sigc::slot<void, boost::shared_ptr<Region>, void *> s, void* arg)
+{
+ RegionLock rl (this, false);
+ for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
+ s (*i, arg);
+ }
+}
+
+void
+Playlist::foreach_region (sigc::slot<void, boost::shared_ptr<Region> > s)
+{
+ RegionLock rl (this, false);
+ for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
+ s (*i);
+ }
+}
+
+