Ardour  8.12
port_group.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2015 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2009-2011 David Robillard <d@drobilla.net>
4  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef __gtk_ardour_port_group_h__
22 #define __gtk_ardour_port_group_h__
23 
24 #include <memory>
25 #include <set>
26 #include <string>
27 #include <vector>
28 
29 #include "pbd/signals.h"
30 
31 #include <gtkmm/widget.h>
32 #include <gtkmm/checkbutton.h>
33 
34 #include "ardour/bundle.h"
35 #include "ardour/data_type.h"
36 #include "ardour/types.h"
37 
38 namespace ARDOUR {
39  class Session;
40  class Processor;
41  class IO;
42 }
43 
44 class PortMatrix;
45 class PublicEditor;
46 
50 class PortGroup : public sigc::trackable
51 {
52 public:
53  PortGroup (std::string const & n);
55 
56  void add_bundle (std::shared_ptr<ARDOUR::Bundle>, bool allow_dups = false);
57  void add_bundle (std::shared_ptr<ARDOUR::Bundle>, std::shared_ptr<ARDOUR::IO> io);
58  void add_bundle (std::shared_ptr<ARDOUR::Bundle>, std::shared_ptr<ARDOUR::IO>, Gdk::Color);
59  void remove_bundle (std::shared_ptr<ARDOUR::Bundle>);
60  std::shared_ptr<ARDOUR::Bundle> only_bundle ();
61  void clear ();
63  std::shared_ptr<ARDOUR::IO> io_from_bundle (std::shared_ptr<ARDOUR::Bundle>) const;
65 
66  std::string name;
67 
68  bool has_port (std::string const &) const;
69 
71  PBD::Signal0<void> Changed;
72 
74  PBD::Signal1<void,ARDOUR::Bundle::Change> BundleChanged;
75 
76  struct BundleRecord {
77  std::shared_ptr<ARDOUR::Bundle> bundle;
80  std::weak_ptr<ARDOUR::IO> io;
82  bool has_colour;
84 
85  BundleRecord (std::shared_ptr<ARDOUR::Bundle>, std::shared_ptr<ARDOUR::IO>, Gdk::Color, bool has_colour);
86  };
87 
88  typedef std::list<BundleRecord*> BundleList;
89 
90  BundleList const & bundles () const {
91  return _bundles;
92  }
93 
94 private:
96  void add_bundle_internal (std::shared_ptr<ARDOUR::Bundle>, std::shared_ptr<ARDOUR::IO>, bool, Gdk::Color, bool);
97 
99 };
100 
102 class PortGroupList : public sigc::trackable
103 {
104 public:
107 
108  typedef std::vector<std::shared_ptr<PortGroup> > List;
109 
110  void add_group (std::shared_ptr<PortGroup>);
111  void add_group_if_not_empty (std::shared_ptr<PortGroup>);
112  void gather (ARDOUR::Session *, ARDOUR::DataType, bool, bool, bool);
113  PortGroup::BundleList const & bundles () const;
114  void clear ();
115  void remove_bundle (std::shared_ptr<ARDOUR::Bundle>);
117  uint32_t size () const {
118  return _groups.size();
119  }
120  std::shared_ptr<ARDOUR::IO> io_from_bundle (std::shared_ptr<ARDOUR::Bundle>) const;
121 
123  void resume_signals ();
124 
125  List::const_iterator begin () const {
126  return _groups.begin ();
127  }
128 
129  List::const_iterator end () const {
130  return _groups.end ();
131  }
132 
133  bool empty () const;
134 
136  PBD::Signal0<void> Changed;
137 
139  PBD::Signal1<void,ARDOUR::Bundle::Change> BundleChanged;
140 
141 private:
142  bool port_has_prefix (std::string const &, std::string const &) const;
143  std::string common_prefix (std::vector<std::string> const &) const;
144  std::string common_prefix_before (std::vector<std::string> const &, std::string const &) const;
145  void emit_changed ();
147  std::shared_ptr<ARDOUR::Bundle> make_bundle_from_ports (std::vector<std::string> const &, ARDOUR::DataType, bool, std::string const& bundle_name = std::string()) const;
148  void add_bundles_for_ports (std::vector<std::string> const &, ARDOUR::DataType, bool, bool, std::shared_ptr<PortGroup>) const;
149  void maybe_add_processor_to_list (std::weak_ptr<ARDOUR::Processor>, std::list<std::shared_ptr<ARDOUR::IO> > *, bool, std::set<std::shared_ptr<ARDOUR::IO> > &);
150 
158 };
159 
160 #endif /* __gtk_ardour_port_group_h__ */
A list of PortGroups.
Definition: port_group.h:103
PBD::Signal0< void > Changed
Definition: port_group.h:136
std::shared_ptr< ARDOUR::IO > io_from_bundle(std::shared_ptr< ARDOUR::Bundle >) const
void emit_bundle_changed(ARDOUR::Bundle::Change)
void add_bundles_for_ports(std::vector< std::string > const &, ARDOUR::DataType, bool, bool, std::shared_ptr< PortGroup >) const
PBD::ScopedConnectionList _bundle_changed_connections
Definition: port_group.h:153
List::const_iterator end() const
Definition: port_group.h:129
uint32_t size() const
Definition: port_group.h:117
void add_group_if_not_empty(std::shared_ptr< PortGroup >)
void maybe_add_processor_to_list(std::weak_ptr< ARDOUR::Processor >, std::list< std::shared_ptr< ARDOUR::IO > > *, bool, std::set< std::shared_ptr< ARDOUR::IO > > &)
std::vector< std::shared_ptr< PortGroup > > List
Definition: port_group.h:108
std::string common_prefix(std::vector< std::string > const &) const
ARDOUR::Bundle::Change _pending_bundle_change
Definition: port_group.h:157
void resume_signals()
PBD::ScopedConnectionList _changed_connections
Definition: port_group.h:154
PortGroup::BundleList _bundles
Definition: port_group.h:151
std::string common_prefix_before(std::vector< std::string > const &, std::string const &) const
void suspend_signals()
List::const_iterator begin() const
Definition: port_group.h:125
bool _signals_suspended
Definition: port_group.h:155
void remove_bundle(std::shared_ptr< ARDOUR::Bundle >)
void add_group(std::shared_ptr< PortGroup >)
PortGroup::BundleList const & bundles() const
void emit_changed()
bool port_has_prefix(std::string const &, std::string const &) const
ARDOUR::ChanCount total_channels() const
PBD::Signal1< void, ARDOUR::Bundle::Change > BundleChanged
Definition: port_group.h:139
void gather(ARDOUR::Session *, ARDOUR::DataType, bool, bool, bool)
std::shared_ptr< ARDOUR::Bundle > make_bundle_from_ports(std::vector< std::string > const &, ARDOUR::DataType, bool, std::string const &bundle_name=std::string()) const
bool empty() const
bool _pending_change
Definition: port_group.h:156
void add_bundle_internal(std::shared_ptr< ARDOUR::Bundle >, std::shared_ptr< ARDOUR::IO >, bool, Gdk::Color, bool)
std::shared_ptr< ARDOUR::Bundle > only_bundle()
std::string name
name for the group
Definition: port_group.h:66
ARDOUR::ChanCount total_channels() const
std::list< BundleRecord * > BundleList
Definition: port_group.h:88
void remove_bundle(std::shared_ptr< ARDOUR::Bundle >)
void clear()
void remove_duplicates()
BundleList _bundles
Definition: port_group.h:98
void add_bundle(std::shared_ptr< ARDOUR::Bundle >, std::shared_ptr< ARDOUR::IO > io)
void bundle_changed(ARDOUR::Bundle::Change)
std::shared_ptr< ARDOUR::IO > io_from_bundle(std::shared_ptr< ARDOUR::Bundle >) const
PBD::Signal0< void > Changed
Definition: port_group.h:71
void add_bundle(std::shared_ptr< ARDOUR::Bundle >, bool allow_dups=false)
PortGroup(std::string const &n)
PBD::Signal1< void, ARDOUR::Bundle::Change > BundleChanged
Definition: port_group.h:74
bool has_port(std::string const &) const
BundleList const & bundles() const
Definition: port_group.h:90
void add_bundle(std::shared_ptr< ARDOUR::Bundle >, std::shared_ptr< ARDOUR::IO >, Gdk::Color)
Representation of the interface of the Editor class.
std::shared_ptr< ARDOUR::Bundle > bundle
Definition: port_group.h:77
std::weak_ptr< ARDOUR::IO > io
Definition: port_group.h:80
PBD::ScopedConnection changed_connection
Definition: port_group.h:83
BundleRecord(std::shared_ptr< ARDOUR::Bundle >, std::shared_ptr< ARDOUR::IO >, Gdk::Color, bool has_colour)