r269@gandalf: fugalh | 2006-08-03 20:18:05 -0600
[ardour.git] / libs / ardour / ardour / connection.h
1 /*
2     Copyright (C) 2002 Paul Davis 
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
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18     $Id$
19 */
20
21 #ifndef __ardour_connection_h__
22 #define __ardour_connection_h__
23
24 #include <vector>
25 #include <string>
26 #include <sigc++/signal.h>
27 #include <glibmm/thread.h>
28 #include <pbd/stateful.h> 
29
30 using std::vector;
31 using std::string;
32
33 namespace ARDOUR {
34
35 class Connection : public Stateful, public sigc::trackable {
36   public:
37         Connection (string name, bool sdep = false) : _name (name), _sysdep(sdep) {}
38         ~Connection() {}
39
40         typedef vector<string> PortList;
41
42         void set_name (string name, void *src);
43         string name() const { return _name; }
44         
45         bool system_dependent() const { return _sysdep; }
46
47         uint32_t nports () const { return _ports.size(); }
48         const PortList& port_connections (int port) const;
49
50         void add_connection (int port, string portname);
51         void remove_connection (int port, string portname);
52         
53         void add_port ();
54         void remove_port (int port);
55         void clear ();
56
57         sigc::signal<void,void*> NameChanged;
58         sigc::signal<void>       ConfigurationChanged;
59         sigc::signal<void,int>   ConnectionsChanged;
60
61         bool operator==(const Connection& other) const;
62
63         XMLNode& get_state (void);
64         int set_state (const XMLNode&);
65
66   protected:
67         Connection (const XMLNode&);
68
69   private:
70         mutable Glib::Mutex port_lock;
71         vector<PortList> _ports;
72         string _name;
73         bool   _sysdep;
74
75         int set_connections (const string& str);
76         int parse_io_string (const string& str, vector<string>& ports);
77 };
78
79 class InputConnection : public Connection {
80   public:
81         InputConnection (string name, bool sdep = false) : Connection (name, sdep) {}
82         InputConnection (const XMLNode&);
83 };
84
85 class OutputConnection : public Connection {
86   public:
87         OutputConnection (string name, bool sdep = false) : Connection (name, sdep) {}
88         OutputConnection (const XMLNode&);
89 };
90
91 }
92
93 #endif /* __ardour_connection_h__ */
94