Mercurial > hg > piper-cpp
comparison bits/PreservingPluginHandleMapper.h @ 60:8a4bcb3dc3a6
Replace exceptions throughout the JSON-handling and adapter code with string-arg error handling. No longer need exception handling enabled in Emscripten (with its consequent runtime overhead - though we still need to check whether this error handling regime is actually faster).
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Tue, 20 Sep 2016 16:35:47 +0100 |
parents | 7aec704705c7 |
children |
comparison
equal
deleted
inserted
replaced
59:77833938f0f8 | 60:8a4bcb3dc3a6 |
---|---|
52 PreservingPluginHandleMapper() : | 52 PreservingPluginHandleMapper() : |
53 m_handle(0), | 53 m_handle(0), |
54 m_plugin(0), | 54 m_plugin(0), |
55 m_omapper(std::make_shared<PreservingPluginOutputIdMapper>()) { } | 55 m_omapper(std::make_shared<PreservingPluginOutputIdMapper>()) { } |
56 | 56 |
57 virtual Handle pluginToHandle(Vamp::Plugin *p) const { | 57 virtual Handle pluginToHandle(Vamp::Plugin *p) const noexcept { |
58 if (!p) return INVALID_HANDLE; | |
58 if (p == m_plugin) return m_handle; | 59 if (p == m_plugin) return m_handle; |
59 else { | 60 else { |
60 std::cerr << "PreservingPluginHandleMapper: p = " << p | 61 std::cerr << "PreservingPluginHandleMapper: p = " << p |
61 << " differs from saved m_plugin " << m_plugin | 62 << " differs from saved m_plugin " << m_plugin |
62 << " (not returning saved handle " << m_handle << ")" | 63 << " (not returning saved handle " << m_handle << ")" |
63 << std::endl; | 64 << std::endl; |
64 throw NotFound(); | 65 return INVALID_HANDLE; |
65 } | 66 } |
66 } | 67 } |
67 | 68 |
68 virtual Vamp::Plugin *handleToPlugin(Handle h) const { | 69 virtual Vamp::Plugin *handleToPlugin(Handle h) const noexcept { |
70 if (h == INVALID_HANDLE) return nullptr; | |
69 m_handle = h; | 71 m_handle = h; |
70 m_plugin = reinterpret_cast<Vamp::Plugin *>(h); | 72 m_plugin = reinterpret_cast<Vamp::Plugin *>(h); |
71 return m_plugin; | 73 return m_plugin; |
72 } | 74 } |
73 | 75 |
74 virtual const std::shared_ptr<PluginOutputIdMapper> pluginToOutputIdMapper | 76 virtual const std::shared_ptr<PluginOutputIdMapper> pluginToOutputIdMapper |
75 (Vamp::Plugin *) const { | 77 (Vamp::Plugin *p) const noexcept { |
78 if (!p) return {}; | |
76 return m_omapper; | 79 return m_omapper; |
77 } | 80 } |
78 | 81 |
79 virtual const std::shared_ptr<PluginOutputIdMapper> handleToOutputIdMapper | 82 virtual const std::shared_ptr<PluginOutputIdMapper> handleToOutputIdMapper |
80 (Handle h) const { | 83 (Handle h) const noexcept { |
84 if (h == INVALID_HANDLE) return {}; | |
81 return m_omapper; | 85 return m_omapper; |
82 } | 86 } |
83 | 87 |
84 private: | 88 private: |
85 mutable Handle m_handle; | 89 mutable Handle m_handle; |