ardour
bundle.h
Go to the documentation of this file.
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 <vector>
25 #include <glibmm/threads.h>
26 #include <boost/shared_ptr.hpp>
27 
28 #include "pbd/signals.h"
29 
30 #include "ardour/data_type.h"
31 #include "ardour/chan_count.h"
32 
33 namespace ARDOUR {
34 
35 class AudioEngine;
36 
44 {
45  public:
46 
50  typedef std::vector<std::string> PortList;
51 
52  struct Channel {
53  Channel (std::string n, DataType t) : name (n), type (t) {}
54  Channel (std::string n, DataType t, PortList p) : name (n), type (t), ports (p) {}
55  Channel (std::string n, DataType t, std::string const & p) : name (n), type (t) {
56  ports.push_back (p);
57  }
58 
59  bool operator== (Channel const &o) const {
60  return name == o.name && type == o.type && ports == o.ports;
61  }
62 
63  std::string name;
65  PortList ports;
66  };
67 
68  Bundle (bool i = true);
69  Bundle (std::string const &, bool i = true);
71 
72  virtual ~Bundle() {}
73 
75  ChanCount nchannels () const;
76 
80  PortList const & channel_ports (uint32_t) const;
81 
82  void add_channel (std::string const &, DataType);
83  void add_channel (std::string const &, DataType, std::string const &);
84  void add_channel (std::string const &, DataType, PortList);
85  std::string channel_name (uint32_t) const;
86  DataType channel_type (uint32_t) const;
87  void set_channel_name (uint32_t, std::string const &);
88  void add_port_to_channel (uint32_t, std::string);
89  void set_port (uint32_t, std::string);
90  void remove_port_from_channel (uint32_t, std::string);
91  void remove_ports_from_channel (uint32_t);
92  void remove_ports_from_channels ();
93  bool port_attached_to_channel (uint32_t, std::string);
94  bool offers_port (std::string) const;
95  bool offers_port_alone (std::string) const;
96  void remove_channel (uint32_t);
97  void remove_channels ();
98  void add_channels_from_bundle (boost::shared_ptr<Bundle>);
99  void connect (boost::shared_ptr<Bundle>, AudioEngine &);
100  void disconnect (boost::shared_ptr<Bundle>, AudioEngine &);
101  bool connected_to (boost::shared_ptr<Bundle>, AudioEngine &);
102  bool connected_to_anything (AudioEngine &);
103  bool has_same_ports (boost::shared_ptr<Bundle>) const;
104  uint32_t type_channel_to_overall (DataType, uint32_t) const;
105  uint32_t overall_channel_to_type (DataType, uint32_t) const;
106 
107  void set_name (std::string const &);
108 
110  std::string name () const { return _name; }
111 
112  void set_ports_are_inputs ();
113  void set_ports_are_outputs ();
114  bool ports_are_inputs () const { return _ports_are_inputs; }
115  bool ports_are_outputs () const { return !_ports_are_inputs; }
116 
117  void suspend_signals ();
118  void resume_signals ();
119 
120  bool operator== (Bundle const & other);
121 
123  enum Change {
124  NameChanged = 0x1,
125  ConfigurationChanged = 0x2,
126  PortsChanged = 0x4,
127  TypeChanged = 0x8,
128  DirectionChanged = 0x10
129  };
130 
131  PBD::Signal1<void,Change> Changed;
132 
133  protected:
134 
137  mutable Glib::Threads::Mutex _channel_mutex;
138  std::vector<Channel> _channel;
139 
140  private:
141  int set_channels (std::string const &);
142  int parse_io_string (std::string const &, std::vector<std::string> &);
143  void emit_changed (Change);
144 
145  std::string _name;
147 
150 };
151 
153 {
154 public:
155  BundleChannel () : channel (-1) {}
156 
158  : bundle (b), channel (c) {}
159 
160  bool operator== (BundleChannel const& other) const {
161  return bundle == other.bundle && channel == other.channel;
162  }
163 
164  bool operator!= (BundleChannel const& other) const {
165  return bundle != other.bundle || channel != other.channel;
166  }
167 
169  int channel;
170 };
171 
172 }
173 
174 std::ostream & operator<< (std::ostream & o, ARDOUR::Bundle const &);
175 
176 #endif /* __ardour_bundle_h__ */
bool operator!=(shared_ptr< T > const &a, shared_ptr< U > const &b)
Definition: shared_ptr.hpp:360
std::vector< std::string > PortList
Definition: bundle.h:50
bool ports_are_outputs() const
Definition: bundle.h:115
Change _pending_change
Definition: bundle.h:149
Channel(std::string n, DataType t, std::string const &p)
Definition: bundle.h:55
std::vector< Channel > _channel
Definition: bundle.h:138
bool _ports_are_inputs
Definition: bundle.h:146
std::string _name
Definition: bundle.h:145
Definition: amp.h:29
bool ports_are_inputs() const
Definition: bundle.h:114
BundleChannel(boost::shared_ptr< Bundle > b, int c)
Definition: bundle.h:157
Channel(std::string n, DataType t, PortList p)
Definition: bundle.h:54
std::string name() const
Definition: bundle.h:110
std::string name
Definition: bundle.h:63
#define LIBARDOUR_API
PBD::Signal1< void, Change > Changed
Definition: bundle.h:131
const char * name
boost::shared_ptr< Bundle > bundle
Definition: bundle.h:168
bool operator==(const RouteProcessorSelection &a, const RouteProcessorSelection &b)
Channel(std::string n, DataType t)
Definition: bundle.h:53
int channel
channel index, or -1 for "all"
Definition: bundle.h:169
virtual ~Bundle()
Definition: bundle.h:72
LIBARDOUR_API uint64_t AudioEngine
Definition: session.h:982
Glib::Threads::Mutex _channel_mutex
Definition: bundle.h:137
bool _signals_suspended
Definition: bundle.h:148
std::ostream & operator<<(std::ostream &o, ARDOUR::Bundle const &)