summaryrefslogtreecommitdiffstats
path: root/src/Metadata.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-28 21:11:58 +0100
committerDavid Robillard <d@drobilla.net>2020-11-28 22:49:10 +0100
commitce4f43343f7554d550e71ca16d9b5ce1ce5fcc13 (patch)
treeba20eadccbb1358519506a57b12038c011481485 /src/Metadata.cpp
parentf53a94419853b63a0f97deab1cf4ccedd4088f3b (diff)
downloadpatchage-ce4f43343f7554d550e71ca16d9b5ce1ce5fcc13.tar.gz
patchage-ce4f43343f7554d550e71ca16d9b5ce1ce5fcc13.tar.bz2
patchage-ce4f43343f7554d550e71ca16d9b5ce1ce5fcc13.zip
Add separate store for client and port metadata
Diffstat (limited to 'src/Metadata.cpp')
-rw-r--r--src/Metadata.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/Metadata.cpp b/src/Metadata.cpp
new file mode 100644
index 0000000..d717387
--- /dev/null
+++ b/src/Metadata.cpp
@@ -0,0 +1,73 @@
+/* This file is part of Patchage.
+ * Copyright 2014-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/>.
+ */
+
+#include "Metadata.hpp"
+
+boost::optional<ClientInfo>
+Metadata::client(const ClientID& id)
+{
+ const auto i = _client_data.find(id);
+ if (i == _client_data.end()) {
+ return {};
+ }
+
+ return i->second;
+}
+
+boost::optional<PortInfo>
+Metadata::port(const PortID& id)
+{
+ const auto i = _port_data.find(id);
+ if (i == _port_data.end()) {
+ return {};
+ }
+
+ return i->second;
+}
+
+void
+Metadata::set_client(const ClientID& id, const ClientInfo& info)
+{
+ const auto i = _client_data.find(id);
+ if (i == _client_data.end()) {
+ _client_data.emplace(id, info);
+ } else {
+ i->second = info;
+ }
+}
+
+void
+Metadata::set_port(const PortID& id, const PortInfo& info)
+{
+ const auto i = _port_data.find(id);
+ if (i == _port_data.end()) {
+ _port_data.emplace(id, info);
+ } else {
+ i->second = info;
+ }
+}
+
+void
+Metadata::erase_client(const ClientID& id)
+{
+ _client_data.erase(id);
+}
+
+void
+Metadata::erase_port(const PortID& id)
+{
+ _port_data.erase(id);
+}