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&);
63 /* other Port management */
65 bool port_is_physical (const std::string&) const;
66 void get_physical_outputs (DataType type, std::vector<std::string>&);
67 void get_physical_inputs (DataType type, std::vector<std::string>&);
68 boost::shared_ptr<Port> get_port_by_name (const std::string &);
69 void port_renamed (const std::string&, const std::string&);
70 ChanCount n_physical_outputs () const;
71 ChanCount n_physical_inputs () const;
72 const char ** get_ports (const std::string& port_name_pattern, const std::string& type_name_pattern, uint32_t flags);
74 void remove_all_ports ();
76 /* per-Port monitoring */
78 bool can_request_input_monitoring () const;
79 void request_input_monitoring (const std::string&, bool) const;
80 void ensure_input_monitoring (const std::string&, bool) const;
82 std::string make_port_name_relative (const std::string&) const;
83 std::string make_port_name_non_relative (const std::string&) const;
84 bool port_is_mine (const std::string&) const;
86 class PortRegistrationFailure : public std::exception {
88 PortRegistrationFailure (std::string const & why = "")
91 ~PortRegistrationFailure () throw () {}
93 const char *what() const throw () { return reason.c_str(); }
102 SerializedRCUManager<Ports> ports;
104 boost::shared_ptr<Port> register_port (DataType type, const std::string& portname, bool input);
105 void port_registration_failure (const std::string& portname);
110 #endif /* __libardour_port_manager_h__ */