Mercurial > hg > piper-cpp
diff bits/PreservingPluginHandleMapper.h @ 65:2d866edd79d5
Merge from noexcept branch
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Fri, 23 Sep 2016 14:23:10 +0100 |
parents | 8a4bcb3dc3a6 |
children |
line wrap: on
line diff
--- a/bits/PreservingPluginHandleMapper.h Fri Sep 23 14:20:29 2016 +0100 +++ b/bits/PreservingPluginHandleMapper.h Fri Sep 23 14:23:10 2016 +0100 @@ -54,30 +54,34 @@ m_plugin(0), m_omapper(std::make_shared<PreservingPluginOutputIdMapper>()) { } - virtual Handle pluginToHandle(Vamp::Plugin *p) const { + virtual Handle pluginToHandle(Vamp::Plugin *p) const noexcept { + if (!p) return INVALID_HANDLE; if (p == m_plugin) return m_handle; else { std::cerr << "PreservingPluginHandleMapper: p = " << p << " differs from saved m_plugin " << m_plugin << " (not returning saved handle " << m_handle << ")" << std::endl; - throw NotFound(); + return INVALID_HANDLE; } } - virtual Vamp::Plugin *handleToPlugin(Handle h) const { + virtual Vamp::Plugin *handleToPlugin(Handle h) const noexcept { + if (h == INVALID_HANDLE) return nullptr; m_handle = h; m_plugin = reinterpret_cast<Vamp::Plugin *>(h); return m_plugin; } virtual const std::shared_ptr<PluginOutputIdMapper> pluginToOutputIdMapper - (Vamp::Plugin *) const { + (Vamp::Plugin *p) const noexcept { + if (!p) return {}; return m_omapper; } virtual const std::shared_ptr<PluginOutputIdMapper> handleToOutputIdMapper - (Handle h) const { + (Handle h) const noexcept { + if (h == INVALID_HANDLE) return {}; return m_omapper; }