PDI 0.4.1

Data exchange made easy

pdi.h
1 /*******************************************************************************
2 * Copyright (C) 2015-2019 Commissariat a l'energie atomique et aux energies alternatives (CEA)
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of CEA nor the names of its contributors may be used to
13 * endorse or promote products derived from this software without specific
14 * prior written permission.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 ******************************************************************************/
24 
59 #ifndef PDI_H_
60 #define PDI_H_
61 
62 #include <paraconf.h>
63 
64 #include <pdi/export.h>
65 #include <pdi/version.h>
66 
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 
77 typedef enum PDI_status_e {
79  PDI_OK = 0,
100 
101 } PDI_status_t;
102 
108 typedef void (*PDI_errfunc_f)(PDI_status_t status, const char* message, void* context);
109 
112 typedef struct PDI_errhandler_s {
113 
116 
118  void* context;
119 
121 
122 
125 extern const PDI_errhandler_t PDI_EXPORT PDI_ASSERT_HANDLER;
126 
129 extern const PDI_errhandler_t PDI_EXPORT PDI_WARN_HANDLER;
130 
133 extern const PDI_errhandler_t PDI_EXPORT PDI_NULL_HANDLER;
134 
135 
138 const char PDI_EXPORT* PDI_errmsg(void);
139 
148 
150 
162 PDI_status_t PDI_EXPORT PDI_init(PC_tree_t conf);
163 
167 PDI_status_t PDI_EXPORT PDI_finalize(void);
168 
176 PDI_status_t PDI_EXPORT PDI_version(unsigned long* provided, unsigned long expected);
177 
179 
187 typedef enum PDI_inout_e {
189  PDI_NONE = 0,
191  PDI_IN = 1,
193  PDI_OUT = 2,
196 
197 } PDI_inout_t;
198 
199 
214 PDI_status_t PDI_EXPORT PDI_share(const char* name, void* data, PDI_inout_t access);
215 
224 PDI_status_t PDI_EXPORT PDI_access(const char* name, void** buffer, PDI_inout_t inout);
225 
233 PDI_status_t PDI_EXPORT PDI_release(const char* name);
234 
242 PDI_status_t PDI_EXPORT PDI_reclaim(const char* name);
243 
248 PDI_status_t PDI_EXPORT PDI_event(const char* event);
249 
251 
263 PDI_status_t PDI_EXPORT PDI_expose(const char* name, void* data, PDI_inout_t access);
264 
280 PDI_status_t PDI_EXPORT PDI_multi_expose(const char* event_name, const char* name, void* data, PDI_inout_t access, ...);
281 
296 PDI_status_t PDI_DEPRECATED_EXPORT PDI_transaction_begin(const char* name);
297 
308 PDI_status_t PDI_DEPRECATED_EXPORT PDI_transaction_end(void);
309 
311 
312 #ifdef __cplusplus
313 } // extern C
314 #endif
315 
316 
317 #endif // PDI_H_
PDI_status_t PDI_transaction_end(void)
Ends the previously opened transaction.
PDI_status_t PDI_multi_expose(const char *event_name, const char *name, void *data, PDI_inout_t access,...)
Performs multiple exposes at once.
data transfer in both direction
Definition: pdi.h:195
const PDI_errhandler_t PDI_WARN_HANDLER
Prints the error message and continue if the status is invalid.
PDI_errhandler_t PDI_errhandler(PDI_errhandler_t handler)
Sets the error handler to use.
Definition of an error handler.
Definition: pdi.h:112
on an input call, no such data is available
Definition: pdi.h:81
PDI_status_t PDI_event(const char *event)
Triggers a PDI "event".
A system error occured (OS, etc.)
Definition: pdi.h:91
void(* PDI_errfunc_f)(PDI_status_t status, const char *message, void *context)
Type of a callback function used when an error occurs.
Definition: pdi.h:108
No data transfert.
Definition: pdi.h:189
PDI_status_t PDI_share(const char *name, void *data, PDI_inout_t access)
Shares some data with PDI.
A value expression is invalid.
Definition: pdi.h:85
The configuration file is invalid.
Definition: pdi.h:83
A call to a function has been made at a wrong time (e.g.
Definition: pdi.h:95
Invalid type error.
Definition: pdi.h:99
PDI_status_t PDI_init(PC_tree_t conf)
Initializes PDI.
PDI_status_t PDI_expose(const char *name, void *data, PDI_inout_t access)
Shortly exposes some data to PDI.
data transfer from the main code to PDI
Definition: pdi.h:193
PDI_status_t PDI_transaction_begin(const char *name)
Begin a transaction in which all PDI_expose calls are grouped.
Tried to load a non-existing plugin.
Definition: pdi.h:87
PDI_status_t PDI_reclaim(const char *name)
Reclaims ownership of a data buffer shared with PDI.
PDI_status_t PDI_release(const char *name)
Releases ownership of a data shared with PDI.
PDI_inout_t
Access directions.
Definition: pdi.h:187
everything went well
Definition: pdi.h:79
PDI_status_t
Error codes of PDI.
Definition: pdi.h:77
A conflict of onwership over a content has been raised.
Definition: pdi.h:97
PDI_status_t PDI_access(const char *name, void **buffer, PDI_inout_t inout)
Requests for PDI to access a data buffer.
const PDI_errhandler_t PDI_NULL_HANDLER
Does nothing.
void * context
the context that will be provided to the function
Definition: pdi.h:118
const char * PDI_errmsg(void)
Return a human-readabe message describing the last error that occured in PDI.
PDI_errfunc_f func
The function to handle the error (none if NULL)
Definition: pdi.h:115
const PDI_errhandler_t PDI_ASSERT_HANDLER
Prints the error message and aborts if the status is invalid.
PDI_status_t PDI_finalize(void)
Finalizes PDI.
data tranfer from PDI to the main code
Definition: pdi.h:191
PDI_status_t PDI_version(unsigned long *provided, unsigned long expected)
Checks PDI API version.
Implementation limitation (typically an unimplemented feature)
Definition: pdi.h:89