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@51
|
39 #include "PreservingPluginOutputIdMapper.h"
|
c@31
|
40
|
c@32
|
41 #include <iostream>
|
c@32
|
42
|
c@31
|
43 namespace vampipe {
|
c@31
|
44
|
c@51
|
45 //!!! document -- this is a passthrough thing for a single plugin
|
c@51
|
46 //!!! handle only, it does not use actually valid Plugin pointers at
|
c@51
|
47 //!!! all
|
c@51
|
48
|
c@31
|
49 class PreservingPluginHandleMapper : public PluginHandleMapper
|
c@31
|
50 {
|
c@31
|
51 public:
|
c@31
|
52 PreservingPluginHandleMapper() : m_handle(0), m_plugin(0) { }
|
c@31
|
53
|
c@52
|
54 virtual Handle pluginToHandle(Vamp::Plugin *p) const {
|
c@31
|
55 if (p == m_plugin) return m_handle;
|
c@32
|
56 else {
|
c@32
|
57 std::cerr << "PreservingPluginHandleMapper: p = " << p
|
c@32
|
58 << " differs from saved m_plugin " << m_plugin
|
c@32
|
59 << " (not returning saved handle " << m_handle << ")"
|
c@32
|
60 << std::endl;
|
c@32
|
61 throw NotFound();
|
c@32
|
62 }
|
c@31
|
63 }
|
c@31
|
64
|
c@52
|
65 virtual Vamp::Plugin *handleToPlugin(Handle h) const {
|
c@31
|
66 m_handle = h;
|
c@31
|
67 m_plugin = reinterpret_cast<Vamp::Plugin *>(h);
|
c@31
|
68 return m_plugin;
|
c@31
|
69 }
|
c@31
|
70
|
c@51
|
71 virtual const PluginOutputIdMapper &pluginToOutputIdMapper(Vamp::Plugin *) const {
|
c@51
|
72 return m_omapper;
|
c@51
|
73 }
|
c@51
|
74
|
c@52
|
75 virtual const PluginOutputIdMapper &handleToOutputIdMapper(Handle h) const {
|
c@51
|
76 return m_omapper;
|
c@51
|
77 }
|
c@51
|
78
|
c@31
|
79 private:
|
c@52
|
80 mutable Handle m_handle;
|
c@40
|
81 mutable Vamp::Plugin *m_plugin;
|
c@51
|
82 PreservingPluginOutputIdMapper m_omapper;
|
c@31
|
83 };
|
c@31
|
84
|
c@31
|
85 }
|
c@31
|
86
|
c@31
|
87 #endif
|