Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill another dict in instr
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 12 Oct 2017 08:42:21 +0000 (10:42 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 12 Oct 2017 08:42:21 +0000 (10:42 +0200)
examples/msg/trace-process-migration/trace-process-migration.tesh
src/instr/instr_paje_types.cpp
src/instr/instr_private.hpp
src/surf/instr_routing.cpp

index 11594a1..41a7064 100644 (file)
@@ -707,8 +707,8 @@ $ tail -n +3 procmig.trace
 > 16 0 17 0 topology 21 44
 > 15 0 17 0 topology 30 45
 > 16 0 17 0 topology 28 45
-> 1 20 13 bmigration_order "0.800026 0.545312 0.857926"
-> 1 21 1 pmigration_order "0.800026 0.545312 0.857926"
+> 1 20 1 pmigration_order "0.800026 0.545312 0.857926"
+> 1 21 13 bmigration_order "0.800026 0.545312 0.857926"
 > 6 0 32 4 3 "emigrant-1"
 > 6 0 33 4 1 "policeman-2"
 > 12 0 5 32 7
@@ -1309,8 +1309,8 @@ $ tail -n +3 procmig.trace
 > 16 0 17 0 topology 21 44
 > 15 0 17 0 topology 30 45
 > 16 0 17 0 topology 28 45
-> 1 20 13 bmigration_order "0.800026 0.545312 0.857926"
-> 1 21 1 pmigration_order "0.800026 0.545312 0.857926"
+> 1 20 1 pmigration_order "0.800026 0.545312 0.857926"
+> 1 21 13 bmigration_order "0.800026 0.545312 0.857926"
 > 6 0 32 4 3 "emigrant-1"
 > 6 0 33 4 1 "policeman-2"
 > 12 0 5 32 7
@@ -1900,8 +1900,8 @@ $ tail -n +3 simgrid.trace
 > 16 0 6 0 topology 21 44
 > 15 0 6 0 topology 30 45
 > 16 0 6 0 topology 28 45
-> 1 9 3 bmigration_order "0.800026 0.545312 0.857926"
-> 1 10 1 pmigration_order "0.800026 0.545312 0.857926"
+> 1 9 1 pmigration_order "0.800026 0.545312 0.857926"
+> 1 10 3 bmigration_order "0.800026 0.545312 0.857926"
 > 7 18.155073 3 16
 > 7 18.155073 3 14
 > 7 18.155073 3 19
index 86846ff..abc3104 100644 (file)
@@ -24,29 +24,23 @@ simgrid::instr::Type::Type(const char* typeNameBuff, const char* key, std::strin
   }
 
   this->name_     = xbt_strdup(typeNameBuff);
-  this->children_ = xbt_dict_new_homogeneous(nullptr);
-
   this->id_ = bprintf("%lld", instr_new_paje_id());
 
   if (father != nullptr){
-    xbt_dict_set(father->children_, key, this, nullptr);
+    father->children_.insert({key, this});
     XBT_DEBUG("new type %s, child of %s", typeNameBuff, father->name_);
   }
 }
 
 simgrid::instr::Type::~Type()
 {
-  xbt_dict_cursor_t cursor = nullptr;
   for (auto elm : values_) {
     XBT_DEBUG("free value %s, child of %s", elm.second->getCname(), elm.second->father_->name_);
     delete elm.second;
   }
-  simgrid::instr::Type* child;
-  char *child_name;
-  xbt_dict_foreach (children_, cursor, child_name, child) {
-    delete child;
+  for (auto elm : children_) {
+    delete elm.second;
   }
-  xbt_dict_free(&children_);
   xbt_free(name_);
   xbt_free(id_);
 }
@@ -64,15 +58,12 @@ simgrid::instr::Type* simgrid::instr::Type::getChildOrNull(const char* name)
   xbt_assert(name != nullptr, "can't get type with a nullptr name");
 
   simgrid::instr::Type* ret = nullptr;
-  simgrid::instr::Type* child;
-  char *child_name;
-  xbt_dict_cursor_t cursor = nullptr;
-  xbt_dict_foreach (children_, cursor, child_name, child) {
-    if (strcmp(child->name_, name) == 0) {
+  for (auto elm : children_) {
+    if (strcmp(elm.second->name_, name) == 0) {
       if (ret != nullptr) {
         THROWF (tracing_error, 0, "there are two children types with the same name?");
       } else {
-        ret = child;
+        ret = elm.second;
       }
     }
   }
index caea5fe..2af3f18 100644 (file)
@@ -65,7 +65,7 @@ public:
 
   e_entity_types kind_;
   Type* father_;
-  xbt_dict_t children_;
+  std::map<std::string, Type*> children_;
   std::map<std::string, Value*> values_; // valid for all types except variable and container
   Type(const char* typeNameBuff, const char* key, std::string color, e_entity_types kind, Type* father);
   ~Type();
index ecbacce..ba7a057 100644 (file)
@@ -340,11 +340,8 @@ static void recursiveNewVariableType(const char* new_typename, const char* color
     snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "b%s", new_typename);
     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 == nullptr ? "" : color, child_type);
+  for (auto elm : root->children_) {
+    recursiveNewVariableType(new_typename, color == nullptr ? "" : color, elm.second);
   }
 }
 
@@ -359,12 +356,8 @@ static void recursiveNewUserVariableType(const char* father_type, const char* ne
   if (not strcmp(root->name_, father_type)) {
     simgrid::instr::Type::variableNew(new_typename, 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) {
-    recursiveNewUserVariableType (father_type, new_typename, color, child_type);
-  }
+  for (auto elm : root->children_)
+    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)
@@ -377,12 +370,8 @@ static void recursiveNewUserStateType(const char* father_type, const char* new_t
   if (not strcmp(root->name_, father_type)) {
     simgrid::instr::Type::stateNew(new_typename, root);
   }
-  xbt_dict_cursor_t cursor = nullptr;
-  simgrid::instr::Type* child_type;
-  char *name;
-  xbt_dict_foreach (root->children_, cursor, name, child_type) {
-    recursiveNewUserStateType (father_type, new_typename, child_type);
-  }
+  for (auto elm : root->children_)
+    recursiveNewUserStateType(father_type, new_typename, elm.second);
 }
 
 void instr_new_user_state_type (const char *father_type, const char *new_typename)
@@ -393,15 +382,11 @@ void instr_new_user_state_type (const char *father_type, const char *new_typenam
 static void recursiveNewValueForUserStateType(const char* type_name, const char* val, const char* color,
                                               simgrid::instr::Type* root)
 {
-  if (not strcmp(root->name_, type_name)) {
+  if (not strcmp(root->name_, type_name))
     simgrid::instr::Value::byNameOrCreate(val, color, root);
-  }
-  xbt_dict_cursor_t cursor = nullptr;
-  simgrid::instr::Type* child_type;
-  char *name;
-  xbt_dict_foreach (root->children_, cursor, name, child_type) {
-    recursiveNewValueForUserStateType(type_name, val, color, child_type);
-  }
+
+  for (auto elm : root->children_)
+    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)