Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Now supernovae mode works out of project directory.
[simgrid.git] / src / surf / surfxml_parse.c
index 4135c78..f312e78 100644 (file)
@@ -1,6 +1,5 @@
-/*     $Id$     */
-
-/* Copyright (c) 2004 Arnaud Legrand. All rights reserved.                  */
+/* Copyright (c) 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
+ * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -117,13 +116,13 @@ FILE *surf_file_to_parse = NULL;
 
 static void convert_route_multi_to_routes(void);
 static void parse_route_elem(void);
-static void parse_foreach(void);
+static void parse_Stag_foreach(void);
 static void parse_sets(void);
-static void parse_route_multi_set_endpoints(void);
-static void parse_route_multi_set_route(void);
-static void parse_trace_init(void);
-static void parse_trace_finalize(void);
-static void parse_trace_c_connect(void);
+static void parse_Stag_route_multi(void);
+static void parse_Etag_route_multi(void);
+static void parse_Stag_trace(void);
+static void parse_Etag_trace(void);
+static void parse_Stag_trace_c_connect(void);
 static void init_randomness(void);
 static void add_randomness(void);
 
@@ -553,14 +552,14 @@ static void init_data(void)
                        &parse_route_set_endpoints);
   surfxml_add_callback(STag_surfxml_set_cb_list, &parse_sets);
   surfxml_add_callback(STag_surfxml_route_c_multi_cb_list,
-                       &parse_route_multi_set_endpoints);
+                       &parse_Stag_route_multi);
   surfxml_add_callback(ETag_surfxml_route_c_multi_cb_list,
-                       &parse_route_multi_set_route);
-  surfxml_add_callback(STag_surfxml_foreach_cb_list, &parse_foreach);
-  surfxml_add_callback(STag_surfxml_trace_cb_list, &parse_trace_init);
-  surfxml_add_callback(ETag_surfxml_trace_cb_list, &parse_trace_finalize);
+                       &parse_Etag_route_multi);
+  surfxml_add_callback(STag_surfxml_foreach_cb_list, &parse_Stag_foreach);
+  surfxml_add_callback(STag_surfxml_trace_cb_list, &parse_Stag_trace);
+  surfxml_add_callback(ETag_surfxml_trace_cb_list, &parse_Etag_trace);
   surfxml_add_callback(STag_surfxml_trace_c_connect_cb_list,
-                       &parse_trace_c_connect);
+                       &parse_Stag_trace_c_connect);
   surfxml_add_callback(STag_surfxml_random_cb_list, &init_randomness);
   surfxml_add_callback(ETag_surfxml_random_cb_list, &add_randomness);
 }
@@ -802,7 +801,7 @@ static void parse_link_foreach(void) {
   foreach_set_name = NULL;
 }
 
-static void parse_foreach(void)
+static void parse_Stag_foreach(void)
 {
   /* save the host & link callbacks */
   main_STag_surfxml_host_cb_list = STag_surfxml_host_cb_list;
@@ -832,9 +831,10 @@ static void parse_route_elem(void)
   val = xbt_strdup(A_surfxml_link_c_ctn_id);
 
   xbt_dynar_push(route_link_list, &val);
+  //INFO2("Push %s (size now:%ld)",val,xbt_dynar_length(route_link_list));
 }
 
-static void parse_route_multi_set_endpoints(void)
+static void parse_Stag_route_multi(void)
 {
   src_name = xbt_strdup(A_surfxml_route_c_multi_src);
   dst_name = xbt_strdup(A_surfxml_route_c_multi_dst);
@@ -845,17 +845,6 @@ static void parse_route_multi_set_endpoints(void)
   route_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
 }
 
-static int contains(xbt_dynar_t list, const char *value)
-{
-  unsigned int cpt;
-  char *val;
-  xbt_dynar_foreach(list, cpt, val) {
-    if (strcmp(val, value) == 0)
-      return 1;
-  }
-  return 0;
-}
-
 /*
    This function is used to append or override the contents of an already existing route in the case a new one with its name is found.
    The decision is based upon the value of action specified in the xml route:multi attribute action
@@ -869,7 +858,11 @@ void manage_route(xbt_dict_t routing_table, const char *route_name,
 
   /* get already existing list if it exists */
   links = xbt_dict_get_or_null(routing_table, route_name);
-  DEBUG1("ROUTE: %s", route_name);
+  DEBUG3("ROUTE: %s (action:%s; len:%ld)", route_name,
+      (action==A_surfxml_route_action_OVERRIDE?"override":(
+          action==A_surfxml_route_action_PREPEND?"prepend":"postpend")),
+       (links?xbt_dynar_length(links):0));
+
   if (links != NULL) {
     switch (action) {
     case A_surfxml_route_action_PREPEND:       /* add existing links at the end; route_link_list + links */
@@ -889,6 +882,8 @@ void manage_route(xbt_dict_t routing_table, const char *route_name,
       xbt_dynar_free(&links);
       break;
     default:
+      xbt_die(bprintf("While dealing with routes of %s, got action=%d. Please report this bug.",
+          route_name,action));
       break;
     }
   }
@@ -898,7 +893,7 @@ void manage_route(xbt_dict_t routing_table, const char *route_name,
   }
 }
 
-static void parse_route_multi_set_route(void)
+static void parse_Etag_route_multi(void)
 {
   char *route_name;
 
@@ -1050,19 +1045,17 @@ static void convert_route_multi_to_routes(void)
 /* Trace management functions */
 
 static double trace_periodicity = -1.0;
-static double trace_timestep = -1.0;
 static char *trace_file = NULL;
 static char *trace_id;
 
-static void parse_trace_init(void)
+static void parse_Stag_trace(void)
 {
   trace_id = strdup(A_surfxml_trace_id);
   trace_file = strdup(A_surfxml_trace_file);
   surf_parse_get_double(&trace_periodicity, A_surfxml_trace_periodicity);
-  surf_parse_get_double(&trace_timestep, A_surfxml_trace_timestep);
 }
 
-static void parse_trace_finalize(void)
+static void parse_Etag_trace(void)
 {
   tmgr_trace_t trace;
   if (!trace_file || strcmp(trace_file, "") != 0) {
@@ -1073,12 +1066,12 @@ static void parse_trace_finalize(void)
     else
       trace =
         tmgr_trace_new_from_string(trace_id, surfxml_pcdata,
-                                   trace_periodicity, trace_timestep);
+                                   trace_periodicity);
   }
   xbt_dict_set(traces_set_list, trace_id, (void *) trace, NULL);
 }
 
-static void parse_trace_c_connect(void)
+static void parse_Stag_trace_c_connect(void)
 {
   xbt_assert2(xbt_dict_get_or_null
               (traces_set_list, A_surfxml_trace_c_connect_trace),