annotate bits/PluginHandleMapper.h @ 60:8a4bcb3dc3a6

Replace exceptions throughout the JSON-handling and adapter code with string-arg error handling. No longer need exception handling enabled in Emscripten (with its consequent runtime overhead - though we still need to check whether this error handling regime is actually faster).
author Chris Cannam <c.cannam@qmul.ac.uk>
date Tue, 20 Sep 2016 16:35:47 +0100
parents 7aec704705c7
children
rev   line source
c@10 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
c@10 2
c@10 3 /*
c@10 4 Vampipe
c@10 5
c@10 6 Centre for Digital Music, Queen Mary, University of London.
c@10 7 Copyright 2006-2016 Chris Cannam and QMUL.
c@10 8
c@10 9 Permission is hereby granted, free of charge, to any person
c@10 10 obtaining a copy of this software and associated documentation
c@10 11 files (the "Software"), to deal in the Software without
c@10 12 restriction, including without limitation the rights to use, copy,
c@10 13 modify, merge, publish, distribute, sublicense, and/or sell copies
c@10 14 of the Software, and to permit persons to whom the Software is
c@10 15 furnished to do so, subject to the following conditions:
c@10 16
c@10 17 The above copyright notice and this permission notice shall be
c@10 18 included in all copies or substantial portions of the Software.
c@10 19
c@10 20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
c@10 21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
c@10 22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
c@10 23 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
c@10 24 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
c@10 25 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
c@10 26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
c@10 27
c@10 28 Except as contained in this notice, the names of the Centre for
c@10 29 Digital Music; Queen Mary, University of London; and Chris Cannam
c@10 30 shall not be used in advertising or otherwise to promote the sale,
c@10 31 use or other dealings in this Software without prior written
c@10 32 authorization.
c@10 33 */
c@10 34
c@10 35 #ifndef VAMPIPE_PLUGIN_HANDLE_MAPPER_H
c@10 36 #define VAMPIPE_PLUGIN_HANDLE_MAPPER_H
c@10 37
c@57 38 #include "PluginOutputIdMapper.h"
c@57 39
c@10 40 #include <vamp-hostsdk/Plugin.h>
c@57 41 #include <memory>
c@51 42
c@10 43 namespace vampipe {
c@19 44
c@60 45 /**
c@60 46 * Convert plugin pointers to handles within some scope defined by the
c@60 47 * individual PluginHandleMapper implementation.
c@60 48 *
c@60 49 * The special handle 0 and the NULL plugin pointer are both used to
c@60 50 * represent "not found" and will be returned in any case where an
c@60 51 * unknown handle or plugin is requested.
c@60 52 *
c@60 53 * Note that the handle type must be representable as a JSON number,
c@60 54 * hence the use of a 32-bit rather than 64-bit int.
c@60 55 *
c@60 56 * This interface also includes methods for obtaining a
c@60 57 * PluginOutputIdMapper, \see PluginOutputIdMapper.
c@60 58 */
c@60 59
c@10 60 class PluginHandleMapper
c@10 61 {
c@10 62 public:
c@51 63 typedef int32_t Handle;
c@60 64 const Handle INVALID_HANDLE = 0;
c@51 65
c@60 66 virtual ~PluginHandleMapper() noexcept { }
c@51 67
c@60 68 /**
c@60 69 * Look up and return the handle for a given plugin pointer.
c@60 70 * If the given pointer is null or not known, return INVALID_HANDLE.
c@60 71 */
c@60 72 virtual Handle pluginToHandle(Vamp::Plugin *) const noexcept = 0;
c@60 73
c@60 74 /**
c@60 75 * Look up and return the plugin for a given handle.
c@60 76 * If the given handle is INVALID_HANDLE or not known, return nullptr.
c@60 77 */
c@60 78 virtual Vamp::Plugin *handleToPlugin(Handle) const noexcept = 0;
c@60 79
c@60 80 /**
c@60 81 * Return a shared pointer to a PluginOutputIdMapper
c@60 82 * implementation for the given plugin pointer. If the given
c@60 83 * pointer is null or not known, return the null shared_ptr.
c@60 84 */
c@57 85 virtual const std::shared_ptr<PluginOutputIdMapper> pluginToOutputIdMapper
c@60 86 (Vamp::Plugin *p) const noexcept = 0;
c@57 87
c@60 88 /**
c@60 89 * Return a shared pointer to a PluginOutputIdMapper
c@60 90 * implementation for the given plugin handle. If the given
c@60 91 * handle is INVALID_HANDLE or not known, return the null shared_ptr.
c@60 92 */
c@57 93 virtual const std::shared_ptr<PluginOutputIdMapper> handleToOutputIdMapper
c@60 94 (Handle h) const noexcept = 0;
c@10 95 };
c@19 96
c@10 97 }
c@10 98
c@10 99 #endif
c@10 100