Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ContextBoost: move static fields where they belong to.
[simgrid.git] / src / surf / instr_routing.cpp
index ccb7013..1a68583 100644 (file)
@@ -17,7 +17,7 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_routing, instr, "Tracing platform hierarchy");
 
 static int platform_created = 0;            /* indicate whether the platform file has been traced */
-static std::vector<container_t> currentContainer; /* push and pop, used only in creation */
+static std::vector<simgrid::instr::NetZoneContainer*> currentContainer; /* push and pop, used only in creation */
 
 static const char *instr_node_name (xbt_node_t node)
 {
@@ -106,8 +106,7 @@ static void linkContainers(container_t src, container_t dst, std::set<std::strin
   //create the link
   static long long counter = 0;
 
-  char key[INSTR_DEFAULT_STR_SIZE];
-  snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter);
+  std::string key = std::to_string(counter);
   counter++;
 
   new simgrid::instr::StartLinkEvent(SIMIX_get_clock(), father, link_type, src, "topology", key);
@@ -155,8 +154,7 @@ static void sg_instr_AS_begin(simgrid::s4u::NetZone& netzone)
   std::string id = netzone.getName();
 
   if (PJ_container_get_root() == nullptr){
-    container_t root = new simgrid::instr::Container(id, simgrid::instr::INSTR_AS, nullptr);
-    PJ_container_set_root (root);
+    simgrid::instr::NetZoneContainer* root = new simgrid::instr::NetZoneContainer(id, 0, nullptr);
 
     if (TRACE_smpi_is_enabled()) {
       simgrid::instr::Type* mpi = root->type_->getOrCreateContainerType("MPI");
@@ -172,8 +170,8 @@ static void sg_instr_AS_begin(simgrid::s4u::NetZone& netzone)
   }
 
   if (TRACE_needs_platform()){
-    container_t father = currentContainer.back();
-    container_t container = new simgrid::instr::Container(id, simgrid::instr::INSTR_AS, father);
+    simgrid::instr::NetZoneContainer* container =
+        new simgrid::instr::NetZoneContainer(id, currentContainer.size(), currentContainer.back());
     currentContainer.push_back(container);
   }
 }
@@ -191,7 +189,7 @@ static void instr_routing_parse_start_link(simgrid::s4u::Link& link)
     return;
 
   container_t father    = currentContainer.back();
-  container_t container = new simgrid::instr::Container(link.getName(), simgrid::instr::INSTR_LINK, father);
+  container_t container = new simgrid::instr::Container(link.getName(), "LINK", father);
 
   if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_link())) {
     simgrid::instr::Type* bandwidth = container->type_->getOrCreateVariableType("bandwidth", "");
@@ -206,8 +204,7 @@ static void instr_routing_parse_start_link(simgrid::s4u::Link& link)
 
 static void sg_instr_new_host(simgrid::s4u::Host& host)
 {
-  container_t father = currentContainer.back();
-  container_t container = new simgrid::instr::Container(host.getName(), simgrid::instr::INSTR_HOST, father);
+  container_t container = new simgrid::instr::HostContainer(host, currentContainer.back());
 
   if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_speed())) {
     simgrid::instr::Type* speed = container->type_->getOrCreateVariableType("power", "");
@@ -247,10 +244,8 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
 
 static void sg_instr_new_router(simgrid::kernel::routing::NetPoint * netpoint)
 {
-  if (not netpoint->isRouter())
-    return;
-  if (TRACE_is_enabled() && TRACE_needs_platform())
-    new simgrid::instr::Container(netpoint->getCname(), simgrid::instr::INSTR_ROUTER, currentContainer.back());
+  if (netpoint->isRouter() && TRACE_is_enabled() && TRACE_needs_platform())
+    new simgrid::instr::RouterContainer(netpoint->getCname(), currentContainer.back());
 }
 
 static void instr_routing_parse_end_platform ()
@@ -282,35 +277,35 @@ void instr_routing_define_callbacks ()
 /*
  * user categories support
  */
-static void recursiveNewVariableType(std::string new_typename, const char* color, simgrid::instr::Type* root)
+static void recursiveNewVariableType(std::string new_typename, std::string color, simgrid::instr::Type* root)
 {
   if (root->getName() == "HOST" || root->getName() == "MSG_VM")
-    root->getOrCreateVariableType(std::string("p") + new_typename, color == nullptr ? "" : color);
+    root->getOrCreateVariableType(std::string("p") + new_typename, color);
 
   if (root->getName() == "LINK")
-    root->getOrCreateVariableType(std::string("b") + new_typename, color == nullptr ? "" : color);
+    root->getOrCreateVariableType(std::string("b") + new_typename, color);
 
   for (auto elm : root->children_) {
-    recursiveNewVariableType(new_typename, color == nullptr ? "" : color, elm.second);
+    recursiveNewVariableType(new_typename, color, elm.second);
   }
 }
 
-void instr_new_variable_type(std::string new_typename, const char* color)
+void instr_new_variable_type(std::string new_typename, std::string color)
 {
   recursiveNewVariableType(new_typename, color, simgrid::instr::Type::getRootType());
 }
 
-static void recursiveNewUserVariableType(std::string father_type, std::string new_typename, const char* color,
+static void recursiveNewUserVariableType(std::string father_type, std::string new_typename, std::string color,
                                          simgrid::instr::Type* root)
 {
   if (root->getName() == father_type) {
-    root->getOrCreateVariableType(new_typename, color == nullptr ? "" : color);
+    root->getOrCreateVariableType(new_typename, color);
   }
   for (auto elm : root->children_)
     recursiveNewUserVariableType(father_type, new_typename, color, elm.second);
 }
 
-void instr_new_user_variable_type(std::string father_type, std::string new_typename, const char* color)
+void instr_new_user_variable_type(std::string father_type, std::string new_typename, std::string color)
 {
   recursiveNewUserVariableType(father_type, new_typename, color, simgrid::instr::Type::getRootType());
 }
@@ -329,7 +324,7 @@ void instr_new_user_state_type(std::string father_type, std::string new_typename
   recursiveNewUserStateType(father_type, new_typename, simgrid::instr::Type::getRootType());
 }
 
-static void recursiveNewValueForUserStateType(std::string type_name, const char* val, const char* color,
+static void recursiveNewValueForUserStateType(std::string type_name, const char* val, std::string color,
                                               simgrid::instr::Type* root)
 {
   if (root->getName() == type_name)
@@ -339,7 +334,7 @@ static void recursiveNewValueForUserStateType(std::string type_name, const char*
     recursiveNewValueForUserStateType(type_name, val, color, elm.second);
 }
 
-void instr_new_value_for_user_state_type(std::string type_name, const char* value, const char* color)
+void instr_new_value_for_user_state_type(std::string type_name, const char* value, std::string color)
 {
   recursiveNewValueForUserStateType(type_name, value, color, simgrid::instr::Type::getRootType());
 }