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