From a95e6bf7b637ba63f3d668b005deb91071c00c1a Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 5 Nov 2011 16:18:13 +0100 Subject: [PATCH] Nobody will ever need to override the behavior of config parsing, so simplify the code --- include/surf/surfxml_parse.h | 2 -- src/surf/surf_routing.c | 26 -------------------------- src/surf/surfxml_parse.c | 30 ++++++++++++++++++++---------- 3 files changed, 20 insertions(+), 38 deletions(-) diff --git a/include/surf/surfxml_parse.h b/include/surf/surfxml_parse.h index 63bdca1b1e..ee13b83575 100644 --- a/include/surf/surfxml_parse.h +++ b/include/surf/surfxml_parse.h @@ -48,8 +48,6 @@ XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_cluster_cb_list; XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_cluster_cb_list; XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_peer_cb_list; XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_peer_cb_list; -XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_config_cb_list; -XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_config_cb_list; XBT_PUBLIC_DATA(xbt_dynar_t) STag_surfxml_include_cb_list; XBT_PUBLIC_DATA(xbt_dynar_t) ETag_surfxml_include_cb_list; diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 6acb74e1de..5d6a515f93 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -55,9 +55,6 @@ static void routing_parse_Speer(void); /* peer bypass */ static void routing_parse_Srandom(void); /* random bypass */ static void routing_parse_Erandom(void); /* random bypass */ -static void routing_parse_Sconfig(void); /* config Tag */ -static void routing_parse_Econfig(void); /* config Tag */ - static char* replace_random_parameter(char * chaine); static void clean_routing_after_parse(void); @@ -1007,8 +1004,6 @@ void routing_model_create(size_t size_of_links, void *loopback, double_f_cpvoid_ void surf_parse_add_callback_config(void) { - surfxml_add_callback(STag_surfxml_config_cb_list, &routing_parse_Sconfig); - surfxml_add_callback(ETag_surfxml_config_cb_list, &routing_parse_Econfig); surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties_XML); surfxml_add_callback(STag_surfxml_random_cb_list, &routing_parse_Srandom); } @@ -1474,27 +1469,6 @@ void generic_src_dst_check(routing_component_t rc, const char *src, src,dst,src_as->name, dst_as->name,rc->name); } -static void routing_parse_Sconfig(void) -{ - XBT_DEBUG("START configuration name = %s",A_surfxml_config_id); -} - -static void routing_parse_Econfig(void) -{ - xbt_dict_cursor_t cursor = NULL; - char *key; - char *elem; - char *cfg; - xbt_dict_foreach(current_property_set, cursor, key, elem) { - cfg = bprintf("%s:%s",key,elem); - if(xbt_cfg_is_default_value(_surf_cfg_set, key)) - xbt_cfg_set_parse(_surf_cfg_set, cfg); - else - XBT_INFO("The custom configuration '%s' is already defined by user!",key); - free(cfg); - } - XBT_DEBUG("End configuration name = %s",A_surfxml_config_id); -} static void parse_create_host_link(int i) { diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index c255656ea8..0d952e2380 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -79,8 +79,6 @@ xbt_dynar_t STag_surfxml_ASroute_cb_list = NULL; xbt_dynar_t ETag_surfxml_ASroute_cb_list = NULL; xbt_dynar_t STag_surfxml_bypassRoute_cb_list = NULL; xbt_dynar_t ETag_surfxml_bypassRoute_cb_list = NULL; -xbt_dynar_t STag_surfxml_config_cb_list = NULL; -xbt_dynar_t ETag_surfxml_config_cb_list = NULL; xbt_dynar_t STag_surfxml_include_cb_list = NULL; xbt_dynar_t ETag_surfxml_include_cb_list = NULL; @@ -209,10 +207,6 @@ void surf_parse_init_callbacks(void) xbt_dynar_new(sizeof(void_f_void_t), NULL); ETag_surfxml_peer_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL); - STag_surfxml_config_cb_list = - xbt_dynar_new(sizeof(void_f_void_t), NULL); - ETag_surfxml_config_cb_list = - xbt_dynar_new(sizeof(void_f_void_t), NULL); STag_surfxml_include_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL); ETag_surfxml_include_cb_list = @@ -262,8 +256,6 @@ void surf_parse_free_callbacks(void) xbt_dynar_free(&ETag_surfxml_cluster_cb_list); xbt_dynar_free(&STag_surfxml_peer_cb_list); xbt_dynar_free(&ETag_surfxml_peer_cb_list); - xbt_dynar_free(&STag_surfxml_config_cb_list); - xbt_dynar_free(&ETag_surfxml_config_cb_list); xbt_dynar_free(&STag_surfxml_include_cb_list); xbt_dynar_free(&ETag_surfxml_include_cb_list); } @@ -482,7 +474,26 @@ void STag_surfxml_bypassRoute(void){ surfxml_call_cb_functions(STag_surfxml_bypassRoute_cb_list); } void STag_surfxml_config(void){ - surfxml_call_cb_functions(STag_surfxml_config_cb_list); + XBT_DEBUG("START configuration name = %s",A_surfxml_config_id); + xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)"); + current_property_set = xbt_dict_new(); + +} +void ETag_surfxml_config(void){ + xbt_dict_cursor_t cursor = NULL; + char *key; + char *elem; + char *cfg; + xbt_dict_foreach(current_property_set, cursor, key, elem) { + cfg = bprintf("%s:%s",key,elem); + if(xbt_cfg_is_default_value(_surf_cfg_set, key)) + xbt_cfg_set_parse(_surf_cfg_set, cfg); + else + XBT_INFO("The custom configuration '%s' is already defined by user!",key); + free(cfg); + } + XBT_DEBUG("End configuration name = %s",A_surfxml_config_id); + current_property_set = NULL; } void STag_surfxml_random(void){ surfxml_call_cb_functions(STag_surfxml_random_cb_list); @@ -503,7 +514,6 @@ parse_method(E, random); parse_method(E, AS); parse_method(E, ASroute); parse_method(E, bypassRoute); -parse_method(E, config); /* Open and Close parse file */ -- 2.20.1