merge from 2.0-ongoing @ 3581
[ardour.git] / libs / ardour / ardour / bundle.h
1 /*
2     Copyright (C) 2002-2007 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 */
19
20 #ifndef __ardour_bundle_h__
21 #define __ardour_bundle_h__
22
23 #include <string>
24 #include <sigc++/signal.h>
25
26 #include "ardour/data_type.h"
27 #include "ardour/chan_count.h"
28
29 namespace ARDOUR {
30
31 typedef std::vector<std::string> PortList;
32   
33 /**
34  *  A set of `channels', each of which is associated with 0 or more JACK ports.
35  */
36
37 class Bundle {
38   public:
39         Bundle () : _type (DataType::AUDIO) {}
40         Bundle (bool i) : _type (DataType::AUDIO), _ports_are_inputs (i) {}
41         Bundle (std::string const & n, bool i = true) : _name (n), _type (DataType::AUDIO), _ports_are_inputs (i) {}
42
43         virtual ~Bundle() {}
44
45         /**
46          *  @return Number of channels that this Bundle has.
47          */
48         virtual ChanCount nchannels () const = 0;
49         virtual const PortList& channel_ports (uint32_t) const = 0;
50
51         void set_name (std::string const & n) {
52                 _name = n;
53                 NameChanged ();
54         }
55         
56         std::string name () const { return _name; }
57
58         sigc::signal<void> NameChanged;
59
60         void set_type (DataType t) { _type = t; }
61         DataType type () const { return _type; }
62
63         void set_ports_are_inputs () { _ports_are_inputs = true; }
64         void set_ports_are_outputs () { _ports_are_inputs = false; }
65         bool ports_are_inputs () const { return _ports_are_inputs; }
66         bool ports_are_outputs () const { return !_ports_are_inputs; }
67
68   private:
69         std::string _name;
70         ARDOUR::DataType _type;
71         bool _ports_are_inputs;
72 };
73
74 }
75
76 #endif /* __ardour_bundle_h__ */