comparison bits/CountingPluginHandleMapper.h @ 52:e90fd30990eb

Error handling, and pass plugin handles through
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 16 Sep 2016 16:20:05 +0100
parents f4244a2d55ac
children 7aec704705c7
comparison
equal deleted inserted replaced
51:f4244a2d55ac 52:e90fd30990eb
65 } 65 }
66 } 66 }
67 67
68 void removePlugin(Handle h) { 68 void removePlugin(Handle h) {
69 if (m_plugins.find(h) == m_plugins.end()) { 69 if (m_plugins.find(h) == m_plugins.end()) {
70 std::cerr << "remove: no handle " << h << std::endl;
70 throw NotFound(); 71 throw NotFound();
71 } 72 }
72 Vamp::Plugin *p = m_plugins[h]; 73 Vamp::Plugin *p = m_plugins[h];
73 delete m_outputMappers.at(h); 74 delete m_outputMappers.at(h);
74 m_outputMappers.erase(h); 75 m_outputMappers.erase(h);
80 m_rplugins.erase(p); 81 m_rplugins.erase(p);
81 } 82 }
82 83
83 Handle pluginToHandle(Vamp::Plugin *p) const { 84 Handle pluginToHandle(Vamp::Plugin *p) const {
84 if (m_rplugins.find(p) == m_rplugins.end()) { 85 if (m_rplugins.find(p) == m_rplugins.end()) {
86 std::cerr << "pluginToHandle: no plugin " << p << std::endl;
85 throw NotFound(); 87 throw NotFound();
86 } 88 }
87 return m_rplugins.at(p); 89 return m_rplugins.at(p);
88 } 90 }
89 91
90 Vamp::Plugin *handleToPlugin(Handle h) const { 92 Vamp::Plugin *handleToPlugin(Handle h) const {
91 if (m_plugins.find(h) == m_plugins.end()) { 93 if (m_plugins.find(h) == m_plugins.end()) {
94 std::cerr << "handleToPlugin: no handle " << h << std::endl;
92 throw NotFound(); 95 throw NotFound();
93 } 96 }
94 return m_plugins.at(h); 97 return m_plugins.at(h);
95 } 98 }
96 99
97 //!!! iffy: mapper will move when another plugin is added. return by value? 100 //!!! iffy: mapper will move when another plugin is added. return by value?
98 const PluginOutputIdMapper &pluginToOutputIdMapper(Vamp::Plugin *p) const { 101 const PluginOutputIdMapper &pluginToOutputIdMapper(Vamp::Plugin *p) const {
99 // pluginToHandle checks the plugin has been registered with us 102 // pluginToHandle checks the plugin has been registered with us
103 std::cerr << "output id mapper requested for plugin with handle " << pluginToHandle(p) << std::endl;
100 return *m_outputMappers.at(pluginToHandle(p)); 104 return *m_outputMappers.at(pluginToHandle(p));
101 } 105 }
102 106
103 //!!! iffy: mapper will move when another plugin is added. return by value? 107 //!!! iffy: mapper will move when another plugin is added. return by value?
104 const PluginOutputIdMapper &handleToOutputIdMapper(Handle h) const { 108 const PluginOutputIdMapper &handleToOutputIdMapper(Handle h) const {
109 std::cerr << "output id mapper requested for handle " << h << std::endl;
105 if (m_plugins.find(h) == m_plugins.end()) { 110 if (m_plugins.find(h) == m_plugins.end()) {
106 throw NotFound(); 111 throw NotFound();
107 } 112 }
108 return *m_outputMappers.at(h); 113 return *m_outputMappers.at(h);
109 } 114 }