Mercurial > hg > piper-vamp-js
comparison VamPipePluginLibrary.h @ 0:c226df029ac8
Start on plugin-library-to-json-request-response-handler adapter
author | Chris Cannam |
---|---|
date | Mon, 22 Aug 2016 17:17:28 +0100 |
parents | |
children | 7cfe736fd974 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c226df029ac8 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 VamPipe | |
5 | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 Copyright 2015-2016 QMUL. | |
8 | |
9 Permission is hereby granted, free of charge, to any person | |
10 obtaining a copy of this software and associated documentation | |
11 files (the "Software"), to deal in the Software without | |
12 restriction, including without limitation the rights to use, copy, | |
13 modify, merge, publish, distribute, sublicense, and/or sell copies | |
14 of the Software, and to permit persons to whom the Software is | |
15 furnished to do so, subject to the following conditions: | |
16 | |
17 The above copyright notice and this permission notice shall be | |
18 included in all copies or substantial portions of the Software. | |
19 | |
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
23 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR | |
24 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
25 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
27 | |
28 Except as contained in this notice, the names of the Centre for | |
29 Digital Music; Queen Mary, University of London; and Chris Cannam | |
30 shall not be used in advertising or otherwise to promote the sale, | |
31 use or other dealings in this Software without prior written | |
32 authorization. | |
33 */ | |
34 | |
35 #ifndef VAMPIPE_PLUGIN_LIBRARY_H | |
36 #define VAMPIPE_PLUGIN_LIBRARY_H | |
37 | |
38 #include "bits/CountingPluginHandleMapper.h" | |
39 #include "bits/RequestOrResponse.h" | |
40 | |
41 #include <vamp-hostsdk/PluginStaticData.h> | |
42 #include <vamp-hostsdk/RequestResponse.h> | |
43 | |
44 #include <vector> | |
45 #include <string> | |
46 #include <cstring> | |
47 | |
48 namespace vampipe { | |
49 | |
50 class VamPipeAdapterBase; | |
51 | |
52 class VamPipePluginLibrary | |
53 { | |
54 public: | |
55 VamPipePluginLibrary(std::vector<VamPipeAdapterBase *> pp); | |
56 | |
57 const char *requestJson(const char *request) { | |
58 return strdup(requestJsonImpl(request).c_str()); | |
59 } | |
60 | |
61 void freeJson(const char *json) { | |
62 free(const_cast<char *>(json)); | |
63 } | |
64 | |
65 private: | |
66 std::string requestJsonImpl(std::string req); | |
67 | |
68 RequestOrResponse readRequest(std::string req) const; | |
69 std::string writeResponse(const RequestOrResponse &resp) const; | |
70 | |
71 //!!! pull out these next few into another class, a sort of mini | |
72 //!!! library-level analogue to PluginLoader ? | |
73 | |
74 //!!! no type for this in RequestResponse.h in vamp sdk, should there be? | |
75 std::vector<Vamp::HostExt::PluginStaticData> listPluginData() const; | |
76 Vamp::HostExt::LoadResponse loadPlugin(Vamp::HostExt::LoadRequest r) const; | |
77 Vamp::HostExt::ConfigurationResponse configurePlugin(Vamp::HostExt:: | |
78 ConfigurationRequest r) const; | |
79 | |
80 std::map<std::string, VamPipeAdapterBase *> m_adapters; // pluginKey -> adapter | |
81 CountingPluginHandleMapper m_mapper; | |
82 }; | |
83 | |
84 } | |
85 | |
86 #endif |