Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a static function with an object parameter is a regular method
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 16 Sep 2017 19:24:55 +0000 (21:24 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 16 Sep 2017 19:25:10 +0000 (21:25 +0200)
src/instr/instr_paje_containers.cpp
src/instr/instr_paje_types.cpp
src/instr/instr_private.h
src/smpi/colls/smpi_automatic_selector.cpp
src/surf/instr_routing.cpp

index 13f4198..7541e6b 100644 (file)
@@ -71,7 +71,7 @@ simgrid::instr::Container::Container(const char* name, simgrid::instr::e_contain
     char as_typename[INSTR_DEFAULT_STR_SIZE];
     snprintf(as_typename, INSTR_DEFAULT_STR_SIZE, "L%d", this->level_);
     if (this->father_) {
-      this->type_ = simgrid::instr::Type::getOrNull(as_typename, this->father_->type_);
+      this->type_ = this->father_->type_->getChildOrNull(as_typename);
       if (this->type_ == nullptr) {
         this->type_ = simgrid::instr::Type::containerNew(as_typename, this->father_->type_);
       }
@@ -107,7 +107,7 @@ simgrid::instr::Container::Container(const char* name, simgrid::instr::e_contain
         THROWF (tracing_error, 0, "new container kind is unknown.");
         break;
     }
-    simgrid::instr::Type* type = simgrid::instr::Type::getOrNull(typeNameBuff, this->father_->type_);
+    simgrid::instr::Type* type = this->father_->type_->getChildOrNull(typeNameBuff);
     if (type == nullptr){
       this->type_ = simgrid::instr::Type::containerNew(typeNameBuff, this->father_->type_);
     }else{
index cdccdcf..b9e47a1 100644 (file)
@@ -64,28 +64,25 @@ simgrid::instr::Type::~Type()
 
 simgrid::instr::Type* PJ_type_get(const char* name, simgrid::instr::Type* father)
 {
-  simgrid::instr::Type* ret = simgrid::instr::Type::getOrNull(name, father);
-  if (ret == nullptr){
+  simgrid::instr::Type* ret = father->getChildOrNull(name);
+  if (ret == nullptr)
     THROWF(tracing_error, 2, "type with name (%s) not found in father type (%s)", name, father->name_);
-  }
   return ret;
 }
 
-simgrid::instr::Type* simgrid::instr::Type::getOrNull(const char* name, simgrid::instr::Type* father)
+simgrid::instr::Type* simgrid::instr::Type::getChildOrNull(const char* name)
 {
-  if (name == nullptr || father == nullptr){
-    THROWF (tracing_error, 0, "can't get type with a nullptr name or from a nullptr father");
-  }
+  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 (father->children_, cursor, child_name, child) {
+  xbt_dict_foreach (children_, cursor, child_name, child) {
     if (strcmp(child->name_, name) == 0) {
-      if (ret != nullptr){
+      if (ret != nullptr) {
         THROWF (tracing_error, 0, "there are two children types with the same name?");
-      }else{
+      } else {
         ret = child;
       }
     }
index 2ecebc2..1e0109b 100644 (file)
@@ -70,7 +70,7 @@ public:
   xbt_dict_t values_; // valid for all types except variable and container
   Type(const char* typeNameBuff, const char* key, const char* color, e_entity_types kind, Type* father);
   ~Type();
-  static Type* getOrNull(const char* name, Type* father);
+  Type* getChildOrNull(const char* name);
   static Type* containerNew(const char* name, Type* father);
   static Type* eventNew(const char* name, Type* father);
   static Type* variableNew(const char* name, const char* color, Type* father);
index df6832b..b6b3693 100644 (file)
@@ -16,7 +16,7 @@
 
 #define TRACE_AUTO_COLL(cat)                                                                                           \
   if (TRACE_is_enabled()) {                                                                                            \
-    simgrid::instr::Type* type = simgrid::instr::Type::getOrNull(#cat, PJ_type_get_root());                            \
+    simgrid::instr::Type* type = PJ_type_get_root()->getChildOrNull(#cat);                                             \
     if (not type) {                                                                                                    \
       type = simgrid::instr::Type::eventNew(#cat, PJ_type_get_root());                                                 \
     }                                                                                                                  \
index c9e513c..fb1a77b 100644 (file)
@@ -103,10 +103,9 @@ static void linkContainers (container_t src, container_t dst, xbt_dict_t filter)
   char link_typename[INSTR_DEFAULT_STR_SIZE];
   snprintf(link_typename, INSTR_DEFAULT_STR_SIZE, "%s-%s%s-%s%s", father->type_->name_, src->type_->name_,
            src->type_->id_, dst->type_->name_, dst->type_->id_);
-  simgrid::instr::Type* link_type = simgrid::instr::Type::getOrNull(link_typename, father->type_);
-  if (link_type == nullptr){
+  simgrid::instr::Type* link_type = father->type_->getChildOrNull(link_typename);
+  if (link_type == nullptr)
     link_type = simgrid::instr::Type::linkNew(link_typename, father->type_, src->type_, dst->type_);
-  }
 
   //register EDGE types for triva configuration
   trivaEdgeTypes.insert(link_type->name_);
@@ -170,7 +169,7 @@ static void sg_instr_AS_begin(simgrid::s4u::NetZone& netzone)
     PJ_container_set_root (root);
 
     if (TRACE_smpi_is_enabled()) {
-      simgrid::instr::Type* mpi = simgrid::instr::Type::getOrNull("MPI", root->type_);
+      simgrid::instr::Type* mpi = root->type_->getChildOrNull("MPI");
       if (mpi == nullptr){
         mpi = simgrid::instr::Type::containerNew("MPI", root->type_);
         if (not TRACE_smpi_is_grouped())
@@ -211,22 +210,19 @@ static void instr_routing_parse_start_link(simgrid::s4u::Link& link)
   container_t container = new simgrid::instr::Container(link.name(), simgrid::instr::INSTR_LINK, father);
 
   if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_link())) {
-    simgrid::instr::Type* bandwidth = simgrid::instr::Type::getOrNull("bandwidth", container->type_);
-    if (bandwidth == nullptr) {
+    simgrid::instr::Type* bandwidth = container->type_->getChildOrNull("bandwidth");
+    if (bandwidth == nullptr)
       bandwidth = simgrid::instr::Type::variableNew("bandwidth", nullptr, container->type_);
-    }
-    simgrid::instr::Type* latency = simgrid::instr::Type::getOrNull("latency", container->type_);
-    if (latency == nullptr) {
+    simgrid::instr::Type* latency = container->type_->getChildOrNull("latency");
+    if (latency == nullptr)
       latency = simgrid::instr::Type::variableNew("latency", nullptr, container->type_);
-    }
     new simgrid::instr::SetVariableEvent(0, container, bandwidth, bandwidth_value);
     new simgrid::instr::SetVariableEvent(0, container, latency, latency_value);
   }
   if (TRACE_uncategorized()) {
-    simgrid::instr::Type* bandwidth_used = simgrid::instr::Type::getOrNull("bandwidth_used", container->type_);
-    if (bandwidth_used == nullptr) {
+    simgrid::instr::Type* bandwidth_used = container->type_->getChildOrNull("bandwidth_used");
+    if (bandwidth_used == nullptr)
       simgrid::instr::Type::variableNew("bandwidth_used", "0.5 0.5 0.5", container->type_);
-    }
   }
 }
 
@@ -236,7 +232,7 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
   container_t container = new simgrid::instr::Container(host.getCname(), simgrid::instr::INSTR_HOST, father);
 
   if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_speed())) {
-    simgrid::instr::Type* speed = simgrid::instr::Type::getOrNull("power", container->type_);
+    simgrid::instr::Type* speed = container->type_->getChildOrNull("power");
     if (speed == nullptr){
       speed = simgrid::instr::Type::variableNew("power", nullptr, container->type_);
     }
@@ -245,14 +241,14 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
     new simgrid::instr::SetVariableEvent(0, container, speed, current_speed_state);
   }
   if (TRACE_uncategorized()){
-    simgrid::instr::Type* speed_used = simgrid::instr::Type::getOrNull("power_used", container->type_);
+    simgrid::instr::Type* speed_used = container->type_->getChildOrNull("power_used");
     if (speed_used == nullptr){
       simgrid::instr::Type::variableNew("power_used", "0.5 0.5 0.5", container->type_);
     }
   }
 
   if (TRACE_smpi_is_enabled() && TRACE_smpi_is_grouped()){
-    simgrid::instr::Type* mpi = simgrid::instr::Type::getOrNull("MPI", container->type_);
+    simgrid::instr::Type* mpi = container->type_->getChildOrNull("MPI");
     if (mpi == nullptr){
       mpi = simgrid::instr::Type::containerNew("MPI", container->type_);
       simgrid::instr::Type::stateNew("MPI_STATE", mpi);
@@ -260,7 +256,7 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
   }
 
   if (TRACE_msg_process_is_enabled()) {
-    simgrid::instr::Type* msg_process = simgrid::instr::Type::getOrNull("MSG_PROCESS", container->type_);
+    simgrid::instr::Type* msg_process = container->type_->getChildOrNull("MSG_PROCESS");
     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);
@@ -275,7 +271,7 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
   }
 
   if (TRACE_msg_vm_is_enabled()) {
-    simgrid::instr::Type* msg_vm = simgrid::instr::Type::getOrNull("MSG_VM", container->type_);
+    simgrid::instr::Type* msg_vm = container->type_->getChildOrNull("MSG_VM");
     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);