Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
f75d57490ade7922584157dc45b44f1a7acd4d4f
[simgrid.git] / doc / gtut-tour-13-pointers.doc
1 /**
2 @page GRAS_tut_tour_pointers Lesson 13: Defining structure containing pointers (TODO)
3
4 This lesson is a bit different from the other ones. It aims at explaining
5 several features of the automatic datadesc parsing. Since it would be a bit
6 long otherwise, the lesson is organized as a FAQ, with little examples of
7 how to do things.
8
9 \section GRAS_tut_tour_pointers_toc Table of Contents
10  - \ref GRAS_tut_tour_pointers_cste
11    
12 <hr>
13
14
15 \section GRAS_tut_tour_pointers_cste How to have constants in parsed structures?
16
17 You can use gras_datadesc_set_const() to explain GRAS about the value of
18 your \#define'd constants.
19
20 \verbatim
21 #define SIZE 12
22 GRAS_DEFINE_TYPE(array,struct array {
23   int data[SIZE];
24 };);
25
26 void declare_ddt() {
27   gras_datadesc_type_t ddt;
28   
29   gras_datadesc_set_const("SIZE",SIZE); /* Set it before */
30   gras_datadesc_by_symbol(array); 
31 }
32 \endverbatim
33
34
35 */
36
37 #define COLS 16
38 #define MAX_ROUTESET 10
39 #define MAX_LEAFSET COLS
40
41 GRAS_DEFINE_TYPE(gras_row_t,
42 struct gras_row_t {         
43   int which_row;            
44   int row[COLS][MAX_ROUTESET];
45 };)
46     
47 typedef struct gras_row_t gras_row_t;
48     
49 GRAS_DEFINE_TYPE(gras_welcome_msg_t, 
50 struct gras_welcome_msg_t {
51   int id;
52   double time_sent;
53     
54   int row_count;
55   gras_row_t *rows GRAS_ANNOTE(size,row_count);
56         
57   int leaves[MAX_LEAFSET];
58 };)              
59
60 void declare_ddt(void) {
61   gras_datadesc_type_t ddt;
62   
63   gras_datadesc_set_const("COLS",COLS);
64   gras_datadesc_set_const("MAX_ROUTESET",MAX_ROUTESET);
65   gras_datadesc_set_const("MAX_LEAFSET",MAX_LEAFSET);
66   
67   gras_datadesc_by_symbol(gras_row_t); /* Parse it before */
68   ddt=gras_datadesc_ref("welcome_msg_t*",gras_datadesc_by_symbol(gras_welcome_msg_t));
69   gras_msgtype_declare("welcome",ddt);  
70 }