Use sigc::slots rather than templates + function ptrs for a foreach_region and foreac...
authorCarl Hetherington <carl@carlh.net>
Wed, 3 Jun 2009 00:23:34 +0000 (00:23 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 3 Jun 2009 00:23:34 +0000 (00:23 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@5118 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/audio_streamview.cc
gtk2_ardour/automation_streamview.cc
gtk2_ardour/crossfade_edit.cc
gtk2_ardour/midi_streamview.cc
libs/ardour/ardour/audioplaylist.h
libs/ardour/ardour/playlist.h
libs/ardour/ardour/playlist_templates.h [deleted file]
libs/ardour/audio_playlist.cc
libs/ardour/playlist.cc

index 19e2e2368b83fc75296cdaa99ace2d62e100d57b..03f3d3d8bde6b100f81a0098dc6dff9382c655de 100644 (file)
@@ -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
index c36085a77cd4d151272565404e3644d52bdf05f9..0ba49fd2d9c801391da861d54278cfe0af303e6f 100644 (file)
@@ -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
index 6b6c47f218f0f70d403ff9861b9d5746b5395a9a..e239ad9fdf0a4b9981e53b6bb2508accbae10f17 100644 (file)
@@ -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 ();
 }
index 047020ea62303fbdb842ef7c438a9f2417bbb85c..b7fa88404e6b3b1a07fb7e4815ae6f7c45340b76 100644 (file)
@@ -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();
index b2e36a10f715683cca4ddcd23c11de1f9086dfe9..1d4118cf83f5746744a49f4fae5e2df2f5025dc3 100644 (file)
@@ -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>);
index 8be95ca74b9dbaace0b0477db8cfb57086f8f280..1671d685d552917728fcca827eaee64489288bad 100644 (file)
@@ -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 (file)
index bf072a7..0000000
+++ /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__ */
index 6439c1b91776dec6f96d9ebdcaa5ef5e3eb81a89..7f89091fdd0a9535c0cea8e9e98cd02fa21bd78a 100644 (file)
@@ -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);
+       }
+}
index 4942485a70ffc3a620cb56426fcc7a6be17bad14..22dacc69a03e68b2273b306a44db0f4d7a2b2971 100644 (file)
@@ -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);
+       }
+}
+
+