Mercurial > hg > piper-cpp
comparison bits/PreservingPluginHandleMapper.h @ 40:55d69b26d4db
Pull out CountingPluginHandleMapper; consts
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Mon, 22 Aug 2016 17:16:44 +0100 |
parents | 2d97883d20df |
children | f4244a2d55ac |
comparison
equal
deleted
inserted
replaced
39:183be3bc9d7b | 40:55d69b26d4db |
---|---|
44 class PreservingPluginHandleMapper : public PluginHandleMapper | 44 class PreservingPluginHandleMapper : public PluginHandleMapper |
45 { | 45 { |
46 public: | 46 public: |
47 PreservingPluginHandleMapper() : m_handle(0), m_plugin(0) { } | 47 PreservingPluginHandleMapper() : m_handle(0), m_plugin(0) { } |
48 | 48 |
49 virtual int32_t pluginToHandle(Vamp::Plugin *p) { | 49 virtual int32_t pluginToHandle(Vamp::Plugin *p) const { |
50 if (p == m_plugin) return m_handle; | 50 if (p == m_plugin) return m_handle; |
51 else { | 51 else { |
52 std::cerr << "PreservingPluginHandleMapper: p = " << p | 52 std::cerr << "PreservingPluginHandleMapper: p = " << p |
53 << " differs from saved m_plugin " << m_plugin | 53 << " differs from saved m_plugin " << m_plugin |
54 << " (not returning saved handle " << m_handle << ")" | 54 << " (not returning saved handle " << m_handle << ")" |
55 << std::endl; | 55 << std::endl; |
56 throw NotFound(); | 56 throw NotFound(); |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 virtual Vamp::Plugin *handleToPlugin(int32_t h) { | 60 virtual Vamp::Plugin *handleToPlugin(int32_t h) const { |
61 m_handle = h; | 61 m_handle = h; |
62 m_plugin = reinterpret_cast<Vamp::Plugin *>(h); | 62 m_plugin = reinterpret_cast<Vamp::Plugin *>(h); |
63 return m_plugin; | 63 return m_plugin; |
64 } | 64 } |
65 | 65 |
66 private: | 66 private: |
67 int32_t m_handle; | 67 mutable int32_t m_handle; |
68 Vamp::Plugin *m_plugin; | 68 mutable Vamp::Plugin *m_plugin; |
69 }; | 69 }; |
70 | 70 |
71 } | 71 } |
72 | 72 |
73 #endif | 73 #endif |