Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
further code simplification. This one were nasty
[simgrid.git] / src / surf / surfxml_parse.c
index 1f110ec..80148b2 100644 (file)
@@ -301,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);
 }
@@ -377,28 +377,36 @@ void STag_surfxml_link(void){
   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.V_link_id = A_surfxml_link_id;
-       link.V_link_bandwidth = surf_parse_get_double(A_surfxml_link_bandwidth);
-       link.V_link_bandwidth_file = tmgr_trace_new(A_surfxml_link_bandwidth_file);
-       link.V_link_latency = surf_parse_get_double(A_surfxml_link_latency);
-       link.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)
-               link.V_link_state = SURF_RESOURCE_ON;
-       if (A_surfxml_link_state == A_surfxml_link_state_OFF)
-               link.V_link_state = SURF_RESOURCE_OFF;
-       link.V_link_state_file = tmgr_trace_new(A_surfxml_link_state_file);
-       link.V_link_sharing_policy = A_surfxml_link_sharing_policy;
-
-       if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_SHARED)
-               link.V_policy_initial_link = SURF_LINK_SHARED;
-       else
-       {
-        if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_FATPIPE)
-                link.V_policy_initial_link = SURF_LINK_FATPIPE;
-        else if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_FULLDUPLEX)
-                link.V_policy_initial_link = SURF_LINK_FULLDUPLEX;
+       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));
        }
 
        sg_platf_new_link(&link);