Ardour  9.0-pre0-582-g084a23a80d
graph_edges.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2022 Robin Gareus <robin@gareus.org>
3  *
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.
8  *
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.
13  *
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.
17  */
18 
19 #pragma once
20 
21 #include <map>
22 #include <set>
23 
25 #include "ardour/types.h"
26 
27 namespace ARDOUR {
28 class GraphNode;
29 
30 typedef std::shared_ptr<GraphNode> GraphVertex;
31 
42 {
43 public:
44  void add (GraphVertex from, GraphVertex to, bool via_sends_only);
45  void remove (GraphVertex from, GraphVertex to);
46 
47  bool has (GraphVertex from, GraphVertex to, bool* via_sends_only);
48  bool feeds (GraphVertex from, GraphVertex to) const;
50  std::set<GraphVertex> from (GraphVertex r) const;
52  std::set<GraphVertex> to (GraphVertex r, bool via_sends_only = false) const;
53  bool has_none_to (GraphVertex to) const;
54  bool empty () const;
55  void dump () const;
56 
57 private:
58  typedef std::map<GraphVertex, std::set<GraphVertex> > EdgeMap;
59  typedef std::multimap<GraphVertex, std::pair<GraphVertex, bool> > EdgeMapWithSends;
60 
62 
63  EdgeMapWithSends::iterator find_in_from_to_with_sends (GraphVertex, GraphVertex);
64  EdgeMapWithSends::iterator find_in_to_from_with_sends (GraphVertex, GraphVertex);
65 
66  EdgeMapWithSends::const_iterator find_recursively_in_from_to_with_sends (GraphVertex, GraphVertex) const;
67 
78 };
79 
81 
82 }
83 
std::set< GraphVertex > to(GraphVertex r, bool via_sends_only=false) const
std::multimap< GraphVertex, std::pair< GraphVertex, bool > > EdgeMapWithSends
Definition: graph_edges.h:59
bool has(GraphVertex from, GraphVertex to, bool *via_sends_only)
std::set< GraphVertex > from(GraphVertex r) const
EdgeMapWithSends::iterator find_in_to_from_with_sends(GraphVertex, GraphVertex)
bool has_none_to(GraphVertex to) const
std::map< GraphVertex, std::set< GraphVertex > > EdgeMap
Definition: graph_edges.h:58
EdgeMapWithSends::iterator find_in_from_to_with_sends(GraphVertex, GraphVertex)
EdgeMapWithSends _from_to_with_sends
Definition: graph_edges.h:76
bool feeds(GraphVertex from, GraphVertex to) const
bool empty() const
void dump() const
EdgeMapWithSends _to_from_with_sends
Definition: graph_edges.h:77
void insert(EdgeMap &e, GraphVertex a, GraphVertex b)
void add(GraphVertex from, GraphVertex to, bool via_sends_only)
EdgeMapWithSends::const_iterator find_recursively_in_from_to_with_sends(GraphVertex, GraphVertex) const
void remove(GraphVertex from, GraphVertex to)
#define LIBARDOUR_API
bool topological_sort(GraphNodeList &, GraphEdges &)
std::shared_ptr< GraphNode > GraphVertex
Definition: graph_edges.h:28
std::list< std::shared_ptr< GraphNode > > GraphNodeList