Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a few more simplifications
[simgrid.git] / src / surf / instr_routing.cpp
index 6d6e819..f2c5ecf 100644 (file)
@@ -96,12 +96,13 @@ static void linkContainers(container_t src, container_t dst, std::set<std::strin
   filter->insert(aux2);
 
   //declare type
-  std::string link_typename = father->type_->getName() + "-" + src->type_->getName() + src->type_->getId() + "-" +
-                              dst->type_->getName() + dst->type_->getId();
-  simgrid::instr::Type* link_type = father->type_->getOrCreateLinkType(link_typename, src->type_, dst->type_);
+  std::string link_typename = father->type_->getName() + "-" + src->type_->getName() +
+                              std::to_string(src->type_->getId()) + "-" + dst->type_->getName() +
+                              std::to_string(dst->type_->getId());
+  simgrid::instr::LinkType* link = father->type_->getOrCreateLinkType(link_typename, src->type_, dst->type_);
 
   //register EDGE types for triva configuration
-  trivaEdgeTypes.insert(link_type->getName());
+  trivaEdgeTypes.insert(link->getName());
 
   //create the link
   static long long counter = 0;
@@ -109,8 +110,8 @@ static void linkContainers(container_t src, container_t dst, std::set<std::strin
   std::string key = std::to_string(counter);
   counter++;
 
-  new simgrid::instr::StartLinkEvent(SIMIX_get_clock(), father, link_type, src, "topology", key);
-  new simgrid::instr::EndLinkEvent(SIMIX_get_clock(), father, link_type, dst, "topology", key);
+  link->startEvent(father, src, "topology", key);
+  link->endEvent(father, dst, "topology", key);
 
   XBT_DEBUG("  linkContainers %s <-> %s", src->getCname(), dst->getCname());
 }
@@ -192,10 +193,8 @@ static void instr_routing_parse_start_link(simgrid::s4u::Link& link)
   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", "");
-    simgrid::instr::Type* latency   = container->type_->getOrCreateVariableType("latency", "");
-    new simgrid::instr::SetVariableEvent(0, container, bandwidth, link.bandwidth());
-    new simgrid::instr::SetVariableEvent(0, container, latency, link.latency());
+    container->type_->getOrCreateVariableType("bandwidth", "")->setEvent(0, container, link.bandwidth());
+    container->type_->getOrCreateVariableType("latency", "")->setEvent(0, container, link.latency());
   }
   if (TRACE_uncategorized()) {
     container->type_->getOrCreateVariableType("bandwidth_used", "0.5 0.5 0.5");
@@ -207,8 +206,7 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
   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", "");
-    new simgrid::instr::SetVariableEvent(0, container, speed, host.getSpeed());
+    container->type_->getOrCreateVariableType("power", "")->setEvent(0, container, host.getSpeed());
   }
 
   if (TRACE_uncategorized())
@@ -218,8 +216,8 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
     container->type_->getOrCreateContainerType("MPI")->getOrCreateStateType("MPI_STATE");
 
   if (TRACE_msg_process_is_enabled()) {
-    simgrid::instr::Type* msg_process = container->type_->getOrCreateContainerType("MSG_PROCESS");
-    simgrid::instr::Type* state       = msg_process->getOrCreateStateType("MSG_PROCESS_STATE");
+    simgrid::instr::ContainerType* msg_process = container->type_->getOrCreateContainerType("MSG_PROCESS");
+    simgrid::instr::StateType* state           = msg_process->getOrCreateStateType("MSG_PROCESS_STATE");
     state->addEntityValue("suspend", "1 0 1");
     state->addEntityValue("sleep", "1 1 0");
     state->addEntityValue("receive", "1 0 0");
@@ -230,8 +228,8 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
   }
 
   if (TRACE_msg_vm_is_enabled()) {
-    simgrid::instr::Type* msg_vm = container->type_->getOrCreateContainerType("MSG_VM");
-    simgrid::instr::Type* state  = msg_vm->getOrCreateStateType("MSG_VM_STATE");
+    simgrid::instr::ContainerType* msg_vm = container->type_->getOrCreateContainerType("MSG_VM");
+    simgrid::instr::StateType* state      = msg_vm->getOrCreateStateType("MSG_VM_STATE");
     state->addEntityValue("suspend", "1 0 1");
     state->addEntityValue("sleep", "1 1 0");
     state->addEntityValue("receive", "1 0 0");
@@ -313,9 +311,9 @@ void instr_new_user_variable_type(std::string father_type, std::string new_typen
 
 static void recursiveNewUserStateType(std::string father_type, std::string new_typename, simgrid::instr::Type* root)
 {
-  if (root->getName() == father_type) {
+  if (root->getName() == father_type)
     root->getOrCreateStateType(new_typename);
-  }
+
   for (auto elm : root->children_)
     recursiveNewUserStateType(father_type, new_typename, elm.second);
 }
@@ -329,7 +327,7 @@ static void recursiveNewValueForUserStateType(std::string type_name, const char*
                                               simgrid::instr::Type* root)
 {
   if (root->getName() == type_name)
-    root->addEntityValue(val, color);
+    static_cast<simgrid::instr::StateType*>(root)->addEntityValue(val, color);
 
   for (auto elm : root->children_)
     recursiveNewValueForUserStateType(type_name, val, color, elm.second);