2 Copyright (C) 2013 Paul Davis
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
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __libardour_port_manager_h__
21 #define __libardour_port_manager_h__
30 #include <boost/shared_ptr.hpp>
34 #include "ardour/chan_count.h"
35 #include "ardour/port.h"
36 #include "ardour/port_engine.h"
43 typedef std::map<std::string,boost::shared_ptr<Port> > Ports;
46 virtual ~PortManager() {}
48 PortEngine& port_engine() { return *_impl; }
50 /* Port registration */
52 boost::shared_ptr<Port> register_input_port (DataType, const std::string& portname);
53 boost::shared_ptr<Port> register_output_port (DataType, const std::string& portname);
54 int unregister_port (boost::shared_ptr<Port>);
56 /* Port connectivity */
58 int connect (const std::string& source, const std::string& destination);
59 int disconnect (const std::string& source, const std::string& destination);
60 int disconnect (boost::shared_ptr<Port>);
61 bool connected (const std::string&);
62 int reestablish_ports ();
63 int reconnect_ports ();
65 /* other Port management */
67 bool port_is_physical (const std::string&) const;
68 void get_physical_outputs (DataType type, std::vector<std::string>&);
69 void get_physical_inputs (DataType type, std::vector<std::string>&);
70 boost::shared_ptr<Port> get_port_by_name (const std::string &);
71 void port_renamed (const std::string&, const std::string&);
72 ChanCount n_physical_outputs () const;
73 ChanCount n_physical_inputs () const;
74 const char ** get_ports (const std::string& port_name_pattern, const std::string& type_name_pattern, uint32_t flags);
76 void remove_all_ports ();
78 /* per-Port monitoring */
80 bool can_request_input_monitoring () const;
81 void request_input_monitoring (const std::string&, bool) const;
82 void ensure_input_monitoring (const std::string&, bool) const;
84 class PortRegistrationFailure : public std::exception {
86 PortRegistrationFailure (std::string const & why = "")
89 ~PortRegistrationFailure () throw () {}
91 const char *what() const throw () { return reason.c_str(); }
100 SerializedRCUManager<Ports> ports;
102 boost::shared_ptr<Port> register_port (DataType type, const std::string& portname, bool input);
103 void port_registration_failure (const std::string& portname);
108 #endif /* __libardour_port_manager_h__ */