More helpful error message when both Redland and RDFLib aren't found.
[lv2.git] / ext / dyn-manifest.lv2 / dyn-manifest.h
blob00e46fd16e7bb53d8192c24e661ca32258400f05
1 /* Dynamic manifest specification for LV2
2 * Revision 1
4 * Copyright (C) 2008, 2009 Stefano D'Angelo <zanga.mail@gmail.com>
5 * All rights reserved.
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.
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.
30 #ifndef LV2_DYN_MANIFEST_H_INCLUDED
31 #define LV2_DYN_MANIFEST_H_INCLUDED
33 #include <stdio.h>
34 #include "lv2.h"
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
41 /* ************************************************************************* */
44 /** @file
45 * C header for the LV2 Dynamic Manifest extension
46 * <http://lv2plug.in/ns/ext/dyn-manifest>.
47 * Revision: 1
49 * == Overview ==
51 * The LV2 API, on its own, cannot be used to write plugin libraries where
52 * data is dynamically generated at runtime (e.g. API wrappers), since LV2
53 * requires needed information to be provided in one or more static data (RDF)
54 * files. This API addresses this limitation by extending the LV2 API.
56 * A host implementing support for this API should first detect that the plugin
57 * library implements a dynamic manifest generator by examining its static
58 * manifest file, then fetch data from the shared object file by accessing it as
59 * usual (dlopen() and family) and using this API.
61 * The host is allowed to request regeneration of the dynamic manifest multiple
62 * times, and the plugin library is expected to provide updated data if/when
63 * possible. All data and references provided via this API before the last
64 * regeneration of the dynamic manifest is to be considered invalid by the
65 * host, including plugin descriptors whose URIs were discovered using this API.
67 * This API is extensible in a similar fashion as the LV2 plugin API.
69 * == Threading rules ==
71 * This specification defines threading rule classes, similarly to the LV2
72 * specification.
74 * The functions defined by this API belong to:
76 * - Dynamic manifest open class: lv2_dyn_manifest_open()
77 * - Dynamic manifest close class: lv2_dyn_manifest_close()
78 * - Dynamic manifest file class: lv2_dyn_manifest_get_subjects(),
79 * lv2_dyn_manifest_get_data()
81 * The rules that hosts must follow are these:
83 * - When a function from the Dynamic manifest open or the Dynamic manifest
84 * close class is running, no other functions in the same shared object file
85 * may run.
86 * - When a function from the Dynamic manifest file class is called, no other
87 * functions from the same class may run if they are given at least one
88 * FILE * argument with the same value.
89 * - A function from the Dynamic manifest open class may not run after a
90 * successful call to a function from the same class, in case a function from
91 * the Dynamic manifest close class was not successfully called in the
92 * meanwhile.
93 * - A function from the Dynamic manifest close class may only run after a
94 * successful call to a function from the Dynamic manifest open class.
95 * - A function from the Dynamic manifest file class may only run beetween a
96 * successful call to a function from the Dynamic manifest open class and the
97 * following successful call to a function from the Dynamic manifest close
98 * class.
100 * Extensions to this specification which add new functions MUST declare in
101 * which of these classes the functions belong, or define new classes for them;
102 * furthermore, classes defined by such extensions MUST only allow calls after
103 * a successful call to a function from the Dynamic manifest open class and
104 * before the following successful call to a function from the Dynamic manifest
105 * close class.
107 * Any simultaneous calls that are not explicitly forbidden by these rules are
108 * allowed.
112 /* ************************************************************************* */
115 /** Dynamic manifest generator handle.
117 * This handle indicates a particular status of a dynamic manifest generator.
118 * The host MUST NOT attempt to interpret it and, unlikely LV2_Handle, it is NOT
119 * even valid to compare this to NULL. The dynamic manifest generator may use it
120 * to reference internal data. */
121 typedef void * LV2_Dyn_Manifest_Handle;
124 /* ************************************************************************* */
127 /** Accessing data.
129 * Whenever a host wants to access data using this API, it could:
131 * 1. Call lv2_dyn_manifest_open();
132 * 2. Create an empty resource identified by a FILE *;
133 * 3. Get a "list" of exposed subject URIs using
134 * lv2_dyn_manifest_get_subjects();
135 * 4. Call lv2_dyn_manifest_get_data() for each URI of interest, in order to
136 * get data related to that URI (either by calling the function subsequently
137 * with the same FILE * resource, or by creating more FILE * resources to
138 * perform parallel calls);
139 * 5. Call lv2_dyn_manifest_close();
140 * 6. Parse the content of the FILE * resource(s).
141 * 7. Free/delete/unlink the FILE * resource(s).
143 * The content of the FILE * resources has to be interpreted by the host as a
144 * regular file in Turtle syntax. This also means that each FILE * resource
145 * should also contain needed prefix definitions, in case any are used.
147 * Each call to lv2_dyn_manifest_open() automatically implies the (re)generation
148 * of the dynamic manifest on the library side.
150 * When such calls are made, data fetched from the involved library using this
151 * API before such call is to be considered no more valid.
153 * In case the library uses this same API to access other dynamic manifests, it
154 * MUST implement some mechanism to avoid potentially endless loops (such as A
155 * loads B, B loads A, etc.) in functions from the Dynamic manifest open class
156 * (the open-like operation MUST fail). For this purpose, use of a static
157 * boolean flag is suggested.
160 /** Function that (re)generates the dynamic manifest.
162 * handle is a pointer to an uninitialized dynamic manifest generator handle.
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.
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.
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.
182 * handle is the dynamic manifest generator handle.
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).
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:
195 * <http://www.example.com/plugin/uri> a lv2:Plugin;
197 * This function MUST return 0 on success, otherwise a non-zero error code.
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.
204 * handle is the dynamic manifest generator handle.
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).
212 * uri is the URI to get data about (in the "plain" form, a.k.a. without RDF
213 * prefixes).
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:
220 * <http://www.example.com/plugin/uri> a lv2:Plugin;
221 * lv2:binary <mylib.so>;
222 * doap:name "My Plugin";
223 * ... etc...
225 * This function MUST return 0 on success, otherwise a non-zero error code.
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.
233 * handle is the dynamic manifest generator handle.
235 * This function should be used by the dynamic manifest generator to perform
236 * cleanup operations, etc.
238 void lv2_dyn_manifest_close(LV2_Dyn_Manifest_Handle handle);
240 #ifdef __cplusplus
242 #endif
244 #endif /* LV2_DYN_MANIFEST_H_INCLUDED */