Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Adapt to lastest changes in dict: Create dicts before use
[simgrid.git] / include / data_description.h
1 /* gs_interface.h */
2 #ifndef GS_INTERFACE_H
3 #define GS_INTERFACE_H
4
5 /* Mask internal structures to users */
6 typedef struct s_gs_type_bag            gras_type_bag_t;
7 typedef struct s_gs_connection          gras_connection_t;
8 typedef struct s_gs_type                gras_type_t;
9 typedef struct s_gs_message             gras_message_t;
10 typedef struct s_gs_net_driver          gras_net_driver_t;
11 typedef struct s_gs_message_instance    gras_message_instance_t;
12 typedef struct s_gs_type_driver         gras_type_driver_t;
13
14
15 /* public functions */
16 void
17 gs_init(int    argc,
18         char **argv);
19
20 void
21 gs_purge_cmd_line(int   *argc,
22                   char **argv);
23
24 void
25 gs_exit(void);
26
27 /* -- */
28
29 gras_type_t *
30 gs_type_new_unsigned_integer_elemental(gras_type_bag_t          *p_bag,
31                                        gras_connection_t        *p_connection,
32                                        const char               *name,
33                                        long int                 size);
34
35 gras_type_t *
36 gs_type_new_signed_integer_elemental(gras_type_bag_t    *p_bag,
37                                      gras_connection_t  *p_connection,
38                                      const char         *name,
39                                      long int    size);
40
41 gras_type_t *
42 gs_type_new_floating_point_elemental(gras_type_bag_t    *p_bag,
43                                      gras_connection_t  *p_connection,
44                                      const char         *name,
45                                      long int    size);
46
47 gras_type_t *
48 gs_type_new_struct(gras_type_bag_t      *p_bag,
49                    gras_connection_t    *p_connection,
50                    const char   *name);
51
52 void
53 gs_type_struct_append_field(gras_type_t         *p_struct_type,
54                             const char          *name,
55                             gras_type_t         *p_field_type);
56
57 gras_type_t *
58 gs_type_new_union(gras_type_bag_t       *p_bag,
59                   gras_connection_t     *p_connection,
60                   const char    *name,
61
62                   int (*field_callback)(void            *vars,
63                                         gras_type_t     *p_type,
64                                         void            *data));
65
66 void
67 gs_type_union_append_field(gras_type_t  *p_union_type,
68                            const char   *name,
69                            gras_type_t  *p_field_type);
70
71 gras_type_t *
72 gs_type_new_ref(gras_type_bag_t         *p_bag,
73                 gras_connection_t       *p_connection,
74                 const char              *name,
75                 gras_type_t             *p_referenced_type);
76
77 gras_type_t *
78 gs_type_new_array(gras_type_bag_t       *p_bag,
79                   gras_connection_t     *p_connection,
80                   const char            *name,
81                   long int               size,
82                   gras_type_t           *p_array_element_type);
83
84 gras_type_t *
85 gs_type_new_ignored(gras_type_bag_t     *p_bag,
86                     gras_connection_t   *p_connection,
87                     const char  *name,
88                     long int     size,
89                     long int     alignment,
90                     void        *default_value);
91
92 /* -- */
93
94 gras_type_t *
95 gs_type_new_unsigned_integer_elemental_with_callback(gras_type_bag_t    *p_bag,
96                                                      gras_connection_t  *p_connection,
97                                                      const char *name,
98                                                      long int    size,
99
100                                                      void (*callback)(void              *vars,
101                                                                       gras_type_t       *p_type,
102                                                                       void              *data));
103
104 gras_type_t *
105 gs_type_new_signed_integer_elemental_with_callback(gras_type_bag_t      *p_bag,
106                                                    gras_connection_t    *p_connection,
107                                                    const char           *name,
108                                                    long int      size,
109
110                                                    void (*callback)(void                *vars,
111                                                                     gras_type_t *p_type,
112                                                                     void                *data));
113
114 gras_type_t *
115 gs_type_new_floating_point_elemental_with_callback(gras_type_bag_t      *p_bag,
116                                                    gras_connection_t    *p_connection,
117                                                    const char           *name,
118                                                    long int      size,
119
120                                                    void (*callback)(void                *vars,
121                                                                     gras_type_t *p_type,
122                                                                     void                *data));
123
124 gras_type_t *
125 gs_type_new_struct_with_callback(gras_type_bag_t        *p_bag,
126                                  gras_connection_t      *p_connection,
127                                  const char *name,
128
129                                  void (*before_callback)(void                   *vars,
130                                                          gras_type_t    *p_type,
131                                                          void                   *data),
132
133                                  void (*after_callback)(void                    *vars,
134                                                         gras_type_t     *p_type,
135                                                         void                    *data));
136
137 void
138 gs_type_struct_append_field_with_callback(gras_type_t   *p_struct_type,
139                                           const char                    *name,
140                                           gras_type_t   *p_field_type,
141
142                                           void (*before_callback)(void                  *vars,
143                                                                   gras_type_t   *p_type,
144                                                                   void                  *data),
145
146                                           void (*after_callback)(void                   *vars,
147                                                                  gras_type_t    *p_type,
148                                                                  void                   *data));
149
150
151 gras_type_t *
152 gs_type_new_union_with_callback(gras_type_bag_t *p_bag,
153                                 gras_connection_t       *p_connection,
154                                 const char *name,
155
156                                 int (*field_callback)(void              *vars,
157                                                        gras_type_t      *p_type,
158                                                        void             *data),
159
160                                 void (*after_callback)(void             *vars,
161                                                        gras_type_t      *p_type,
162                                                        void             *data));
163
164 void
165 gs_type_union_append_field_with_callback(gras_type_t    *p_union_type,
166                                          const char                     *name,
167                                          gras_type_t    *p_field_type,
168
169                                          void (*before_callback)(void                   *vars,
170                                                                  gras_type_t    *p_type,
171                                                                  void                   *data),
172
173                                          void (*after_callback)(void                    *vars,
174                                                                 gras_type_t     *p_type,
175                                                                 void                    *data));
176
177 gras_type_t *
178 gs_type_new_ref_with_callback(gras_type_bag_t   *p_bag,
179                               gras_connection_t *p_connection,
180                               const char                *name,
181                               gras_type_t       *p_referenced_type,
182
183                               int (*type_callback)(void                 *vars,
184                                                    gras_type_t  *p_type,
185                                                    void                 *data),
186
187                               void (*after_callback)(void               *vars,
188                                                      gras_type_t        *p_type,
189                                                      void               *data));
190
191 gras_type_t *
192 gs_type_new_array_with_callback(gras_type_bag_t *p_bag,
193                                 gras_connection_t       *p_connection,
194                                 const char                      *name,
195                                 long int                size,
196                                 gras_type_t     *p_array_element_type,
197
198                                 long int (*size_callback)(void                  *vars,
199                                                           gras_type_t   *p_type,
200                                                           void                  *data),
201
202                                 void (*after_callback)(void                     *vars,
203                                                        gras_type_t              *p_type,
204                                                        void                     *data));
205
206 gras_type_t *
207 gs_type_new_ignored_with_callback(gras_type_bag_t       *p_bag,
208                                   gras_connection_t     *p_connection,
209                                   const char            *name,
210                                   long int       size,
211                                   long int       alignment,
212                                   void          *default_value,
213                                   void (*callback)(void                 *vars,
214                                                    gras_type_t  *p_type,
215                                                    void                 *data));
216
217 /* Automatic parsing of datatypes */
218 gras_type_t *
219 _gs_type_parse(gras_type_bag_t  *p_bag,
220                const char       *definition);
221
222 #define GRAS_DEFINE_TYPE(name,def) \
223   static const char * _gs_this_type_symbol_does_not_exist__##name=#def; def
224
225 #define gras_type_symbol_parse(bag,name)                                  \
226  _gs_type_parse(bag, _gs_this_type_symbol_does_not_exist__##name)
227
228 #define gs_type_get_by_symbol(bag,name)                  \
229   (bag->bag_ops->get_type_by_name(bag, NULL, #name) ?    \
230      bag->bag_ops->get_type_by_name(bag, NULL, #name) :  \
231      gras_type_symbol_parse(bag, name)                   \
232   )
233
234 /* -- */
235
236 void
237 gs_bootstrap_incoming_connection(gras_type_bag_t        *p_bag,
238                                  gras_connection_t      *p_cnx);
239
240 void
241 gs_bootstrap_type_bag(gras_type_bag_t *p_bag);
242
243
244 void
245 gs_bootstrap_outgoing_connection(gras_type_bag_t        *p_bag,
246                                  gras_connection_t      *p_cnx);
247
248 /* -- */
249
250 gras_message_t *
251 gs_message_new(gras_type_bag_t  *p_bag,
252                gras_connection_t        *p_connection,
253                const char                       *name);
254
255
256 void
257 gs_message_append_new_sequence(gras_message_t   *p_message,
258                                gras_type_t              *p_type);
259
260 gras_message_instance_t *
261 gs_message_init_send_by_ref(gras_type_bag_t     *p_bag,
262                              gras_connection_t  *p_connection,
263                              gras_message_t     *p_message);
264
265 gras_message_instance_t *
266 gs_message_init_send_by_name(gras_type_bag_t    *p_bag,
267                              gras_connection_t  *p_connection,
268                              const char *name);
269
270 gras_message_instance_t *
271 gs_message_init_send_by_code(gras_type_bag_t    *p_bag,
272                              gras_connection_t  *p_connection,
273                              int code);
274
275
276 void
277 gs_message_send_next_sequence_ext(void                          *vars,
278                                   gras_message_instance_t       *p_message_instance,
279                                   void                          *data);
280
281 void
282 gs_message_send_next_sequence(gras_message_instance_t   *p_message_instance,
283                               void                              *data);
284
285 void *
286 gs_message_receive_next_sequence(gras_message_instance_t *p_message_instance);
287
288 gras_message_instance_t *
289 gs_message_init_receive(gras_type_bag_t *p_bag,
290                         gras_connection_t       *p_cnx);
291
292 /* -- */
293
294 void *
295 gs_vars_alloc(void);
296
297 void
298 gs_vars_free(void *p_vars);
299
300 void
301 gs_vars_enter(void *p_vars);
302
303 void
304 gs_vars_leave(void *p_vars);
305
306 void
307 gs_vars_push(void               *p_vars,
308              gras_type_t        *p_type,
309              const char         *name,
310              void               *data);
311
312 void *
313 gs_vars_get(void                 *p_vars,
314             const char           *name,
315             gras_type_t **pp_type);
316
317 void
318 gs_vars_set(void                *p_vars,
319             gras_type_t *p_type,
320             const char          *name,
321             void                *data);
322
323 void *
324 gs_vars_pop(void                 *p_vars,
325             const char           *name,
326             gras_type_t **pp_type);
327
328 /* -- */
329
330 void
331 gs_net_drivers_init(void);
332
333 gras_net_driver_t *
334 gs_net_driver_init(const char *name);
335
336 void
337 gs_net_driver_exit(gras_net_driver_t    *p_net_driver);
338
339 gras_connection_t *
340 gs_net_connection_connect(gras_net_driver_t     *p_net_driver,
341                           void                          *arg);
342
343 gras_connection_t *
344 gs_net_connection_accept(gras_net_driver_t      *p_net_driver,
345                          void                   *arg);
346
347 void
348 gs_net_connection_close(gras_connection_t       *p_connection);
349
350 /* -- */
351
352 void
353 gs_type_drivers_init(void);
354
355 gras_type_driver_t *
356 gs_type_driver_init(const char *name);
357
358 void
359 gs_type_driver_exit(gras_type_driver_t  *p_type_driver);
360
361
362 gras_type_bag_t *
363 gs_type_bag_alloc(gras_type_driver_t    *p_driver);
364
365 void
366 gs_type_bag_free(gras_type_bag_t        *p_bag);
367
368 /* -- */
369
370 void *
371 gs_memdup(const void * const ptr,
372           const size_t       length);
373
374
375 #endif /* GS_INTERFACE_H */