/*
- Copyright (C) 2000 Paul Davis
+ Copyright (C) 2000 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
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id$
*/
#ifndef __ardour_session_route_h__
#include <iostream>
-#include <pbd/lockmonitor.h>
-#include <ardour/session.h>
-#include <ardour/route.h>
+#include <glibmm/threads.h>
+
+#include "ardour/session.h"
+#include "ardour/route.h"
namespace ARDOUR {
-template<class T> void
-Session::foreach_route (T *obj, void (T::*func)(Route&))
+template<class T> void
+Session::foreach_route (T *obj, void (T::*func)(Route&), bool sort)
{
- RouteList public_order;
+ boost::shared_ptr<RouteList> r = routes.reader();
+ RouteList public_order (*r);
- {
- RWLockMonitor lm (route_lock, false, __LINE__, __FILE__);
- public_order = routes;
+ if (sort) {
+ public_order.sort (RoutePublicOrderSorter());
}
- RoutePublicOrderSorter cmp;
- public_order.sort (cmp);
-
for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) {
(obj->*func) (**i);
}
}
-template<class T> void
-Session::foreach_route (T *obj, void (T::*func)(Route*))
+template<class T> void
+Session::foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>), bool sort)
{
- RouteList public_order;
+ boost::shared_ptr<RouteList> r = routes.reader();
+ RouteList public_order (*r);
- {
- RWLockMonitor lm (route_lock, false, __LINE__, __FILE__);
- public_order = routes;
+ if (sort) {
+ public_order.sort (RoutePublicOrderSorter());
}
- RoutePublicOrderSorter cmp;
- public_order.sort (cmp);
-
for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) {
(obj->*func) (*i);
}
}
-
-template<class T, class A> void
-Session::foreach_route (T *obj, void (T::*func)(Route&, A), A arg1)
+template<class T, class A> void
+Session::foreach_route (T *obj, void (T::*func)(Route&, A), A arg1, bool sort)
{
- RouteList public_order;
+ boost::shared_ptr<RouteList> r = routes.reader();
+ RouteList public_order (*r);
- {
- RWLockMonitor lm (route_lock, false, __LINE__, __FILE__);
- public_order = routes;
+ if (sort) {
+ public_order.sort (RoutePublicOrderSorter());
}
- RoutePublicOrderSorter cmp;
- public_order.sort (cmp);
-
for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) {
(obj->*func) (**i, arg1);
}