Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
CleanUp unused xbt_dynar_t from callback
[simgrid.git] / src / surf / surfxml_parse.c
index 8a1c8d0..e2a0e4c 100644 (file)
@@ -64,41 +64,16 @@ 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_route_cb_list = NULL;
-xbt_dynar_t ETag_surfxml_route_cb_list = NULL;
-xbt_dynar_t STag_surfxml_link_ctn_cb_list = NULL;
-xbt_dynar_t ETag_surfxml_link_ctn_cb_list = NULL;
 xbt_dynar_t STag_surfxml_process_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_process_cb_list = NULL;
 xbt_dynar_t STag_surfxml_argument_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_argument_cb_list = NULL;
 xbt_dynar_t STag_surfxml_prop_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_prop_cb_list = NULL;
-xbt_dynar_t STag_surfxml_peer_cb_list = NULL;
-xbt_dynar_t ETag_surfxml_peer_cb_list = NULL;
 xbt_dynar_t STag_surfxml_trace_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_trace_cb_list = NULL;
 xbt_dynar_t STag_surfxml_trace_connect_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_trace_connect_cb_list = NULL;
-xbt_dynar_t STag_surfxml_random_cb_list = NULL;
-xbt_dynar_t ETag_surfxml_random_cb_list = NULL;
-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_bypassASroute_cb_list = NULL;
-xbt_dynar_t ETag_surfxml_bypassASroute_cb_list = NULL;
-xbt_dynar_t STag_surfxml_include_cb_list = NULL;
-xbt_dynar_t ETag_surfxml_include_cb_list = NULL;
-
-xbt_dynar_t STag_surfxml_storage_cb_list = NULL;
-xbt_dynar_t ETag_surfxml_storage_cb_list = NULL;
-xbt_dynar_t STag_surfxml_storage_type_cb_list = NULL;
-xbt_dynar_t ETag_surfxml_storage_type_cb_list = NULL;
-xbt_dynar_t STag_surfxml_mount_cb_list = NULL;
-xbt_dynar_t ETag_surfxml_mount_cb_list = NULL;
-xbt_dynar_t STag_surfxml_mstorage_cb_list = NULL;
-xbt_dynar_t ETag_surfxml_mstorage_cb_list = NULL;
 
 /* The default current property receiver. Setup in the corresponding opening callbacks. */
 xbt_dict_t current_property_set = NULL;
@@ -242,13 +217,6 @@ int ETag_surfxml_include_state(void)
 void surf_parse_init_callbacks(void)
 {
     sg_platf_init(); // FIXME: move to a proper place?
-
-    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 =
-        xbt_dynar_new(sizeof(void_f_void_t), NULL);
-    ETag_surfxml_link_ctn_cb_list =
-        xbt_dynar_new(sizeof(void_f_void_t), NULL);
     STag_surfxml_process_cb_list =
         xbt_dynar_new(sizeof(void_f_void_t), NULL);
     ETag_surfxml_process_cb_list =
@@ -265,37 +233,6 @@ void surf_parse_init_callbacks(void)
         xbt_dynar_new(sizeof(void_f_void_t), NULL);
     ETag_surfxml_trace_connect_cb_list =
         xbt_dynar_new(sizeof(void_f_void_t), NULL);
-    STag_surfxml_random_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-    ETag_surfxml_random_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-    STag_surfxml_ASroute_cb_list =
-        xbt_dynar_new(sizeof(void_f_void_t), NULL);
-    ETag_surfxml_ASroute_cb_list =
-        xbt_dynar_new(sizeof(void_f_void_t), NULL);
-    STag_surfxml_bypassRoute_cb_list =
-        xbt_dynar_new(sizeof(void_f_void_t), NULL);
-    ETag_surfxml_bypassRoute_cb_list =
-        xbt_dynar_new(sizeof(void_f_void_t), NULL);
-      STag_surfxml_bypassASroute_cb_list =
-          xbt_dynar_new(sizeof(void_f_void_t), NULL);
-      ETag_surfxml_bypassASroute_cb_list =
-          xbt_dynar_new(sizeof(void_f_void_t), NULL);
-    STag_surfxml_peer_cb_list =
-        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_include_cb_list =
-        xbt_dynar_new(sizeof(void_f_void_t), NULL);
-    ETag_surfxml_include_cb_list =
-        xbt_dynar_new(sizeof(void_f_void_t), NULL);
-
-    STag_surfxml_storage_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-    ETag_surfxml_storage_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-      STag_surfxml_storage_type_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-      ETag_surfxml_storage_type_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-      STag_surfxml_mount_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-      ETag_surfxml_mount_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-      STag_surfxml_mstorage_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-      ETag_surfxml_mstorage_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
 }
 
 void surf_parse_reset_callbacks(void)
@@ -308,10 +245,6 @@ void surf_parse_free_callbacks(void)
 {
   sg_platf_exit(); // FIXME: better place?
 
-  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);
-  xbt_dynar_free(&ETag_surfxml_link_ctn_cb_list);
   xbt_dynar_free(&STag_surfxml_process_cb_list);
   xbt_dynar_free(&ETag_surfxml_process_cb_list);
   xbt_dynar_free(&STag_surfxml_argument_cb_list);
@@ -322,27 +255,6 @@ void surf_parse_free_callbacks(void)
   xbt_dynar_free(&ETag_surfxml_trace_cb_list);
   xbt_dynar_free(&STag_surfxml_trace_connect_cb_list);
   xbt_dynar_free(&ETag_surfxml_trace_connect_cb_list);
-  xbt_dynar_free(&STag_surfxml_random_cb_list);
-  xbt_dynar_free(&ETag_surfxml_random_cb_list);
-  xbt_dynar_free(&STag_surfxml_ASroute_cb_list);
-  xbt_dynar_free(&ETag_surfxml_ASroute_cb_list);
-  xbt_dynar_free(&STag_surfxml_bypassRoute_cb_list);
-  xbt_dynar_free(&ETag_surfxml_bypassRoute_cb_list);
-  xbt_dynar_free(&STag_surfxml_bypassASroute_cb_list);
-  xbt_dynar_free(&ETag_surfxml_bypassASroute_cb_list);
-  xbt_dynar_free(&STag_surfxml_peer_cb_list);
-  xbt_dynar_free(&ETag_surfxml_peer_cb_list);
-  xbt_dynar_free(&STag_surfxml_include_cb_list);
-  xbt_dynar_free(&ETag_surfxml_include_cb_list);
-
-  xbt_dynar_free(&STag_surfxml_storage_cb_list);
-  xbt_dynar_free(&ETag_surfxml_storage_cb_list);
-  xbt_dynar_free(&STag_surfxml_mstorage_cb_list);
-  xbt_dynar_free(&ETag_surfxml_mstorage_cb_list);
-  xbt_dynar_free(&STag_surfxml_mount_cb_list);
-  xbt_dynar_free(&ETag_surfxml_mount_cb_list);
-  xbt_dynar_free(&STag_surfxml_storage_type_cb_list);
-  xbt_dynar_free(&ETag_surfxml_storage_type_cb_list);
 }
 
 /* Stag and Etag parse functions */
@@ -406,7 +318,7 @@ void ETag_surfxml_host(void)    {
 }
 
 void STag_surfxml_host_link(void){
-  XBT_INFO("Create a Host_link for %s",A_surfxml_host_link_id);
+  XBT_DEBUG("Create a Host_link for %s",A_surfxml_host_link_id);
   s_sg_platf_host_link_cbarg_t host_link;
   memset(&host_link,0,sizeof(host_link));
 
@@ -417,7 +329,7 @@ void STag_surfxml_host_link(void){
 }
 
 void ETag_surfxml_host_link(void){
-  XBT_INFO("End create a Host_link for %s",A_surfxml_host_link_id);
+  XBT_DEBUG("End create a Host_link for %s",A_surfxml_host_link_id);
 }
 
 void STag_surfxml_router(void){
@@ -483,6 +395,23 @@ void ETag_surfxml_cluster(void){
   /* nothing I can think of */
 }
 
+void STag_surfxml_cabinet(void){
+  s_sg_platf_cabinet_cbarg_t cabinet;
+  memset(&cabinet,0,sizeof(cabinet));
+  cabinet.id = A_surfxml_cabinet_id;
+  cabinet.prefix = A_surfxml_cabinet_prefix;
+  cabinet.suffix = A_surfxml_cabinet_suffix;
+  cabinet.power = surf_parse_get_double(A_surfxml_cabinet_power);
+  cabinet.bw = surf_parse_get_double(A_surfxml_cabinet_bw);
+  cabinet.lat = surf_parse_get_double(A_surfxml_cabinet_lat);
+  cabinet.radical = A_surfxml_cabinet_radical;
+
+  sg_platf_new_cabinet(&cabinet);
+}
+void ETag_surfxml_cabinet(void){
+  /* nothing I can think of */
+}
+
 void STag_surfxml_peer(void){
   s_sg_platf_peer_cbarg_t peer;
   memset(&peer,0,sizeof(peer));
@@ -495,7 +424,6 @@ void STag_surfxml_peer(void){
   peer.availability_trace = tmgr_trace_new_from_file(A_surfxml_peer_availability_file);
   peer.state_trace = tmgr_trace_new_from_file(A_surfxml_peer_state_file);
 
-  surfxml_call_cb_functions(STag_surfxml_peer_cb_list);
   sg_platf_new_peer(&peer);
 }
 void ETag_surfxml_peer(void){
@@ -554,6 +482,31 @@ void ETag_surfxml_link(void){
   current_property_set = NULL;
 }
 
+void STag_surfxml_link_ctn(void){
+  s_sg_platf_linkctn_cbarg_t linkctn;
+  memset(&linkctn,0,sizeof(linkctn));
+
+  linkctn.id = A_surfxml_link_ctn_id;
+
+  switch (A_surfxml_link_ctn_direction) {
+  case AU_surfxml_link_ctn_direction:
+  case A_surfxml_link_ctn_direction_NONE:
+    linkctn.direction = SURF_LINK_DIRECTION_NONE;
+    break;
+  case A_surfxml_link_ctn_direction_UP:
+    linkctn.direction = SURF_LINK_DIRECTION_UP;
+    break;
+  case A_surfxml_link_ctn_direction_DOWN:
+    linkctn.direction = SURF_LINK_DIRECTION_DOWN;
+    break;
+  }
+  sg_platf_new_linkctn(&linkctn);
+
+}
+
+void ETag_surfxml_link_ctn(void){
+ // NOTHING TO DO
+}
 void ETag_surfxml_backbone(void){
   s_sg_platf_link_cbarg_t link;
   memset(&link,0,sizeof(link));
@@ -572,11 +525,94 @@ void ETag_surfxml_backbone(void){
 }
 
 void STag_surfxml_route(void){
-  surfxml_call_cb_functions(STag_surfxml_route_cb_list);
+  xbt_assert(strlen(A_surfxml_route_src) > 0 || strlen(A_surfxml_route_dst) > 0,
+      "Missing end-points while defining route \"%s\"->\"%s\"",
+      A_surfxml_route_src, A_surfxml_route_dst);
 }
-void STag_surfxml_link_ctn(void){
-  surfxml_call_cb_functions(STag_surfxml_link_ctn_cb_list);
+void STag_surfxml_ASroute(void){
+  xbt_assert(strlen(A_surfxml_ASroute_src) > 0 || strlen(A_surfxml_ASroute_dst) > 0
+      || strlen(A_surfxml_ASroute_gw_src) > 0 || strlen(A_surfxml_ASroute_gw_dst) > 0,
+      "Missing end-points while defining route \"%s\"->\"%s\" (with %s and %s as gateways)",
+      A_surfxml_ASroute_src, A_surfxml_ASroute_dst,
+      A_surfxml_ASroute_gw_src,A_surfxml_ASroute_gw_dst);
+}
+void STag_surfxml_bypassRoute(void){
+  xbt_assert(strlen(A_surfxml_bypassRoute_src) > 0 || strlen(A_surfxml_bypassRoute_dst) > 0,
+      "Missing end-points while defining bupass route \"%s\"->\"%s\"",
+      A_surfxml_bypassRoute_src, A_surfxml_bypassRoute_dst);
+}
+void STag_surfxml_bypassASroute(void){
+  xbt_assert(strlen(A_surfxml_bypassASroute_src) > 0 || strlen(A_surfxml_bypassASroute_dst) > 0
+      || strlen(A_surfxml_bypassASroute_gw_src) > 0 || strlen(A_surfxml_bypassASroute_gw_dst) > 0,
+      "Missing end-points while defining route \"%s\"->\"%s\" (with %s and %s as gateways)",
+      A_surfxml_bypassASroute_src, A_surfxml_bypassASroute_dst,
+      A_surfxml_bypassASroute_gw_src,A_surfxml_bypassASroute_gw_dst);
 }
+
+void ETag_surfxml_route(void){
+  s_sg_platf_route_cbarg_t route;
+  memset(&route,0,sizeof(route));
+
+  route.src = A_surfxml_route_src;
+  route.dst = A_surfxml_route_dst;
+
+  switch (A_surfxml_route_symmetrical) {
+  case AU_surfxml_route_symmetrical:
+  case A_surfxml_route_symmetrical_YES:
+    route.symmetrical = TRUE;
+    break;
+  case A_surfxml_route_symmetrical_NO:
+    route.symmetrical = FALSE;;
+    break;
+  }
+
+  sg_platf_new_route(&route);
+}
+
+void ETag_surfxml_ASroute(void){
+  s_sg_platf_ASroute_cbarg_t ASroute;
+  memset(&ASroute,0,sizeof(ASroute));
+
+  ASroute.src = A_surfxml_ASroute_src;
+  ASroute.dst = A_surfxml_ASroute_dst;
+  ASroute.gw_src = A_surfxml_ASroute_gw_src;
+  ASroute.gw_dst = A_surfxml_ASroute_gw_dst;
+
+  switch (A_surfxml_ASroute_symmetrical) {
+  case AU_surfxml_ASroute_symmetrical:
+  case A_surfxml_ASroute_symmetrical_YES:
+    ASroute.symmetrical = TRUE;
+    break;
+  case A_surfxml_ASroute_symmetrical_NO:
+    ASroute.symmetrical = FALSE;;
+    break;
+  }
+
+  sg_platf_new_ASroute(&ASroute);
+}
+
+void ETag_surfxml_bypassRoute(void){
+  s_sg_platf_bypassRoute_cbarg_t route;
+  memset(&route,0,sizeof(route));
+
+  route.src = A_surfxml_bypassRoute_src;
+  route.dst = A_surfxml_bypassRoute_dst;
+
+  sg_platf_new_bypassRoute(&route);
+}
+
+void ETag_surfxml_bypassASroute(void){
+  s_sg_platf_bypassASroute_cbarg_t ASroute;
+  memset(&ASroute,0,sizeof(ASroute));
+
+  ASroute.src = A_surfxml_bypassASroute_src;
+  ASroute.dst = A_surfxml_bypassASroute_dst;
+  ASroute.gw_src = A_surfxml_bypassASroute_gw_src;
+  ASroute.gw_dst = A_surfxml_bypassASroute_gw_dst;
+
+  sg_platf_new_bypassASroute(&ASroute);
+}
+
 void STag_surfxml_process(void){
   surfxml_call_cb_functions(STag_surfxml_process_cb_list);
 }
@@ -598,15 +634,7 @@ void STag_surfxml_AS(void){
 void ETag_surfxml_AS(void){
   sg_platf_new_AS_end();
 }
-void STag_surfxml_ASroute(void){
-  surfxml_call_cb_functions(STag_surfxml_ASroute_cb_list);
-}
-void STag_surfxml_bypassRoute(void){
-  surfxml_call_cb_functions(STag_surfxml_bypassRoute_cb_list);
-}
-void STag_surfxml_bypassASroute(void){
-  surfxml_call_cb_functions(STag_surfxml_bypassASroute_cb_list);
-}
+
 void STag_surfxml_config(void){
   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)");
@@ -628,7 +656,10 @@ void ETag_surfxml_config(void){
   xbt_dict_free(&current_property_set);
 }
 void STag_surfxml_random(void){
-  surfxml_call_cb_functions(STag_surfxml_random_cb_list);
+//TODO
+}
+void ETag_surfxml_random(void){
+//TODO
 }
 
 #define parse_method(type,name)                                         \
@@ -636,17 +667,11 @@ void STag_surfxml_random(void){
   { surfxml_call_cb_functions(type##Tag_surfxml_##name##_cb_list); }    \
   void type##Tag_surfxml_##name(void)
 
-parse_method(E, route);
-parse_method(E, link_ctn);
 parse_method(E, process);
 parse_method(E, argument);
 parse_method(E, prop);
 parse_method(E, trace);
 parse_method(E, trace_connect);
-parse_method(E, random);
-parse_method(E, ASroute);
-parse_method(E, bypassRoute);
-parse_method(E, bypassASroute);
 
 /* Open and Close parse file */