summaryrefslogtreecommitdiffstats
path: root/src/PortNames.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-28 12:02:55 +0100
committerDavid Robillard <d@drobilla.net>2020-11-28 12:45:57 +0100
commit0ae4276ac187a9a361950f26bd67eb2d54636aff (patch)
treecc46c2ff5df75d426de5e80b891042ae1ebb7bf3 /src/PortNames.hpp
parent4ac8e622bb4ef5841435fc0815efb6bb756f76da (diff)
downloadpatchage-0ae4276ac187a9a361950f26bd67eb2d54636aff.tar.gz
patchage-0ae4276ac187a9a361950f26bd67eb2d54636aff.tar.bz2
patchage-0ae4276ac187a9a361950f26bd67eb2d54636aff.zip
Simplify driver connection interface
Diffstat (limited to 'src/PortNames.hpp')
-rw-r--r--src/PortNames.hpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/PortNames.hpp b/src/PortNames.hpp
new file mode 100644
index 0000000..e976e34
--- /dev/null
+++ b/src/PortNames.hpp
@@ -0,0 +1,44 @@
+/* This file is part of Patchage.
+ * Copyright 2008-2020 David Robillard <d@drobilla.net>
+ *
+ * Patchage is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Patchage is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Patchage. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PATCHAGE_PORTNAMES_HPP
+#define PATCHAGE_PORTNAMES_HPP
+
+#include <cassert>
+#include <string>
+
+/// Utility class that splits a Jack port ID into client and client names
+class PortNames
+{
+public:
+ explicit PortNames(const PortID& id)
+ {
+ assert(id.type() == PortID::Type::jack);
+
+ const auto colon = id.jack_name().find(':');
+ _client_name = id.jack_name().substr(0, colon);
+ _port_name = id.jack_name().substr(colon + 1);
+ }
+
+ const std::string& client() const { return _client_name; }
+ const std::string& port() const { return _port_name; }
+
+private:
+ std::string _client_name;
+ std::string _port_name;
+};
+
+#endif // PATCHAGE_PORTNAMES_HPP