X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/081dcade7709989b3d7b83719121868ee11a3dfc..ebd3066b86ef358bce0557c175febcd8ed6fdefc:/include/datadesc.h diff --git a/include/datadesc.h b/include/datadesc.h index 4820fef9be..07163c8ab7 100644 --- a/include/datadesc.h +++ b/include/datadesc.h @@ -3,7 +3,7 @@ /* gras/datadesc.h - Describing the data you want to exchange */ /* Authors: Martin Quinson */ -/* Copyright (C) 2003 the OURAGAN project. */ +/* Copyright (C) 2003, 2004 Martin Quinson. */ /* This program is free software; you can redistribute it and/or modify it under the terms of the license (GNU LGPL) which comes with this package. */ @@ -37,6 +37,142 @@ BEGIN_DECL + +/** + * gras_datadesc_type_t: + * + * Opaque type describing a type description you don't want to open. + */ +typedef struct s_gras_datadesc_type gras_datadesc_type_t; + +/* callbacks prototypes */ +typedef void (*gras_datadesc_type_cb_void_t)(void *vars, + gras_datadesc_type_t *p_type, + void *data); +typedef int (*gras_datadesc_type_cb_int_t)(void *vars, + gras_datadesc_type_t *p_type, + void *data); + +/*********************************************** + **** Search and retrieve declared datatype **** + ***********************************************/ +gras_datadesc_type_t *gras_datadesc_by_name(const char *name); + +/****************************************** + **** Declare datadescription yourself **** + ******************************************/ + +gras_error_t +gras_datadesc_declare_struct(const char *name, + gras_datadesc_type_t **dst); +gras_error_t +gras_datadesc_declare_struct_append(gras_datadesc_type_t *struct_type, + const char *name, + gras_datadesc_type_t *field_type); +void +gras_datadesc_declare_struct_close(gras_datadesc_type_t *struct_type); +gras_error_t +gras_datadesc_declare_union(const char *name, + gras_datadesc_type_cb_int_t selector, + gras_datadesc_type_t **dst); +gras_error_t +gras_datadesc_declare_union_append(gras_datadesc_type_t *union_type, + const char *name, + gras_datadesc_type_t *field_type); +void +gras_datadesc_declare_union_close(gras_datadesc_type_t *union_type); +gras_error_t +gras_datadesc_declare_ref(const char *name, + gras_datadesc_type_t *referenced_type, + gras_datadesc_type_t **dst); +gras_error_t +gras_datadesc_declare_ref_generic(const char *name, + gras_datadesc_type_cb_int_t discriminant, + gras_datadesc_type_t **dst); +gras_error_t +gras_datadesc_declare_array_fixed(const char *name, + gras_datadesc_type_t *element_type, + long int fixed_size, + gras_datadesc_type_t **dst); +gras_error_t +gras_datadesc_declare_array_dyn(const char *name, + gras_datadesc_type_t *element_type, + gras_datadesc_type_cb_int_t dynamic_size, + gras_datadesc_type_t **dst); + +/********************************* + * Change stuff within datadescs * + *********************************/ + +typedef struct s_gras_dd_cbps gras_dd_cbps_t; +void gras_datadesc_cb_set_pre (gras_datadesc_type_t *type, + gras_datadesc_type_cb_void_t pre); +void gras_datadesc_cb_set_post(gras_datadesc_type_t *type, + gras_datadesc_type_cb_void_t post); + +/****************************** + * Get stuff within datadescs * + ******************************/ +char * gras_datadesc_get_name(gras_datadesc_type_t *ddt); +int gras_datadesc_get_id(gras_datadesc_type_t *ddt); + +/******************************************************** + * Advanced data describing: callback persistent states * + ********************************************************/ + +void * +gras_dd_cbps_pop (gras_dd_cbps_t *ps, + const char *name, + gras_datadesc_type_t **ddt); +void +gras_dd_cbps_push(gras_dd_cbps_t *ps, + const char *name, + void *data, + gras_datadesc_type_t *ddt); +void +gras_dd_cbps_set (gras_dd_cbps_t *ps, + const char *name, + void *data, + gras_datadesc_type_t *ddt); + +void * +gras_dd_cbps_get (gras_dd_cbps_t *ps, + const char *name, + gras_datadesc_type_t **ddt); + +void +gras_dd_cbps_block_begin(gras_dd_cbps_t *ps); +void +gras_dd_cbps_block_end(gras_dd_cbps_t *ps); + + + + +/******************************* + **** About data convertion **** + *******************************/ +int gras_arch_selfid(void); /* ID of this arch */ + +/**************************** + **** Parse C statements **** + ****************************/ +gras_datadesc_type_t * +gras_datadesc_parse(const char *name, + const char *Cdefinition); +#define GRAS_DEFINE_TYPE(name,def) \ + static const char * _gras_this_type_symbol_does_not_exist__##name=#def; def + +#define gras_datadesc_by_symbol(name) \ + (gras_datadesc_by_name(#name) ? \ + gras_datadesc_by_name(#name) : \ + gras_datadesc_parse(#name, \ + _gras_this_type_symbol_does_not_exist__##name) \ + ) + +/***************************** + **** NWS datadescription **** + *****************************/ + /** * Basic types we can embeed in DataDescriptors. */ @@ -77,113 +213,11 @@ typedef struct DataDescriptorStruct { sizeof(structType) - offsetof(structType, lastMember) - \ sizeof(memberType) * repetitions -/* -gras_error_t gras_datadesc_parse(const char *def, - gras_datadesc__t **dst); -gras_error_t gras_datadesc_from_nws(const DataDescriptor *desc, - size_t howmany, - gras_datadesc_t **dst); -gras_error_t gras_datadesc_eq(const gras_datadesc_t *d1, - const gras_datadesc_t *d2); -gras_error_t gras_datadesc_cpy(gras_datadesc_t *src, - gras_datadesc_t **dst); -gras_error_t gras_datadesc_sizeof_host(gras_datadesc_t *desc, - size_t *dst); -gras_error_t gras_datadesc_sizeof_network(gras_datadesc_t *desc, - size_t *dst); -*/ - -typedef struct s_gras_datadesc_type gras_datadesc_type_t; - -typedef void (*gras_datadesc_type_cb_void_t)(void *vars, - gras_datadesc_type_t *p_type, - void *data); -typedef int (*gras_datadesc_type_cb_int_t)(void *vars, - gras_datadesc_type_t *p_type, - void *data); - - - -/* Create a new type and register it on the local machine */ -#define gras_datadesc_declare_struct( name, code) \ - gras_datadesc_declare_struct_cb(name, NULL, NULL, code) - -#define gras_datadesc_declare_struct_add_name( struct_code,field_name,field_type_name) \ - gras_datadesc_declare_struct_add_name_cb(struct_code,field_name,field_type_name, NULL, NULL) - -#define gras_datadesc_declare_struct_add_code( struct_code,field_name,field_type_code) \ - gras_datadesc_declare_struct_add_code_cb(struct_code,field_name,field_type_code, NULL, NULL) - -gras_error_t -gras_datadesc_declare_struct_cb(const char *name, - gras_datadesc_type_cb_void_t pre_cb, - gras_datadesc_type_cb_void_t post_cb, - long int *code); -gras_error_t -gras_datadesc_declare_struct_add_name_cb(long int struct_code, - const char *field_name, - const char *field_type_name, - gras_datadesc_type_cb_void_t pre_cb, - gras_datadesc_type_cb_void_t post_cb); - -gras_error_t -gras_datadesc_declare_struct_add_code_cb(long int struct_code, - const char *field_name, - long int field_code, - gras_datadesc_type_cb_void_t pre_cb, - gras_datadesc_type_cb_void_t post_cb); -/* union */ -#define gras_datadesc_declare_union( name, code) \ - gras_datadesc_declare_union_cb(name, NULL, NULL, code) - -#define gras_datadesc_declare_union_add_name( union_code,field_name,field_type_name) \ - gras_datadesc_declare_union_add_name_cb(union_code,field_name,field_type_name, NULL, NULL) - -#define gras_datadesc_declare_union_add_code( union_code,field_name,field_type_code) \ - gras_datadesc_declare_union_add_code_cb(union_code,field_name,field_type_code, NULL, NULL) - -gras_error_t -gras_datadesc_declare_union_cb(const char *name, - gras_datadesc_type_cb_int_t field_count, - gras_datadesc_type_cb_void_t post, - long int *code); -gras_error_t -gras_datadesc_declare_union_add_name_cb(long int union_code, - const char *field_name, - const char *field_type_name, - gras_datadesc_type_cb_void_t pre_cb, - gras_datadesc_type_cb_void_t post_cb); -gras_error_t -gras_datadesc_declare_union_add_code_cb(long int union_code, - const char *field_name, - long int field_code, - gras_datadesc_type_cb_void_t pre_cb, - gras_datadesc_type_cb_void_t post_cb); -/* ref */ -#define gras_datadesc_declare_ref(name,ref_type, code) \ - gras_datadesc_declare_ref_cb(name, ref_type, NULL, NULL, code) -#define gras_datadesc_declare_ref_disc(name,discriminant, code) \ - gras_datadesc_declare_ref_cb(name, NULL, discriminant, NULL, code) - gras_error_t -gras_datadesc_declare_ref_cb(const char *name, - gras_datadesc_type_t *referenced_type, - gras_datadesc_type_cb_int_t discriminant, - gras_datadesc_type_cb_void_t post, - long int *code); -/* array */ -#define gras_datadesc_declare_array(name,elm_type, size, code) \ - gras_datadesc_declare_array_cb(name, elm_type, size, NULL, NULL, code) -#define gras_datadesc_declare_array_dyn(name,elm_type, dynamic_size, code) \ - gras_datadesc_declare_array_cb(name, elm_type, -1, dynamic_size, NULL, code) - -gras_error_t -gras_datadesc_declare_array_cb(const char *name, - gras_datadesc_type_t *element_type, - long int fixed_size, - gras_datadesc_type_cb_int_t dynamic_size, - gras_datadesc_type_cb_void_t post, - long int *code); +gras_datadesc_import_nws(const char *name, + const DataDescriptor *desc, + size_t howmany, + gras_datadesc_type_t **dst); END_DECL