SimGrid  3.7
Scalable simulation of distributed systems
Functions
Data description with Callback Persistant State: Simple push/pop mechanism
Data description

Functions

void xbt_cbps_i_push (xbt_cbps_t ps, int val)
 Push a new integer value into the cbps.
int xbt_cbps_i_pop (xbt_cbps_t ps)
 Pop the lastly pushed integer value from the cbps.
int xbt_datadesc_cb_pop (xbt_datadesc_type_t typedesc, xbt_cbps_t vars, void *data)
 Generic cb returning the lastly pushed value.
void xbt_datadesc_cb_push_int (xbt_datadesc_type_t typedesc, xbt_cbps_t vars, void *data)
 Cb to push an integer. Must be attached to the field you want to push.
void xbt_datadesc_cb_push_uint (xbt_datadesc_type_t typedesc, xbt_cbps_t vars, void *data)
 Cb to push an unsigned integer. Must be attached to the field you want to push.
void xbt_datadesc_cb_push_lint (xbt_datadesc_type_t typedesc, xbt_cbps_t vars, void *data)
 Cb to push an long integer. Must be attached to the field you want to push.
void xbt_datadesc_cb_push_ulint (xbt_datadesc_type_t typedesc, xbt_cbps_t vars, void *data)
 Cb to push an unsigned long integer. Must be attached to the field you want to push.
void xbt_datadesc_cb_push_int_mult (xbt_datadesc_type_t typedesc, xbt_cbps_t vars, void *data)
 Cb to push an integer as multiplier. Must be attached to the field you want to push.
void xbt_datadesc_cb_push_uint_mult (xbt_datadesc_type_t typedesc, xbt_cbps_t vars, void *data)
 Cb to push an unsigned integer as multiplier. Must be attached to the field you want to push.
void xbt_datadesc_cb_push_lint_mult (xbt_datadesc_type_t typedesc, xbt_cbps_t vars, void *data)
 Cb to push an long integer as multiplier. Must be attached to the field you want to push.
void xbt_datadesc_cb_push_ulint_mult (xbt_datadesc_type_t typedesc, xbt_cbps_t vars, void *data)
 Cb to push an unsigned long integer as multiplier. Must be attached to the field you want to push.

Detailed Description

Sometimes, one of the callbacks need to leave information for the next ones. If this is a simple integer (such as an array size), you can use the functions described here. If not, you'll have to play with the complete cbps interface.

Here is an example:

struct s_array {
  int length;
  int *data;
}
[...]
my_type=xbt_datadesc_struct("s_array");
xbt_datadesc_struct_append(my_type,"length", xbt_datadesc_by_name("int"));
xbt_datadesc_cb_field_send (my_type, "length", xbt_datadesc_cb_push_int);

xbt_datadesc_struct_append(my_type,"data",
                            xbt_datadesc_array_dyn ("s_array::data",xbt_datadesc_by_name("int"), xbt_datadesc_cb_pop));
xbt_datadesc_struct_close(my_type);

The *_mult versions are intended for multi-dimensional arrays: They multiply their value to the previously pushed one (by another field callback) and push the result of the multiplication back. An example of use follows. Please note that the first field needs a regular push callback, not a multiplier one. Think of it as a stacked calculator (man dc(1)).

struct s_matrix {
  int row;
  int col;
  int *data;
}
[...]
my_type=xbt_datadesc_struct("s_matrix");
xbt_datadesc_struct_append(my_type,"row", xbt_datadesc_by_name("int"));
xbt_datadesc_cb_field_send (my_type, "length", xbt_datadesc_cb_push_int);
xbt_datadesc_struct_append(my_type,"col", xbt_datadesc_by_name("int"));
xbt_datadesc_cb_field_send (my_type, "length", xbt_datadesc_cb_push_int_mult);

xbt_datadesc_struct_append(my_type,"data",
                            xbt_datadesc_array_dyn ("s_matrix::data",xbt_datadesc_by_name("int"), xbt_datadesc_cb_pop));
xbt_datadesc_struct_close(my_type);

Function Documentation

int xbt_datadesc_cb_pop ( xbt_datadesc_type_t  ignored,
xbt_cbps_t  vars,
void *  data 
)

Generic cb returning the lastly pushed value.

Used by xbt_datadesc_ref_pop_arr


Back to the main Simgrid Documentation page The version of SimGrid documented here is v3.7.
Documentation of other versions can be found in their respective archive files (directory doc/html).
Generated by doxygen