Correctly implement LV2 event URI mapping (event URI context is restricted to uint16_t).
[ardour.git] / libs / ardour / lv2ext / lv2_uri_unmap.h
1 /* lv2_uri_unmap.h - C header file for the LV2 URI Unmap extension.
2  *
3  * Copyright (C) 2010 David Robillard <http://drobilla.net>
4  *
5  * This header is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published
7  * by the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This header is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
13  * License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this header; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place, Suite 330, Boston, MA 01222-1307 USA
18  */
19
20 /** @file
21  * C header for the LV2 URI Map extension <http://lv2plug.in/ns/ext/uri-unmap>.
22  */
23
24 #ifndef LV2_URI_UNMAP_H
25 #define LV2_URI_UNMAP_H
26
27 #define LV2_URI_UNMAP_URI "http://lv2plug.in/ns/ext/uri-unmap"
28
29 #include <stdint.h>
30
31
32 /** Opaque pointer to host data. */
33 typedef void* LV2_URI_Unmap_Callback_Data;
34
35
36 /** The data field of the LV2_Feature for the URI Unmap extension.
37  *
38  * To support this extension the host must pass an LV2_Feature struct to the
39  * plugin's instantiate method with URI "http://lv2plug.in/ns/ext/uri-unmap"
40  * and data pointed to an instance of this struct.
41  */
42 typedef struct {
43
44         /** Opaque pointer to host data.
45          *
46          * The plugin MUST pass this to any call to functions in this struct.
47          * Otherwise, it must not be interpreted in any way.
48          */
49         LV2_URI_Unmap_Callback_Data callback_data;
50
51         /** Get the numeric ID of a URI from the host.
52          *
53          * @param callback_data Must be the callback_data member of this struct.
54          * @param map The 'context' used to map this URI.
55          * @param id The URI ID to unmap.
56          * @return The string form of @a id, or NULL on error.
57          *
58          * The @a id MUST be a value previously returned from
59          * LV2_Uri_Map_Feature.uri_to_id.
60          *
61          * The returned string is owned by the host and MUST NOT be freed by
62          * the plugin or stored for a long period of time (e.g. across run
63          * invocations) without copying.
64          *
65          * This function is referentially transparent - any number of calls with
66          * the same arguments is guaranteed to return the same value over the life
67          * of a plugin instance (though the same ID may return different values
68          * with a different map parameter).
69          *
70          * This function may be called from any non-realtime thread, possibly
71          * concurrently (hosts may simply use a mutex to meet these requirements).
72          */
73         const char* (*id_to_uri)(LV2_URI_Unmap_Callback_Data callback_data,
74                                  const char*                 map,
75                                  uint32_t                    id);
76
77 } LV2_URI_Unmap_Feature;
78
79
80 #endif /* LV2_URI_UNMAP_H */
81