naspro

view naspro-bridges-bad/ladspa/dyn-manifest.h @ 174:4f7243a606b1

Updated copyright notices and build system
author Stefano D'Angelo <zanga.mail@gmail.com>
date Sat May 01 21:51:33 2010 +0300 (2010-05-01)
parents
children
line source
1 /* Dynamic manifest specification for LV2
2 * Revision 2
3 *
4 * Copyright (C) 2008-2010 Stefano D'Angelo <zanga.mail@gmail.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
30 #ifndef LV2_DYN_MANIFEST_H_INCLUDED
31 #define LV2_DYN_MANIFEST_H_INCLUDED
33 #include <stdio.h>
34 #include <lv2.h>
36 #define LV2_DYN_MANIFEST_URI "http://lv2plug.in/ns/ext/dyn-manifest"
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
43 /* ************************************************************************* */
46 /** @file
47 *
48 * Revision: 2
49 *
50 * == Overview ==
51 *
52 * The LV2 API, on its own, cannot be used to write plugin libraries where
53 * data is dynamically generated at runtime (e.g. API wrappers), since LV2
54 * requires needed information to be provided in one or more static data (RDF)
55 * files. This API addresses this limitation by extending the LV2 API.
56 *
57 * A host implementing support for this API should first detect that the plugin
58 * library implements a dynamic manifest generator by examining its static
59 * manifest file, then fetch data from the shared object file by accessing it as
60 * usual (dlopen() and family) and using this API.
61 *
62 * The host is allowed to request regeneration of the dynamic manifest multiple
63 * times, and the plugin library is expected to provide updated data if/when
64 * possible. All data and references provided via this API before the last
65 * regeneration of the dynamic manifest is to be considered invalid by the
66 * host, including plugin descriptors whose URIs were discovered using this API.
67 *
68 * This API is extensible in a similar fashion as the LV2 plugin API.
69 *
70 * == Accessing data ==
71 *
72 * Whenever a host wants to access data using this API, it could:
73 *
74 * -# Call lv2_dyn_manifest_open();
75 * -# Create an empty resource identified by a FILE *;
76 * -# Get a "list" of exposed subject URIs using
77 * lv2_dyn_manifest_get_subjects();
78 * -# Call lv2_dyn_manifest_get_data() for each URI of interest, in order to
79 * get data related to that URI (either by calling the function subsequently
80 * with the same FILE * resource, or by creating more FILE * resources to
81 * perform parallel calls);
82 * -# Call lv2_dyn_manifest_close();
83 * -# Parse the content of the FILE * resource(s).
84 * -# Free/delete/unlink the FILE * resource(s).
85 *
86 * The content of the FILE * resources has to be interpreted by the host as a
87 * regular file in Turtle syntax. This also means that each FILE * resource
88 * should also contain needed prefix definitions, in case any are used.
89 *
90 * Each call to lv2_dyn_manifest_open() automatically implies the (re)generation
91 * of the dynamic manifest on the library side.
92 *
93 * When such calls are made, data fetched from the involved library using this
94 * API before such call is to be considered no more valid.
95 *
96 * In case the library uses this same API to access other dynamic manifests, it
97 * MUST implement some mechanism to avoid potentially endless loops (such as A
98 * loads B, B loads A, etc.) in functions from the Dynamic manifest open class
99 * (the open-like operation MUST fail). For this purpose, use of a static
100 * boolean flag is suggested.
101 *
102 * == Threading rules ==
103 *
104 * This specification defines threading rule classes, similarly to the LV2
105 * specification.
106 *
107 * The functions defined by this API belong to:
108 *
109 * - Dynamic manifest open class: lv2_dyn_manifest_open()
110 * - Dynamic manifest close class: lv2_dyn_manifest_close()
111 * - Dynamic manifest file class: lv2_dyn_manifest_get_subjects(),
112 * lv2_dyn_manifest_get_data()
113 *
114 * The rules that hosts must follow are these:
115 *
116 * - When a function from the Dynamic manifest open or the Dynamic manifest
117 * close class is running, no other functions in the same shared object file
118 * may run.
119 * - When a function from the Dynamic manifest file class is called, no other
120 * functions from the same class may run if they are given at least one
121 * FILE * argument with the same value.
122 * - A function from the Dynamic manifest open class may not run after a
123 * successful call to a function from the same class, in case a function from
124 * the Dynamic manifest close class was not successfully called in the
125 * meanwhile.
126 * - A function from the Dynamic manifest close class may only run after a
127 * successful call to a function from the Dynamic manifest open class.
128 * - A function from the Dynamic manifest file class may only run beetween a
129 * successful call to a function from the Dynamic manifest open class and the
130 * following successful call to a function from the Dynamic manifest close
131 * class.
132 *
133 * Extensions to this specification which add new functions MUST declare in
134 * which of these classes the functions belong, or define new classes for them;
135 * furthermore, classes defined by such extensions MUST only allow calls after
136 * a successful call to a function from the Dynamic manifest open class and
137 * before the following successful call to a function from the Dynamic manifest
138 * close class.
139 *
140 * Any simultaneous calls that are not explicitly forbidden by these rules are
141 * allowed.
142 */
145 /* ************************************************************************* */
148 /** Dynamic manifest generator handle.
149 *
150 * This handle indicates a particular status of a dynamic manifest generator.
151 * The host MUST NOT attempt to interpret it and, unlikely LV2_Handle, it is NOT
152 * even valid to compare this to NULL. The dynamic manifest generator may use it
153 * to reference internal data. */
154 typedef void * LV2_Dyn_Manifest_Handle;
157 /* ************************************************************************* */
160 /** Function that (re)generates the dynamic manifest.
161 *
162 * handle is a pointer to an uninitialized dynamic manifest generator handle.
163 *
164 * features is a NULL terminated array of LV2_Feature structs which
165 * represent the features the host supports. The dynamic manifest geenrator may
166 * refuse to (re)generate the dynamic manifest if required features are not
167 * found here (however hosts SHOULD NOT use this as a discovery mechanism,
168 * instead of reading the static manifest file). This array must always exist;
169 * if a host has no features, it MUST pass a single element array containing
170 * NULL.
171 *
172 * This function MUST return 0 on success, otherwise a non-zero error code, and
173 * the host SHOULD evaluate the result of the operation by examining the
174 * returned value, rather than try to interpret the value of handle.
175 */
176 int lv2_dyn_manifest_open(LV2_Dyn_Manifest_Handle * handle,
177 const LV2_Feature *const * features);
179 /** Function that fetches a "list" of subject URIs exposed by the dynamic
180 * manifest generator.
181 *
182 * handle is the dynamic manifest generator handle.
183 *
184 * fp is the FILE * identifying the resource the host has to set up for the
185 * dynamic manifest generator. The host MUST pass a writable, empty resource to
186 * this function, and the dynamic manifest generator MUST ONLY perform write
187 * operations on it at the end of the stream (e.g. use only fprintf(), fwrite()
188 * and similar).
189 *
190 * The dynamic manifest generator has to fill the resource only with the needed
191 * triples to make the host aware of the "objects" it wants to expose. For
192 * example, if the library exposes a regular LV2 plugin, it should output only a
193 * triple like the following:
194 *
195 * <http://www.example.com/plugin/uri> a lv2:Plugin;
196 *
197 * This function MUST return 0 on success, otherwise a non-zero error code.
198 */
199 int lv2_dyn_manifest_get_subjects(LV2_Dyn_Manifest_Handle handle,
200 FILE * fp);
202 /** Function that fetches data related to a specific URI.
203 *
204 * handle is the dynamic manifest generator handle.
205 *
206 * fp is the FILE * identifying the resource the host has to set up for the
207 * dynamic manifest generator. The host MUST pass a writable resource to this
208 * function, and the dynamic manifest generator MUST ONLY perform write
209 * operations on it at the current position of the stream (e.g. use only
210 * fprintf(), fwrite() and similar).
211 *
212 * uri is the URI to get data about (in the "plain" form, a.k.a. without RDF
213 * prefixes).
214 *
215 * The dynamic manifest generator has to fill the resource with data related to
216 * the URI. For example, if the library exposes a regular LV2 plugin whose URI,
217 * as retrieved by the host using lv2_dyn_manifest_get_subjects() is
218 * http://www.example.com/plugin/uri, it should output something like:
219 *
220 * <http://www.example.com/plugin/uri> a lv2:Plugin;
221 * lv2:binary <mylib.so>;
222 * doap:name "My Plugin";
223 * ... etc...
224 *
225 * This function MUST return 0 on success, otherwise a non-zero error code.
226 */
227 int lv2_dyn_manifest_get_data(LV2_Dyn_Manifest_Handle handle,
228 FILE * fp,
229 const char * uri);
231 /** Function that ends the operations on the dynamic manifest generator.
232 *
233 * handle is the dynamic manifest generator handle.
234 *
235 * This function should be used by the dynamic manifest generator to perform
236 * cleanup operations, etc.
237 */
238 void lv2_dyn_manifest_close(LV2_Dyn_Manifest_Handle handle);
240 #ifdef __cplusplus
241 }
242 #endif
244 #endif /* LV2_DYN_MANIFEST_H_INCLUDED */