summaryrefslogtreecommitdiff
path: root/libs/ardour/port_manager.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-09-10 16:26:48 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2015-09-10 16:41:34 -0400
commitc7e755b25c485f6d20a0c49230c558245511c9ba (patch)
tree03185c2f176aac6a278bf10df715905796fedcd8 /libs/ardour/port_manager.cc
parent306f234a5b115b3a4bbc40509dab6a7d910958d5 (diff)
add PortManager::port_name_prefix_is_unique()
Diffstat (limited to 'libs/ardour/port_manager.cc')
-rw-r--r--libs/ardour/port_manager.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/libs/ardour/port_manager.cc b/libs/ardour/port_manager.cc
index a1a4397551..02e7719cc4 100644
--- a/libs/ardour/port_manager.cc
+++ b/libs/ardour/port_manager.cc
@@ -17,6 +17,7 @@
*/
+#include "pbd/convert.h"
#include "pbd/error.h"
#include "ardour/async_midi_port.h"
@@ -197,6 +198,28 @@ PortManager::n_physical_inputs () const
return _backend->n_physical_inputs ();
}
+bool
+PortManager::port_name_prefix_is_unique (const string& first_part_of_port_name) const
+{
+ if (!_backend) {
+ return boost::shared_ptr<Port>();
+ }
+
+ boost::shared_ptr<const Ports> pr = ports.reader();
+ const string::size_type len = first_part_of_port_name.length();
+
+ for (Ports::const_iterator x = pr->begin(); x != pr->end(); ++x) {
+
+ string prefix = x->first.substr (0, len);
+
+ if (strings_equal_ignore_case (prefix, first_part_of_port_name)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
/** @param name Full or short name of port
* @return Corresponding Port or 0.
*/