2 * Copyright (C) 2015-2016 Robin Gareus <robin@gareus.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef __ardour_route_graph_h__
20 #define __ardour_route_graph_h__
27 typedef boost::shared_ptr<Route> GraphVertex;
29 /** A list of edges for a directed graph for routes.
31 * It keeps the same data in a few different ways, with add() adding edges
32 * to all different representations, remove() removing similarly, and the
33 * lookup method using whichever representation is most efficient for
34 * that particular lookup.
36 * This may be a premature optimisation...
38 class LIBARDOUR_API GraphEdges
41 typedef std::map<GraphVertex, std::set<GraphVertex> > EdgeMap;
43 void add (GraphVertex from, GraphVertex to, bool via_sends_only);
44 bool has (GraphVertex from, GraphVertex to, bool* via_sends_only);
45 bool feeds (GraphVertex from, GraphVertex to);
46 std::set<GraphVertex> from (GraphVertex r) const;
47 void remove (GraphVertex from, GraphVertex to);
48 bool has_none_to (GraphVertex to) const;
53 void insert (EdgeMap& e, GraphVertex a, GraphVertex b);
55 typedef std::multimap<GraphVertex, std::pair<GraphVertex, bool> > EdgeMapWithSends;
57 EdgeMapWithSends::iterator find_in_from_to_with_sends (GraphVertex, GraphVertex);
58 EdgeMapWithSends::iterator find_recursively_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>,