Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more std::string and stuff
[simgrid.git] / src / surf / instr_routing.cpp
index 774ad4b..d15d655 100644 (file)
@@ -133,20 +133,17 @@ static void recursiveGraphExtraction(simgrid::s4u::NetZone* netzone, container_t
   }
 
   xbt_graph_t graph = xbt_graph_new_graph (0, nullptr);
-  xbt_dict_t nodes = xbt_dict_new_homogeneous(nullptr);
-  xbt_dict_t edges = xbt_dict_new_homogeneous(nullptr);
-  xbt_edge_t edge = nullptr;
-
-  xbt_dict_cursor_t cursor = nullptr;
-  char *edge_name;
+  std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>;
+  std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>;
 
   static_cast<simgrid::kernel::routing::NetZoneImpl*>(netzone)->getGraph(graph, nodes, edges);
-  xbt_dict_foreach(edges,cursor,edge_name,edge) {
+  for (auto elm : *edges) {
+    xbt_edge_t edge = elm.second;
     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);
+  delete nodes;
+  delete edges;
   xbt_graph_free_graph(graph, xbt_free_f, xbt_free_f, nullptr);
 }
 
@@ -291,7 +288,7 @@ void instr_routing_define_callbacks ()
 /*
  * user categories support
  */
-static void recursiveNewVariableType(const char* new_typename, const char* color, simgrid::instr::Type* root)
+static void recursiveNewVariableType(std::string new_typename, const char* color, simgrid::instr::Type* root)
 {
   if (root->getName() == "HOST" || root->getName() == "MSG_VM")
     root->getOrCreateVariableType(std::string("p") + new_typename, color == nullptr ? "" : color);
@@ -304,12 +301,12 @@ static void recursiveNewVariableType(const char* new_typename, const char* color
   }
 }
 
-void instr_new_variable_type (const char *new_typename, const char *color)
+void instr_new_variable_type(std::string new_typename, const char* color)
 {
   recursiveNewVariableType(new_typename, color, simgrid::instr::Type::getRootType());
 }
 
-static void recursiveNewUserVariableType(const char* father_type, const char* new_typename, const char* color,
+static void recursiveNewUserVariableType(std::string father_type, std::string new_typename, const char* color,
                                          simgrid::instr::Type* root)
 {
   if (root->getName() == father_type) {
@@ -319,12 +316,12 @@ static void recursiveNewUserVariableType(const char* father_type, const char* ne
     recursiveNewUserVariableType(father_type, new_typename, color, elm.second);
 }
 
-void instr_new_user_variable_type  (const char *father_type, const char *new_typename, const char *color)
+void instr_new_user_variable_type(std::string father_type, std::string new_typename, const char* color)
 {
   recursiveNewUserVariableType(father_type, new_typename, color, simgrid::instr::Type::getRootType());
 }
 
-static void recursiveNewUserStateType(const char* father_type, const char* new_typename, simgrid::instr::Type* root)
+static void recursiveNewUserStateType(std::string father_type, std::string new_typename, simgrid::instr::Type* root)
 {
   if (root->getName() == father_type) {
     root->getOrCreateStateType(new_typename);
@@ -333,12 +330,12 @@ static void recursiveNewUserStateType(const char* father_type, const char* new_t
     recursiveNewUserStateType(father_type, new_typename, elm.second);
 }
 
-void instr_new_user_state_type (const char *father_type, const char *new_typename)
+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(const char* type_name, const char* val, const char* color,
+static void recursiveNewValueForUserStateType(std::string type_name, const char* val, const char* color,
                                               simgrid::instr::Type* root)
 {
   if (root->getName() == type_name)
@@ -348,7 +345,7 @@ static void recursiveNewValueForUserStateType(const char* type_name, const char*
     recursiveNewValueForUserStateType(type_name, val, color, elm.second);
 }
 
-void instr_new_value_for_user_state_type (const char *type_name, const char *value, const char *color)
+void instr_new_value_for_user_state_type(std::string type_name, const char* value, const char* color)
 {
   recursiveNewValueForUserStateType(type_name, value, color, simgrid::instr::Type::getRootType());
 }
@@ -360,7 +357,8 @@ int instr_platform_traced ()
 
 #define GRAPHICATOR_SUPPORT_FUNCTIONS
 
-static void recursiveXBTGraphExtraction(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges, sg_netzone_t netzone,
+static void recursiveXBTGraphExtraction(xbt_graph_t graph, std::map<std::string, xbt_node_t>* nodes,
+                                        std::map<std::string, xbt_edge_t>* edges, sg_netzone_t netzone,
                                         container_t container)
 {
   if (not netzone->getChildren()->empty()) {
@@ -377,12 +375,12 @@ static void recursiveXBTGraphExtraction(xbt_graph_t graph, xbt_dict_t nodes, xbt
 xbt_graph_t instr_routing_platform_graph ()
 {
   xbt_graph_t ret = xbt_graph_new_graph (0, nullptr);
-  xbt_dict_t nodes = xbt_dict_new_homogeneous(nullptr);
-  xbt_dict_t edges = xbt_dict_new_homogeneous(nullptr);
+  std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>;
+  std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>;
   recursiveXBTGraphExtraction(ret, nodes, edges, simgrid::s4u::Engine::getInstance()->getNetRoot(),
                               PJ_container_get_root());
-  xbt_dict_free (&nodes);
-  xbt_dict_free (&edges);
+  delete nodes;
+  delete edges;
   return ret;
 }