allow to customize variable i/o plugin inputs
[ardour.git] / libs / ardour / route_graph.cc
index ee02afef2401710aaca5a8987a612d98e1386c06..910141a44029c901343c43a8720d5f5d45d839d7 100644 (file)
@@ -59,6 +59,24 @@ GraphEdges::find_in_from_to_with_sends (GraphVertex from, GraphVertex to)
        return _from_to_with_sends.end ();
 }
 
+GraphEdges::EdgeMapWithSends::iterator
+GraphEdges::find_recursively_in_from_to_with_sends (GraphVertex from, GraphVertex to)
+{
+       typedef EdgeMapWithSends::iterator Iter;
+       pair<Iter, Iter> r = _from_to_with_sends.equal_range (from);
+       for (Iter i = r.first; i != r.second; ++i) {
+               if (i->second.first == to) {
+                       return i;
+               }
+               GraphEdges::EdgeMapWithSends::iterator t = find_recursively_in_from_to_with_sends (i->second.first, to);
+               if (t != _from_to_with_sends.end ()) {
+                       return t;
+               }
+       }
+
+       return _from_to_with_sends.end ();
+}
+
 /** @param via_sends_only if non-0, filled in with true if the edge is a
  *  path via a send only.
  *  @return true if the given edge is present.
@@ -70,7 +88,7 @@ GraphEdges::has (GraphVertex from, GraphVertex to, bool* via_sends_only)
        if (i == _from_to_with_sends.end ()) {
                return false;
        }
-       
+
        if (via_sends_only) {
                *via_sends_only = i->second.second;
        }
@@ -78,6 +96,16 @@ GraphEdges::has (GraphVertex from, GraphVertex to, bool* via_sends_only)
        return true;
 }
 
+bool
+GraphEdges::feeds (GraphVertex from, GraphVertex to)
+{
+       EdgeMapWithSends::iterator i = find_recursively_in_from_to_with_sends (from, to);
+       if (i == _from_to_with_sends.end ()) {
+               return false;
+       }
+       return true;
+}
+
 /** @return the vertices that are fed from `r' */
 set<GraphVertex>
 GraphEdges::from (GraphVertex r) const
@@ -86,7 +114,7 @@ GraphEdges::from (GraphVertex r) const
        if (i == _from_to.end ()) {
                return set<GraphVertex> ();
        }
-       
+
        return i->second;
 }
 
@@ -99,7 +127,7 @@ GraphEdges::remove (GraphVertex from, GraphVertex to)
        if (i->second.empty ()) {
                _from_to.erase (i);
        }
-       
+
        EdgeMap::iterator j = _to_from.find (to);
        assert (j != _to_from.end ());
        j->second.erase (from);
@@ -139,7 +167,7 @@ GraphEdges::dump () const
                }
                cout << "\n";
        }
-       
+
        for (EdgeMap::const_iterator i = _to_from.begin(); i != _to_from.end(); ++i) {
                cout << "TO: " << i->first->name() << " ";
                for (set<GraphVertex>::const_iterator j = i->second.begin(); j != i->second.end(); ++j) {
@@ -197,7 +225,7 @@ ARDOUR::topological_sort (
        )
 {
        boost::shared_ptr<RouteList> sorted_routes (new RouteList);
-       
+
        /* queue of routes to process */
        RouteList queue;
 
@@ -217,7 +245,7 @@ ARDOUR::topological_sort (
        /* Do the sort: algorithm is Kahn's from Wikipedia.
           `Topological sorting of large networks', Communications of the ACM 5(11):558-562.
        */
-       
+
        while (!queue.empty ()) {
                GraphVertex r = queue.front ();
                queue.pop_front ();