Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Refactoring instr
[simgrid.git] / src / surf / instr_routing.cpp
index 50f60c2..ecbacce 100644 (file)
@@ -145,9 +145,8 @@ static void recursiveGraphExtraction(simgrid::s4u::NetZone* netzone, container_t
 
   static_cast<simgrid::kernel::routing::NetZoneImpl*>(netzone)->getGraph(graph, nodes, edges);
   xbt_dict_foreach(edges,cursor,edge_name,edge) {
-    linkContainers(
-          PJ_container_get(static_cast<const char*>(edge->src->data)),
-          PJ_container_get(static_cast<const char*>(edge->dst->data)), filter);
+    linkContainers(simgrid::instr::Container::byName(static_cast<const char*>(edge->src->data)),
+                   simgrid::instr::Container::byName(static_cast<const char*>(edge->dst->data)), filter);
   }
   xbt_dict_free (&nodes);
   xbt_dict_free (&edges);
@@ -209,10 +208,10 @@ static void instr_routing_parse_start_link(simgrid::s4u::Link& link)
   if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_link())) {
     simgrid::instr::Type* bandwidth = container->type_->getChildOrNull("bandwidth");
     if (bandwidth == nullptr)
-      bandwidth = simgrid::instr::Type::variableNew("bandwidth", nullptr, container->type_);
+      bandwidth                   = simgrid::instr::Type::variableNew("bandwidth", "", container->type_);
     simgrid::instr::Type* latency = container->type_->getChildOrNull("latency");
     if (latency == nullptr)
-      latency = simgrid::instr::Type::variableNew("latency", nullptr, container->type_);
+      latency = simgrid::instr::Type::variableNew("latency", "", container->type_);
     new simgrid::instr::SetVariableEvent(0, container, bandwidth, bandwidth_value);
     new simgrid::instr::SetVariableEvent(0, container, latency, latency_value);
   }
@@ -231,7 +230,7 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
   if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_speed())) {
     simgrid::instr::Type* speed = container->type_->getChildOrNull("power");
     if (speed == nullptr){
-      speed = simgrid::instr::Type::variableNew("power", nullptr, container->type_);
+      speed = simgrid::instr::Type::variableNew("power", "", container->type_);
     }
 
     double current_speed_state = host.getSpeed();
@@ -257,11 +256,11 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
     if (msg_process == nullptr){
       msg_process                 = simgrid::instr::Type::containerNew("MSG_PROCESS", container->type_);
       simgrid::instr::Type* state = simgrid::instr::Type::stateNew("MSG_PROCESS_STATE", msg_process);
-      new simgrid::instr::Value("suspend", "1 0 1", state);
-      simgrid::instr::Value::get_or_new("sleep", "1 1 0", state);
-      simgrid::instr::Value::get_or_new("receive", "1 0 0", state);
-      simgrid::instr::Value::get_or_new("send", "0 0 1", state);
-      simgrid::instr::Value::get_or_new("task_execute", "0 1 1", state);
+      simgrid::instr::Value::byNameOrCreate("suspend", "1 0 1", state);
+      simgrid::instr::Value::byNameOrCreate("sleep", "1 1 0", state);
+      simgrid::instr::Value::byNameOrCreate("receive", "1 0 0", state);
+      simgrid::instr::Value::byNameOrCreate("send", "0 0 1", state);
+      simgrid::instr::Value::byNameOrCreate("task_execute", "0 1 1", state);
       simgrid::instr::Type::linkNew("MSG_PROCESS_LINK", PJ_type_get_root(), msg_process, msg_process);
       simgrid::instr::Type::linkNew("MSG_PROCESS_TASK_LINK", PJ_type_get_root(), msg_process, msg_process);
     }
@@ -272,11 +271,11 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
     if (msg_vm == nullptr){
       msg_vm                      = simgrid::instr::Type::containerNew("MSG_VM", container->type_);
       simgrid::instr::Type* state = simgrid::instr::Type::stateNew("MSG_VM_STATE", msg_vm);
-      new simgrid::instr::Value("suspend", "1 0 1", state);
-      simgrid::instr::Value::get_or_new("sleep", "1 1 0", state);
-      simgrid::instr::Value::get_or_new("receive", "1 0 0", state);
-      simgrid::instr::Value::get_or_new("send", "0 0 1", state);
-      simgrid::instr::Value::get_or_new("task_execute", "0 1 1", state);
+      simgrid::instr::Value::byNameOrCreate("suspend", "1 0 1", state);
+      simgrid::instr::Value::byNameOrCreate("sleep", "1 1 0", state);
+      simgrid::instr::Value::byNameOrCreate("receive", "1 0 0", state);
+      simgrid::instr::Value::byNameOrCreate("send", "0 0 1", state);
+      simgrid::instr::Value::byNameOrCreate("task_execute", "0 1 1", state);
       simgrid::instr::Type::linkNew("MSG_VM_LINK", PJ_type_get_root(), msg_vm, msg_vm);
       simgrid::instr::Type::linkNew("MSG_VM_PROCESS_LINK", PJ_type_get_root(), msg_vm, msg_vm);
     }
@@ -325,26 +324,27 @@ void instr_routing_define_callbacks ()
  */
 static void recursiveNewVariableType(const char* new_typename, const char* color, simgrid::instr::Type* root)
 {
+
   if (not strcmp(root->name_, "HOST")) {
     char tnstr[INSTR_DEFAULT_STR_SIZE];
     snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "p%s", new_typename);
-    simgrid::instr::Type::variableNew(tnstr, color, root);
+    simgrid::instr::Type::variableNew(tnstr, color == nullptr ? "" : color, root);
   }
   if (not strcmp(root->name_, "MSG_VM")) {
     char tnstr[INSTR_DEFAULT_STR_SIZE];
     snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "p%s", new_typename);
-    simgrid::instr::Type::variableNew(tnstr, color, root);
+    simgrid::instr::Type::variableNew(tnstr, color == nullptr ? "" : color, root);
   }
   if (not strcmp(root->name_, "LINK")) {
     char tnstr[INSTR_DEFAULT_STR_SIZE];
     snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "b%s", new_typename);
-    simgrid::instr::Type::variableNew(tnstr, color, root);
+    simgrid::instr::Type::variableNew(tnstr, color == nullptr ? "" : color, root);
   }
   xbt_dict_cursor_t cursor = nullptr;
   simgrid::instr::Type* child_type;
   char *name;
   xbt_dict_foreach (root->children_, cursor, name, child_type) {
-    recursiveNewVariableType (new_typename, color, child_type);
+    recursiveNewVariableType(new_typename, color == nullptr ? "" : color, child_type);
   }
 }
 
@@ -357,7 +357,7 @@ static void recursiveNewUserVariableType(const char* father_type, const char* ne
                                          simgrid::instr::Type* root)
 {
   if (not strcmp(root->name_, father_type)) {
-    simgrid::instr::Type::variableNew(new_typename, color, root);
+    simgrid::instr::Type::variableNew(new_typename, color == nullptr ? "" : color, root);
   }
   xbt_dict_cursor_t cursor = nullptr;
   simgrid::instr::Type* child_type;
@@ -394,7 +394,7 @@ static void recursiveNewValueForUserStateType(const char* type_name, const char*
                                               simgrid::instr::Type* root)
 {
   if (not strcmp(root->name_, type_name)) {
-    new simgrid::instr::Value(val, color, root);
+    simgrid::instr::Value::byNameOrCreate(val, color, root);
   }
   xbt_dict_cursor_t cursor = nullptr;
   simgrid::instr::Type* child_type;