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@31
|
40 namespace vampipe {
|
c@31
|
41
|
c@31
|
42 class PreservingPluginHandleMapper : public PluginHandleMapper
|
c@31
|
43 {
|
c@31
|
44 public:
|
c@31
|
45 PreservingPluginHandleMapper() : m_handle(0), m_plugin(0) { }
|
c@31
|
46
|
c@31
|
47 virtual int32_t pluginToHandle(Vamp::Plugin *p) {
|
c@31
|
48 if (p == m_plugin) return m_handle;
|
c@31
|
49 else throw NotFound();
|
c@31
|
50 }
|
c@31
|
51
|
c@31
|
52 virtual Vamp::Plugin *handleToPlugin(int32_t h) {
|
c@31
|
53 m_handle = h;
|
c@31
|
54 m_plugin = reinterpret_cast<Vamp::Plugin *>(h);
|
c@31
|
55 return m_plugin;
|
c@31
|
56 }
|
c@31
|
57
|
c@31
|
58 private:
|
c@31
|
59 int32_t m_handle;
|
c@31
|
60 Vamp::Plugin *m_plugin;
|
c@31
|
61 };
|
c@31
|
62
|
c@31
|
63 }
|
c@31
|
64
|
c@31
|
65 #endif
|