ardour
port_group.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2009 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 __gtk_ardour_port_group_h__
21 #define __gtk_ardour_port_group_h__
22 
23 #include <vector>
24 #include <string>
25 #include <set>
26 #include <boost/shared_ptr.hpp>
27 #include "pbd/signals.h"
28 
29 #include <gtkmm/widget.h>
30 #include <gtkmm/checkbutton.h>
31 
32 #include "ardour/data_type.h"
33 #include "ardour/types.h"
34 
35 namespace ARDOUR {
36  class Session;
37  class Bundle;
38  class Processor;
39  class IO;
40 }
41 
42 class PortMatrix;
43 class PublicEditor;
44 
48 class PortGroup : public sigc::trackable
49 {
50 public:
51  PortGroup (std::string const & n);
52  ~PortGroup ();
53 
54  void add_bundle (boost::shared_ptr<ARDOUR::Bundle>, bool allow_dups = false);
59  void clear ();
62  void remove_duplicates ();
63 
64  std::string name;
65 
66  bool has_port (std::string const &) const;
67 
69  PBD::Signal0<void> Changed;
70 
72  PBD::Signal1<void,ARDOUR::Bundle::Change> BundleChanged;
73 
74  struct BundleRecord {
79  Gdk::Color colour;
80  bool has_colour;
82 
84  };
85 
86  typedef std::list<BundleRecord*> BundleList;
87 
88  BundleList const & bundles () const {
89  return _bundles;
90  }
91 
92 private:
95 
96  BundleList _bundles;
97 };
98 
100 class PortGroupList : public sigc::trackable
101 {
102  public:
103  PortGroupList ();
104  ~PortGroupList();
105 
106  typedef std::vector<boost::shared_ptr<PortGroup> > List;
107 
110  void gather (ARDOUR::Session *, ARDOUR::DataType, bool, bool, bool);
111  PortGroup::BundleList const & bundles () const;
112  void clear ();
115  uint32_t size () const {
116  return _groups.size();
117  }
119 
120  void suspend_signals ();
121  void resume_signals ();
122 
123  List::const_iterator begin () const {
124  return _groups.begin ();
125  }
126 
127  List::const_iterator end () const {
128  return _groups.end ();
129  }
130 
131  bool empty () const;
132 
134  PBD::Signal0<void> Changed;
135 
137  PBD::Signal1<void,ARDOUR::Bundle::Change> BundleChanged;
138 
139  private:
140  bool port_has_prefix (std::string const &, std::string const &) const;
141  std::string common_prefix (std::vector<std::string> const &) const;
142  std::string common_prefix_before (std::vector<std::string> const &, std::string const &) const;
143  void emit_changed ();
145  boost::shared_ptr<ARDOUR::Bundle> make_bundle_from_ports (std::vector<std::string> const &, ARDOUR::DataType, bool) const;
148  );
149 
151  List _groups;
157 };
158 
159 #endif /* __gtk_ardour_port_group_h__ */
PBD::Signal1< void, ARDOUR::Bundle::Change > BundleChanged
Definition: port_group.h:72
void suspend_signals()
Definition: port_group.cc:758
List::const_iterator begin() const
Definition: port_group.h:123
void resume_signals()
Definition: port_group.cc:764
boost::shared_ptr< ARDOUR::Bundle > bundle
Definition: port_group.h:75
void remove_bundle(boost::shared_ptr< ARDOUR::Bundle >)
Definition: port_group.cc:133
void gather(ARDOUR::Session *, ARDOUR::DataType, bool, bool, bool)
Definition: port_group.cc:329
void add_bundle_internal(boost::shared_ptr< ARDOUR::Bundle >, boost::shared_ptr< ARDOUR::IO >, bool, Gdk::Color, bool)
Definition: port_group.cc:107
PBD::ScopedConnectionList _changed_connections
Definition: port_group.h:153
boost::shared_ptr< ARDOUR::Bundle > make_bundle_from_ports(std::vector< std::string > const &, ARDOUR::DataType, bool) const
Definition: port_group.cc:603
boost::weak_ptr< ARDOUR::IO > io
Definition: port_group.h:78
std::list< BundleRecord * > BundleList
Definition: port_group.h:86
Representation of the interface of the Editor class.
void clear()
Definition: port_group.cc:160
std::string name
name for the group
Definition: port_group.h:64
bool empty() const
Definition: port_group.cc:795
void emit_bundle_changed(ARDOUR::Bundle::Change)
Definition: port_group.cc:749
PortGroup::BundleList _bundles
Definition: port_group.h:150
void add_group(boost::shared_ptr< PortGroup >)
Definition: port_group.cc:718
bool _pending_change
Definition: port_group.h:155
boost::shared_ptr< ARDOUR::IO > io_from_bundle(boost::shared_ptr< ARDOUR::Bundle >) const
Definition: port_group.cc:780
PBD::ScopedConnectionList _bundle_changed_connections
Definition: port_group.h:152
List::const_iterator end() const
Definition: port_group.h:127
std::string common_prefix_before(std::vector< std::string > const &, std::string const &) const
Definition: port_group.cc:632
void remove_duplicates()
Definition: port_group.cc:219
A list of PortGroups.
Definition: port_group.h:100
BundleList const & bundles() const
Definition: port_group.h:88
PBD::Signal0< void > Changed
Definition: port_group.h:69
BundleList _bundles
Definition: port_group.h:96
std::string common_prefix(std::vector< std::string > const &) const
Definition: port_group.cc:660
void add_bundle(boost::shared_ptr< ARDOUR::Bundle >, bool allow_dups=false)
Definition: port_group.cc:73
void maybe_add_processor_to_list(boost::weak_ptr< ARDOUR::Processor >, std::list< boost::shared_ptr< ARDOUR::IO > > *, bool, std::set< boost::shared_ptr< ARDOUR::IO > > &)
Definition: port_group.cc:281
std::vector< boost::shared_ptr< PortGroup > > List
Definition: port_group.h:106
void emit_changed()
Definition: port_group.cc:739
bool port_has_prefix(std::string const &, std::string const &) const
Definition: port_group.cc:626
Definition: amp.h:29
PortGroup::BundleList const & bundles() const
Definition: port_group.cc:686
PBD::Signal0< void > Changed
Definition: port_group.h:134
boost::shared_ptr< ARDOUR::IO > io_from_bundle(boost::shared_ptr< ARDOUR::Bundle >) const
Definition: port_group.cc:202
ARDOUR::ChanCount total_channels() const
Definition: port_group.cc:191
ARDOUR::Bundle::Change _pending_bundle_change
Definition: port_group.h:156
uint32_t size() const
Definition: port_group.h:115
PBD::Signal1< void, ARDOUR::Bundle::Change > BundleChanged
Definition: port_group.h:137
ARDOUR::ChanCount total_channels() const
Definition: port_group.cc:698
void bundle_changed(ARDOUR::Bundle::Change)
Definition: port_group.cc:153
PortGroup(std::string const &n)
Definition: port_group.cc:54
PBD::ScopedConnection changed_connection
Definition: port_group.h:81
boost::shared_ptr< ARDOUR::Bundle > only_bundle()
Definition: port_group.cc:183
void add_group_if_not_empty(boost::shared_ptr< PortGroup >)
Definition: port_group.cc:710
BundleRecord(boost::shared_ptr< ARDOUR::Bundle >, boost::shared_ptr< ARDOUR::IO >, Gdk::Color, bool has_colour)
Definition: port_group.cc:98
bool has_port(std::string const &) const
Definition: port_group.cc:171
bool _signals_suspended
Definition: port_group.h:154
void remove_bundle(boost::shared_ptr< ARDOUR::Bundle >)
Definition: port_group.cc:729