/usr/include/lvtk-1/lvtk/ext/urid.hpp is in lvtk-dev 1.2.0~dfsg0-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | /*
urid.hpp - support file for writing LV2 plugins in C++
Copyright (C) 2012 Michael Fisher <mfisher31@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 01222-1307 USA
*/
#ifndef LVTK_URID_HPP
#define LVTK_URID_HPP
#include <lv2/lv2plug.in/ns/ext/urid/urid.h>
namespace lvtk
{
/** Function type for mapping symbols */
typedef uint32_t (*MapFunc)(const char* symbol);
/** Function type for unmaping URIDs */
typedef const char* (*UnmapFunc)(uint32_t id);
/** The URID Mixin.
@headerfile lvtk/ext/urid.hpp
@ingroup pluginmixins
@ingroup guimixins
@see The internal struct I for details.
*/
template<bool Required = true>
struct URID
{
template<class Derived>
struct I : Extension<Required>
{
I() : p_map(0), p_unmap(0) { }
/** @internal */
static void
map_feature_handlers (FeatureHandlerMap& hmap)
{
hmap[LV2_URID__map] = &I<Derived>::handle_map_feature;
hmap[LV2_URID__unmap] = &I<Derived>::handle_unmap_feature;
}
/** @internal */
static void
handle_map_feature (void* instance, void* data)
{
Derived* d = reinterpret_cast<Derived*>(instance);
I<Derived>* mixin = static_cast<I<Derived>*>(d);
mixin->p_map = reinterpret_cast<LV2_URID_Map*>(data);
mixin->m_ok = true;
}
/** @internal */
static void
handle_unmap_feature (void* instance, void* data)
{
Derived* d = reinterpret_cast<Derived*> (instance);
I<Derived>* mixin = static_cast<I<Derived>*>(d);
mixin->p_unmap = reinterpret_cast<LV2_URID_Unmap*>(data);
mixin->m_ok = true;
}
bool
check_ok()
{
if (LVTK_DEBUG)
{
std::clog << " [URID] Validation "
<< (this->m_ok ? "succeeded" : "failed")
<< "." << std::endl;
}
return this->m_ok;
}
/** Get the URI for a previously mapped numeric ID.
Returns NULL if @p urid is not yet mapped. Otherwise, the corresponding
URI is returned in a canonical form. This MAY not be the exact same
string that was originally passed to LV2_URID_Map::map(), but it MUST be
an identical URI according to the URI syntax specification (RFC3986). A
non-NULL return for a given @p urid will always be the same for the life
of the plugin. Plugins that intend to perform string comparison on
unmapped URIs SHOULD first canonicalise URI strings with a call to
map_uri() followed by a call to unmap_uri().
@param urid The ID to be mapped back to the URI string.
*/
const char*
unmap (LV2_URID urid)
{
if (p_unmap != NULL)
return p_unmap->unmap(p_unmap->handle, urid);
return "";
}
/** Get the numeric ID of a URI.
If the ID does not already exist, it will be created.
This function is referentially transparent; any number of calls with the
same arguments is guaranteed to return the same value over the life of a
plugin instance. Note, however, that several URIs MAY resolve to the
same ID if the host considers those URIs equivalent.
This function is not necessarily very fast or RT-safe: plugins SHOULD
cache any IDs they might need in performance critical situations.
The return value 0 is reserved and indicates that an ID for that URI
could not be created for whatever reason. However, hosts SHOULD NOT
return 0 from this function in non-exceptional circumstances (i.e. the
URI map SHOULD be dynamic).
@param uri The URI to be mapped to an integer ID.
*/
LV2_URID
map (const char* uri)
{
if (p_map != NULL)
return p_map->map(p_map->handle, uri);
return 0;
}
/** Get the underlying LV2_URID_Map pointer */
LV2_URID_Map* get_urid_map() const { return p_map; }
/** Get the underlying LV2_URID_Unmap pointer */
LV2_URID_Unmap* get_urid_unmap() const { return p_unmap; }
protected:
LV2_URID_Map *p_map;
LV2_URID_Unmap *p_unmap;
};
};
}
#endif /* LVTK_URID_HPP */
|