Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
22 
23 #include <memory>
24 #include <set>
25 #include <string>
26 #include <vector>
27 
28 #include "pbd/signals.h"
29 
30 #include <gtkmm/widget.h>
31 #include <gtkmm/checkbutton.h>
32 
33 #include "ardour/bundle.h"
34 #include "ardour/data_type.h"
35 #include "ardour/types.h"
36 
37 namespace ARDOUR {
38  class Session;
39  class Processor;
40  class IO;
41 }
42 
43 class PortMatrix;
44 class PublicEditor;
45 
49 class PortGroup : public sigc::trackable
50 {
51 public:
52  PortGroup (std::string const & n);
54 
55  void add_bundle (std::shared_ptr<ARDOUR::Bundle>, bool allow_dups = false);
56  void add_bundle (std::shared_ptr<ARDOUR::Bundle>, std::shared_ptr<ARDOUR::IO> io);
57  void add_bundle (std::shared_ptr<ARDOUR::Bundle>, std::shared_ptr<ARDOUR::IO>, Gdk::Color);
58  void remove_bundle (std::shared_ptr<ARDOUR::Bundle>);
59  std::shared_ptr<ARDOUR::Bundle> only_bundle ();
60  void clear ();
62  std::shared_ptr<ARDOUR::IO> io_from_bundle (std::shared_ptr<ARDOUR::Bundle>) const;
64 
65  std::string name;
66 
67  bool has_port (std::string const &) const;
68 
71 
74 
75  struct BundleRecord {
76  std::shared_ptr<ARDOUR::Bundle> bundle;
79  std::weak_ptr<ARDOUR::IO> io;
81  bool has_colour;
83 
84  BundleRecord (std::shared_ptr<ARDOUR::Bundle>, std::shared_ptr<ARDOUR::IO>, Gdk::Color, bool has_colour);
85  };
86 
87  typedef std::list<BundleRecord*> BundleList;
88 
89  BundleList const & bundles () const {
90  return _bundles;
91  }
92 
93 private:
95  void add_bundle_internal (std::shared_ptr<ARDOUR::Bundle>, std::shared_ptr<ARDOUR::IO>, bool, Gdk::Color, bool);
96 
98 };
99 
101 class PortGroupList : public sigc::trackable
102 {
103 public:
106 
107  typedef std::vector<std::shared_ptr<PortGroup> > List;
108 
109  void add_group (std::shared_ptr<PortGroup>);
110  void add_group_if_not_empty (std::shared_ptr<PortGroup>);
111  void gather (ARDOUR::Session *, ARDOUR::DataType, bool, bool, bool);
112  PortGroup::BundleList const & bundles () const;
113  void clear ();
114  void remove_bundle (std::shared_ptr<ARDOUR::Bundle>);
116  uint32_t size () const {
117  return _groups.size();
118  }
119  std::shared_ptr<ARDOUR::IO> io_from_bundle (std::shared_ptr<ARDOUR::Bundle>) const;
120 
122  void resume_signals ();
123 
124  List::const_iterator begin () const {
125  return _groups.begin ();
126  }
127 
128  List::const_iterator end () const {
129  return _groups.end ();
130  }
131 
132  bool empty () const;
133 
136 
139 
140 private:
141  bool port_has_prefix (std::string const &, std::string const &) const;
142  std::string common_prefix (std::vector<std::string> const &) const;
143  std::string common_prefix_before (std::vector<std::string> const &, std::string const &) const;
144  void emit_changed ();
146  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;
147  void add_bundles_for_ports (std::vector<std::string> const &, ARDOUR::DataType, bool, bool, std::shared_ptr<PortGroup>) const;
148  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> > &);
149 
157 };
158 
A list of PortGroups.
Definition: port_group.h:102
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:152
List::const_iterator end() const
Definition: port_group.h:128
uint32_t size() const
Definition: port_group.h:116
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:107
PBD::Signal< void()> Changed
Definition: port_group.h:135
std::string common_prefix(std::vector< std::string > const &) const
ARDOUR::Bundle::Change _pending_bundle_change
Definition: port_group.h:156
void resume_signals()
PBD::ScopedConnectionList _changed_connections
Definition: port_group.h:153
PortGroup::BundleList _bundles
Definition: port_group.h:150
PBD::Signal< void(ARDOUR::Bundle::Change)> BundleChanged
Definition: port_group.h:138
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:124
bool _signals_suspended
Definition: port_group.h:154
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
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:155
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:65
ARDOUR::ChanCount total_channels() const
std::list< BundleRecord * > BundleList
Definition: port_group.h:87
PBD::Signal< void(ARDOUR::Bundle::Change)> BundleChanged
Definition: port_group.h:73
PBD::Signal< void()> Changed
Definition: port_group.h:70
void remove_bundle(std::shared_ptr< ARDOUR::Bundle >)
void clear()
void remove_duplicates()
BundleList _bundles
Definition: port_group.h:97
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
void add_bundle(std::shared_ptr< ARDOUR::Bundle >, bool allow_dups=false)
PortGroup(std::string const &n)
bool has_port(std::string const &) const
BundleList const & bundles() const
Definition: port_group.h:89
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:76
std::weak_ptr< ARDOUR::IO > io
Definition: port_group.h:79
PBD::ScopedConnection changed_connection
Definition: port_group.h:82
BundleRecord(std::shared_ptr< ARDOUR::Bundle >, std::shared_ptr< ARDOUR::IO >, Gdk::Color, bool has_colour)