From ce4f43343f7554d550e71ca16d9b5ce1ce5fcc13 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 28 Nov 2020 21:11:58 +0100 Subject: Add separate store for client and port metadata --- src/Metadata.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/Metadata.cpp (limited to 'src/Metadata.cpp') 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 + * + * 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 . + */ + +#include "Metadata.hpp" + +boost::optional +Metadata::client(const ClientID& id) +{ + const auto i = _client_data.find(id); + if (i == _client_data.end()) { + return {}; + } + + return i->second; +} + +boost::optional +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); +} -- cgit v1.2.1