2 Copyright (C) 2011 Paul Davis
3 Author: Carl Hetherington <cth@carlh.net>
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.
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.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __ardour_route_graph_h__
22 #define __ardour_route_graph_h__
29 typedef boost::shared_ptr<Route> GraphVertex;
31 /** A list of edges for a directed graph for routes.
33 * It keeps the same data in a few different ways, with add() adding edges
34 * to all different representations, remove() removing similarly, and the
35 * lookup method using whichever representation is most efficient for
36 * that particular lookup.
38 * This may be a premature optimisation...
40 class LIBARDOUR_API GraphEdges
43 typedef std::map<GraphVertex, std::set<GraphVertex> > EdgeMap;
45 void add (GraphVertex from, GraphVertex to, bool via_sends_only);
46 bool has (GraphVertex from, GraphVertex to, bool* via_sends_only);
47 std::set<GraphVertex> from (GraphVertex r) const;
48 void remove (GraphVertex from, GraphVertex to);
49 bool has_none_to (GraphVertex to) const;
54 void insert (EdgeMap& e, GraphVertex a, GraphVertex b);
56 typedef std::multimap<GraphVertex, std::pair<GraphVertex, bool> > EdgeMapWithSends;
58 EdgeMapWithSends::iterator find_in_from_to_with_sends (GraphVertex, GraphVertex);
60 /** map of edges with from as `first' and to as `second' */
62 /** map of the same edges with to as `first' and from as `second' */
64 /** map of edges with via-sends information; first part of the map is
65 the `from' vertex, second is the `to' vertex and a flag which is
66 true if the edge is via a send only.
68 EdgeMapWithSends _from_to_with_sends;
71 boost::shared_ptr<RouteList> topological_sort (
72 boost::shared_ptr<RouteList>,