Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
61cce3420547d8e6ec96bbcd3b8c008ed3a59187
[simgrid.git] / src / gras / DataDesc / categories.h
1 /* gs_categories.h */
2 #ifndef GS_CATEGORIES_H
3 #define GS_CATEGORIES_H
4
5 /*
6  * Avoid some strange warnings with callback defs.
7  */
8 struct s_gs_type;
9
10 /*
11  * categories of types
12  */
13 enum e_gs_type_category {
14         e_gs_type_cat_undefined = 0,
15
16         e_gs_type_cat_elemental,
17         e_gs_type_cat_struct,
18         e_gs_type_cat_union,
19         e_gs_type_cat_ref,
20         e_gs_type_cat_array,
21         e_gs_type_cat_ignored,
22
23         e_gs_type_cat_invalid
24 };
25
26
27 /*
28  * Elemental category
29  */
30 enum e_gs_elemental_encoding {
31         e_gs_elemental_encoding_undefined = 0,
32
33         e_gs_elemental_encoding_unsigned_integer,
34         e_gs_elemental_encoding_signed_integer,
35         e_gs_elemental_encoding_floating_point,
36
37         e_gs_elemental_encoding_invalid
38 };
39
40 struct s_gs_cat_elemental {
41         int                             encoding;
42 };
43
44
45 /*
46  * Structure category
47  */
48 struct s_gs_cat_struct_field {
49
50         char                           *name;
51         long int                        offset;
52         int                             code;
53
54         void                            (*before_callback)(void                 *vars,
55                                                            struct s_gs_type     *p_type,
56                                                            void                 *data);
57
58         void                            (*after_callback)(void                  *vars,
59                                                           struct s_gs_type      *p_type,
60                                                           void                  *data);
61 };
62
63 struct s_gs_cat_struct {
64
65         int                               nb_fields;
66         struct s_gs_cat_struct_field    **field_array;
67 };
68
69
70 /*
71  * Union category
72  */
73 struct s_gs_cat_union_field {
74
75         char                           *name;
76         int                             code;
77
78         void                            (*before_callback)(void                 *vars,
79                                                            struct s_gs_type     *p_type,
80                                                            void                 *data);
81
82         void                            (*after_callback)(void                  *vars,
83                                                           struct s_gs_type      *p_type,
84                                                           void                  *data);
85 };
86
87 struct s_gs_cat_union {
88
89         int                               nb_fields;
90         struct s_gs_cat_union_field     **field_array;
91
92         /* callback used to return the field number  */
93         int                         (*callback)(void             *vars,
94                                                 struct s_gs_type *p_type,
95                                                 void             *data);
96 };
97
98
99 /*
100  * Ref category
101  */
102 struct s_gs_cat_ref {
103         int                             code;
104
105         /* callback used to return the referenced type number  */
106         int                         (*callback)(void             *vars,
107                                                 struct s_gs_type *p_type,
108                                                 void             *data);
109 };
110
111
112 /*
113  * Array_categorie
114  */
115 struct s_gs_cat_array {
116         int                             code;
117
118         /* element_count < 0 means dynamically defined */
119         long int                          element_count;
120
121         /* callback used to return the dynamic length */
122         long int                         (*callback)(void               *vars,
123                                                      struct s_gs_type   *p_type,
124                                                      void               *data);
125 };
126
127 /*
128  * Ignored category
129  */
130 struct s_gs_cat_ignored {
131         void                            *default_value;
132 };
133
134 gras_type_t *
135 gs_type_new_elemental(gras_type_bag_t   *p_bag,
136                       gras_connection_t *p_connection,
137                       const char        *name,
138                       enum e_gs_elemental_encoding       encoding,
139                       long int                           size);
140
141 gras_type_t *
142 gs_type_new_elemental_with_callback(gras_type_bag_t     *p_bag,
143                                     gras_connection_t   *p_connection,
144                                     const char                          *name,
145                                     enum e_gs_elemental_encoding         encoding,
146                                     long int                             size,
147
148                                     void (*callback)(void               *vars,
149                                                      gras_type_t        *p_type,
150                                                      void               *data));
151
152
153
154 #endif /* GS_CATEGORIES_H */