comparison bits/PreservingPluginHandleMapper.h @ 58:c38e12d4bbdd

Merge from branch outputid-string-in-featureset
author Chris Cannam <c.cannam@qmul.ac.uk>
date Mon, 19 Sep 2016 14:48:43 +0100
parents 7aec704705c7
children 8a4bcb3dc3a6
comparison
equal deleted inserted replaced
48:ce6cb3308bd7 58:c38e12d4bbdd
34 34
35 #ifndef VAMPIPE_PRESERVING_PLUGIN_HANDLE_MAPPER_H 35 #ifndef VAMPIPE_PRESERVING_PLUGIN_HANDLE_MAPPER_H
36 #define VAMPIPE_PRESERVING_PLUGIN_HANDLE_MAPPER_H 36 #define VAMPIPE_PRESERVING_PLUGIN_HANDLE_MAPPER_H
37 37
38 #include "PluginHandleMapper.h" 38 #include "PluginHandleMapper.h"
39 #include "PreservingPluginOutputIdMapper.h"
39 40
40 #include <iostream> 41 #include <iostream>
41 42
42 namespace vampipe { 43 namespace vampipe {
43 44
45 //!!! document -- this is a passthrough thing for a single plugin
46 //!!! handle only, it does not use actually valid Plugin pointers at
47 //!!! all
48
44 class PreservingPluginHandleMapper : public PluginHandleMapper 49 class PreservingPluginHandleMapper : public PluginHandleMapper
45 { 50 {
46 public: 51 public:
47 PreservingPluginHandleMapper() : m_handle(0), m_plugin(0) { } 52 PreservingPluginHandleMapper() :
53 m_handle(0),
54 m_plugin(0),
55 m_omapper(std::make_shared<PreservingPluginOutputIdMapper>()) { }
48 56
49 virtual int32_t pluginToHandle(Vamp::Plugin *p) const { 57 virtual Handle pluginToHandle(Vamp::Plugin *p) const {
50 if (p == m_plugin) return m_handle; 58 if (p == m_plugin) return m_handle;
51 else { 59 else {
52 std::cerr << "PreservingPluginHandleMapper: p = " << p 60 std::cerr << "PreservingPluginHandleMapper: p = " << p
53 << " differs from saved m_plugin " << m_plugin 61 << " differs from saved m_plugin " << m_plugin
54 << " (not returning saved handle " << m_handle << ")" 62 << " (not returning saved handle " << m_handle << ")"
55 << std::endl; 63 << std::endl;
56 throw NotFound(); 64 throw NotFound();
57 } 65 }
58 } 66 }
59 67
60 virtual Vamp::Plugin *handleToPlugin(int32_t h) const { 68 virtual Vamp::Plugin *handleToPlugin(Handle h) const {
61 m_handle = h; 69 m_handle = h;
62 m_plugin = reinterpret_cast<Vamp::Plugin *>(h); 70 m_plugin = reinterpret_cast<Vamp::Plugin *>(h);
63 return m_plugin; 71 return m_plugin;
64 } 72 }
65 73
74 virtual const std::shared_ptr<PluginOutputIdMapper> pluginToOutputIdMapper
75 (Vamp::Plugin *) const {
76 return m_omapper;
77 }
78
79 virtual const std::shared_ptr<PluginOutputIdMapper> handleToOutputIdMapper
80 (Handle h) const {
81 return m_omapper;
82 }
83
66 private: 84 private:
67 mutable int32_t m_handle; 85 mutable Handle m_handle;
68 mutable Vamp::Plugin *m_plugin; 86 mutable Vamp::Plugin *m_plugin;
87 std::shared_ptr<PreservingPluginOutputIdMapper> m_omapper;
69 }; 88 };
70 89
71 } 90 }
72 91
73 #endif 92 #endif