3 /* gras/datadesc.h - Describing the data you want to exchange */
5 /* Authors: Martin Quinson */
6 /* Copyright (C) 2003 the OURAGAN project. */
8 /* This program is free software; you can redistribute it and/or modify it
9 under the terms of the license (GNU LGPL) which comes with this package. */
11 #ifndef GRAS_DATADESC_SIMPLE_H
12 #define GRAS_DATADESC_SIMPLE_H
14 #include <stddef.h> /* offsetof() */
15 #include <sys/types.h> /* size_t */
19 /*! C++ users need love */
22 # define BEGIN_DECL extern "C" {
28 /*! C++ users need love */
36 /* End of cruft for C++ */
41 **** The NWS type and constructors
45 {CHAR_TYPE, DOUBLE_TYPE, FLOAT_TYPE, INT_TYPE, LONG_TYPE, SHORT_TYPE,
46 UNSIGNED_INT_TYPE, UNSIGNED_LONG_TYPE, UNSIGNED_SHORT_TYPE, STRUCT_TYPE}
48 #define SIMPLE_TYPE_COUNT 9
50 typedef struct DataDescriptorStruct {
54 struct DataDescriptorStruct *members;
61 #define SIMPLE_DATA(type,repetitions) {type, repetitions, 0, NULL, 0, 0}
62 #define SIMPLE_MEMBER(type,repetitions,offset) \
63 {type, repetitions, offset, NULL, 0, 0}
64 #define PAD_BYTES(structType,lastMember,memberType,repetitions) \
65 sizeof(structType) - offsetof(structType, lastMember) - \
66 sizeof(memberType) * repetitions
69 **** Gras (opaque) type, constructors and functions
72 typedef struct gras_datadesc_ gras_datadesc_t;
74 /* constructors, memory management */
75 gras_error_t gras_datadesc_parse(const char *def,
76 gras_datadesc_t **dst);
77 gras_error_t gras_datadesc_from_nws(const DataDescriptor *desc,
79 gras_datadesc_t **dst);
81 gras_error_t gras_datadesc_cpy(gras_datadesc_t *src,
82 gras_datadesc_t **dst);
83 void gras_datadesc_free(gras_datadesc_t **dd);
85 /* basic functionnalities */
86 int gras_datadesc_cmp(const gras_datadesc_t *d1,
87 const gras_datadesc_t *d2);
89 gras_error_t gras_datadesc_sizeof_host(gras_datadesc_t *desc,
91 gras_error_t gras_datadesc_sizeof_network(gras_datadesc_t *desc,
94 /* high level function needed in SG */
95 gras_error_t gras_datadesc_data_cpy(const gras_datadesc_t *dd,
99 /* high level functions needed in RL */
100 gras_error_t gras_datadesc_convert_recv(const gras_datadesc_t *dd,
101 gras_trp_plugin_t *trp,
103 gras_error_t gras_datadesc_convert_send(const gras_datadesc_t *dd,
104 gras_trp_plugin_t *trp,
109 #endif /* GRAS_DATADESC_SIMPLE_H */