X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7e082217ec28452a0f8fdb0207d8792f0b0932dc..c215f8139368ac8b172ad664c05d4f2b4211a961:/src/surf/surfxml_parse.c diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 3ec0d35449..b9fc03b2d1 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -69,6 +69,13 @@ int surf_parse_get_int(const char *string) { /* The default current property receiver. Setup in the corresponding opening callbacks. */ xbt_dict_t current_property_set = NULL; +xbt_dict_t as_current_property_set = NULL; +int AS_TAG = 0; +char* as_name_tab[1024]; +void* as_dict_tab[1024]; +int as_prop_nb = 0; + + /* dictionary of random generator data */ xbt_dict_t random_data_list = NULL; @@ -83,7 +90,9 @@ static void add_randomness(void); */ void STag_surfxml_storage(void) { + AS_TAG = 0; XBT_DEBUG("STag_surfxml_storage"); + xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)"); } void ETag_surfxml_storage(void) { @@ -93,10 +102,13 @@ void ETag_surfxml_storage(void) storage.id = A_surfxml_storage_id; storage.type_id = A_surfxml_storage_typeId; storage.content = A_surfxml_storage_content; + storage.properties = current_property_set; sg_platf_new_storage(&storage); + current_property_set = NULL; } void STag_surfxml_storage_type(void) { + AS_TAG = 0; XBT_DEBUG("STag_surfxml_storage_type"); xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)"); } @@ -251,15 +263,28 @@ void ETag_surfxml_platform(void){ } void STag_surfxml_host(void){ + AS_TAG = 0; xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)"); } void STag_surfxml_prop(void) { - if (!current_property_set) - current_property_set = xbt_dict_new_homogeneous(xbt_free_f); // Maybe, it should raise an error - - xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), NULL); + if(AS_TAG){ + if (!as_current_property_set){ + xbt_assert(as_prop_nb < 1024, "Number of AS property reach the limit!!!"); + as_current_property_set = xbt_dict_new_homogeneous(xbt_free_f); // Maybe, it should raise an error + as_name_tab[as_prop_nb] = xbt_strdup(A_surfxml_AS_id); + as_dict_tab[as_prop_nb] = as_current_property_set; + XBT_DEBUG("PUSH prop %p for AS '%s'",as_dict_tab[as_prop_nb],as_name_tab[as_prop_nb]); + as_prop_nb++; + } + xbt_dict_set(as_current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), NULL); + } + else{ + if (!current_property_set) + current_property_set = xbt_dict_new_homogeneous(xbt_free_f); // Maybe, it should raise an error + xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), NULL); + } } void ETag_surfxml_host(void) { @@ -387,6 +412,7 @@ void STag_surfxml_peer(void){ } void STag_surfxml_link(void){ + AS_TAG = 0; xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)"); } @@ -470,7 +496,6 @@ void ETag_surfxml_backbone(void){ sg_platf_new_link(&link); routing_cluster_add_backbone(xbt_lib_get_or_null(link_lib, A_surfxml_backbone_id, SURF_LINK_LEVEL)); - current_property_set = NULL; } void STag_surfxml_route(void){ @@ -645,20 +670,34 @@ void STag_surfxml_trace_connect(void){ } void STag_surfxml_AS(void){ - xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)"); + AS_TAG = 1; s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER; AS.id = A_surfxml_AS_id; AS.routing = (int)A_surfxml_AS_routing; + as_current_property_set = NULL; + sg_platf_new_AS_begin(&AS); } void ETag_surfxml_AS(void){ + if(as_prop_nb){ + char *name = as_name_tab[as_prop_nb-1]; + xbt_dict_t dict = as_dict_tab[as_prop_nb-1]; + as_prop_nb--; + XBT_DEBUG("POP prop %p for AS '%s'",dict,name); + xbt_lib_set(as_router_lib, + name, + ROUTING_PROP_ASR_LEVEL, + dict); + xbt_free(name); + } sg_platf_new_AS_end(); } void STag_surfxml_config(void){ - XBT_DEBUG("START configuration name = %s",A_surfxml_config_id); + AS_TAG = 0; xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)"); + XBT_DEBUG("START configuration name = %s",A_surfxml_config_id); } void ETag_surfxml_config(void){ xbt_dict_cursor_t cursor = NULL; @@ -675,15 +714,18 @@ void ETag_surfxml_config(void){ } XBT_DEBUG("End configuration name = %s",A_surfxml_config_id); xbt_dict_free(¤t_property_set); + current_property_set = NULL; } static int argc; static char **argv; void STag_surfxml_process(void){ + AS_TAG = 0; argc = 1; argv = xbt_new(char *, 1); argv[0] = xbt_strdup(A_surfxml_process_function); + xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)"); } void ETag_surfxml_process(void){ @@ -859,3 +901,9 @@ static void add_randomness(void) &xbt_free_ref); } + +xbt_dict_t get_as_router_properties(const char* name) +{ + return xbt_lib_get_or_null(as_router_lib, name, ROUTING_PROP_ASR_LEVEL); +} +