c@31
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
c@31
|
2
|
c@31
|
3 /*
|
c@31
|
4 Vampipe
|
c@31
|
5
|
c@31
|
6 Centre for Digital Music, Queen Mary, University of London.
|
c@31
|
7 Copyright 2006-2016 Chris Cannam and QMUL.
|
c@31
|
8
|
c@31
|
9 Permission is hereby granted, free of charge, to any person
|
c@31
|
10 obtaining a copy of this software and associated documentation
|
c@31
|
11 files (the "Software"), to deal in the Software without
|
c@31
|
12 restriction, including without limitation the rights to use, copy,
|
c@31
|
13 modify, merge, publish, distribute, sublicense, and/or sell copies
|
c@31
|
14 of the Software, and to permit persons to whom the Software is
|
c@31
|
15 furnished to do so, subject to the following conditions:
|
c@31
|
16
|
c@31
|
17 The above copyright notice and this permission notice shall be
|
c@31
|
18 included in all copies or substantial portions of the Software.
|
c@31
|
19
|
c@31
|
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
c@31
|
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
c@31
|
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
c@31
|
23 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
|
c@31
|
24 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
c@31
|
25 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
c@31
|
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
c@31
|
27
|
c@31
|
28 Except as contained in this notice, the names of the Centre for
|
c@31
|
29 Digital Music; Queen Mary, University of London; and Chris Cannam
|
c@31
|
30 shall not be used in advertising or otherwise to promote the sale,
|
c@31
|
31 use or other dealings in this Software without prior written
|
c@31
|
32 authorization.
|
c@31
|
33 */
|
c@31
|
34
|
c@31
|
35 #ifndef VAMPIPE_PRESERVING_PLUGIN_HANDLE_MAPPER_H
|
c@31
|
36 #define VAMPIPE_PRESERVING_PLUGIN_HANDLE_MAPPER_H
|
c@31
|
37
|
c@31
|
38 #include "PluginHandleMapper.h"
|
c@31
|
39
|
c@32
|
40 #include <iostream>
|
c@32
|
41
|
c@31
|
42 namespace vampipe {
|
c@31
|
43
|
c@31
|
44 class PreservingPluginHandleMapper : public PluginHandleMapper
|
c@31
|
45 {
|
c@31
|
46 public:
|
c@31
|
47 PreservingPluginHandleMapper() : m_handle(0), m_plugin(0) { }
|
c@31
|
48
|
c@31
|
49 virtual int32_t pluginToHandle(Vamp::Plugin *p) {
|
c@31
|
50 if (p == m_plugin) return m_handle;
|
c@32
|
51 else {
|
c@32
|
52 std::cerr << "PreservingPluginHandleMapper: p = " << p
|
c@32
|
53 << " differs from saved m_plugin " << m_plugin
|
c@32
|
54 << " (not returning saved handle " << m_handle << ")"
|
c@32
|
55 << std::endl;
|
c@32
|
56 throw NotFound();
|
c@32
|
57 }
|
c@31
|
58 }
|
c@31
|
59
|
c@31
|
60 virtual Vamp::Plugin *handleToPlugin(int32_t h) {
|
c@31
|
61 m_handle = h;
|
c@31
|
62 m_plugin = reinterpret_cast<Vamp::Plugin *>(h);
|
c@31
|
63 return m_plugin;
|
c@31
|
64 }
|
c@31
|
65
|
c@31
|
66 private:
|
c@31
|
67 int32_t m_handle;
|
c@31
|
68 Vamp::Plugin *m_plugin;
|
c@31
|
69 };
|
c@31
|
70
|
c@31
|
71 }
|
c@31
|
72
|
c@31
|
73 #endif
|