X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7329497f42d918f8bac62146274854ef8c199681..46e0cb17f365814060eccbd32af103d1b41ae34b:/src/surf/surfxml_parse.c diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 9760b4ec08..80148b2894 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -21,7 +21,7 @@ int ETag_surfxml_include_state(void); /* * Helping functions */ -static void surf_parse_error(char *msg) { +void surf_parse_error(char *msg) { xbt_die("Parse error on line %d: %s\n", surf_parse_lineno, msg); } @@ -48,9 +48,6 @@ int surf_parse_get_int(const char *string) { */ /* make sure these symbols are defined as strong ones in this file so that the linker can resolve them */ -//xbt_dynar_t STag_surfxml_host_cb_list = NULL; -xbt_dynar_t STag_surfxml_link_cb_list = NULL; -xbt_dynar_t ETag_surfxml_link_cb_list = NULL; xbt_dynar_t STag_surfxml_route_cb_list = NULL; xbt_dynar_t ETag_surfxml_route_cb_list = NULL; xbt_dynar_t STag_surfxml_link_ctn_cb_list = NULL; @@ -153,8 +150,6 @@ void surf_parse_init_callbacks(void) { sg_platf_init(); // FIXME: move to a proper place? - STag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL); - ETag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL); STag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL); ETag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL); STag_surfxml_link_ctn_cb_list = @@ -213,8 +208,6 @@ void surf_parse_free_callbacks(void) { sg_platf_exit(); // FIXME: better place? - xbt_dynar_free(&STag_surfxml_link_cb_list); - xbt_dynar_free(&ETag_surfxml_link_cb_list); xbt_dynar_free(&STag_surfxml_route_cb_list); xbt_dynar_free(&ETag_surfxml_route_cb_list); xbt_dynar_free(&STag_surfxml_link_ctn_cb_list); @@ -284,19 +277,19 @@ void STag_surfxml_host(void){ xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)"); host.properties = current_property_set = xbt_dict_new(); - host.V_host_id = A_surfxml_host_id; - host.V_host_power_peak = get_cpu_power(A_surfxml_host_power); - host.V_host_power_scale = surf_parse_get_double( A_surfxml_host_availability); - host.V_host_core = surf_parse_get_int(A_surfxml_host_core); - host.V_host_power_trace = tmgr_trace_new(A_surfxml_host_availability_file); - host.V_host_state_trace = tmgr_trace_new(A_surfxml_host_state_file); + host.id = A_surfxml_host_id; + host.power_peak = get_cpu_power(A_surfxml_host_power); + host.power_scale = surf_parse_get_double( A_surfxml_host_availability); + host.core_amount = surf_parse_get_int(A_surfxml_host_core); + host.power_trace = tmgr_trace_new(A_surfxml_host_availability_file); + host.state_trace = tmgr_trace_new(A_surfxml_host_state_file); xbt_assert((A_surfxml_host_state == A_surfxml_host_state_ON) || (A_surfxml_host_state == A_surfxml_host_state_OFF), "Invalid state"); if (A_surfxml_host_state == A_surfxml_host_state_ON) - host.V_host_state_initial = SURF_RESOURCE_ON; + host.initial_state = SURF_RESOURCE_ON; if (A_surfxml_host_state == A_surfxml_host_state_OFF) - host.V_host_state_initial = SURF_RESOURCE_OFF; - host.V_host_coord = A_surfxml_host_coordinates; + host.initial_state = SURF_RESOURCE_OFF; + host.coord = A_surfxml_host_coordinates; sg_platf_new_host(&host); } @@ -308,8 +301,8 @@ void STag_surfxml_router(void){ s_sg_platf_router_cbarg_t router; memset(&router, 0, sizeof(router)); - router.V_router_id = A_surfxml_router_id; - router.V_router_coord = A_surfxml_router_coordinates; + router.id = A_surfxml_router_id; + router.coord = A_surfxml_router_coordinates; sg_platf_new_router(&router); } @@ -378,39 +371,48 @@ void ETag_surfxml_peer(void){ xbt_free(struct_peer); } void STag_surfxml_link(void){ - struct_lnk = xbt_new0(s_surf_parsing_link_arg_t, 1); - struct_lnk->V_link_id = A_surfxml_link_id; - struct_lnk->V_link_bandwidth = surf_parse_get_double(A_surfxml_link_bandwidth); - struct_lnk->V_link_bandwidth_file = tmgr_trace_new(A_surfxml_link_bandwidth_file); - struct_lnk->V_link_latency = surf_parse_get_double(A_surfxml_link_latency); - struct_lnk->V_link_latency_file = tmgr_trace_new(A_surfxml_link_latency_file); - xbt_assert((A_surfxml_link_state == A_surfxml_link_state_ON) || - (A_surfxml_link_state == A_surfxml_link_state_OFF), "Invalid state"); - if (A_surfxml_link_state == A_surfxml_link_state_ON) - struct_lnk->V_link_state = SURF_RESOURCE_ON; - if (A_surfxml_link_state == A_surfxml_link_state_OFF) - struct_lnk->V_link_state = SURF_RESOURCE_OFF; - struct_lnk->V_link_state_file = tmgr_trace_new(A_surfxml_link_state_file); - struct_lnk->V_link_sharing_policy = A_surfxml_link_sharing_policy; - - if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_SHARED) - struct_lnk->V_policy_initial_link = SURF_LINK_SHARED; - else - { - if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_FATPIPE) - struct_lnk->V_policy_initial_link = SURF_LINK_FATPIPE; - else if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_FULLDUPLEX) - struct_lnk->V_policy_initial_link = SURF_LINK_FULLDUPLEX; + s_sg_platf_link_cbarg_t link; + memset(&link,0,sizeof(link)); + + xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)"); + link.properties = current_property_set = xbt_dict_new(); + + link.id = A_surfxml_link_id; + link.bandwidth = surf_parse_get_double(A_surfxml_link_bandwidth); + link.bandwidth_trace = tmgr_trace_new(A_surfxml_link_bandwidth_file); + link.latency = surf_parse_get_double(A_surfxml_link_latency); + link.latency_trace = tmgr_trace_new(A_surfxml_link_latency_file); + + switch (A_surfxml_link_state) { + case A_surfxml_link_state_ON: + link.state = SURF_RESOURCE_ON; + break; + case A_surfxml_link_state_OFF: + link.state = SURF_RESOURCE_OFF; + break; + default: + surf_parse_error(bprintf("invalid state for link %s",link.id)); + } + link.state_trace = tmgr_trace_new(A_surfxml_link_state_file); + + switch (A_surfxml_link_sharing_policy) { + case A_surfxml_link_sharing_policy_SHARED: + link.policy = SURF_LINK_SHARED; + break; + case A_surfxml_link_sharing_policy_FATPIPE: + link.policy = SURF_LINK_FATPIPE; + break; + case A_surfxml_link_sharing_policy_FULLDUPLEX: + link.policy = SURF_LINK_FULLDUPLEX; + break; + default: + surf_parse_error(bprintf("Invalid sharing policy in link %s",link.id)); } - surf_parse_link(); -} -void surf_parse_link(void){ - surfxml_call_cb_functions(STag_surfxml_link_cb_list); + sg_platf_new_link(&link); } void ETag_surfxml_link(void){ - surfxml_call_cb_functions(ETag_surfxml_link_cb_list); - xbt_free(struct_lnk); + current_property_set = NULL; } void STag_surfxml_route(void){ @@ -734,14 +736,6 @@ void* surf_wsL07_link_create_resource(char *name, properties); } -/* - * add host to the network element list - */ -void surf_route_add_host(const char *host_id) -{ - routing_add_host(host_id); -} - /** * set route */