Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please sonar: remove an unused parameters down below
[simgrid.git] / src / instr / jedule / jedule_platform.cpp
index 6aedb79..5109fd7 100644 (file)
@@ -1,17 +1,14 @@
-/* Copyright (c) 2010-2016. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simgrid/jedule/jedule.hpp"
-#include "simgrid/jedule/jedule_platform.hpp"
 #include "simgrid/s4u/NetZone.hpp"
 #include "xbt/asserts.h"
-#include "xbt/dynar.h"
 #include <algorithm>
 
-#if HAVE_JEDULE
+#if SIMGRID_HAVE_JEDULE
 
 namespace simgrid {
 namespace jedule {
@@ -29,7 +26,7 @@ Container::Container(std::string name): name(name)
 
 Container::~Container()
 {
-  if(!this->children.empty())
+  if (not this->children.empty())
     for (auto child: this->children)
       delete child;
 }
@@ -59,32 +56,20 @@ void Container::addResources(std::vector<sg_host_t> hosts)
   }
 }
 
-void Container::createHierarchy(NetZone_t from_as)
+void Container::createHierarchy(sg_netzone_t from_as)
 {
-  xbt_dict_cursor_t cursor = nullptr;
-  char *key;
-  NetZone_t elem;
-  xbt_dict_t routing_sons = from_as->children();
 
-  if (xbt_dict_is_empty(routing_sons)) {
+  if (from_as->getChildren()->empty()) {
     // I am no AS
     // add hosts to jedule platform
-    xbt_dynar_t table = from_as->hosts();
-    unsigned int dynar_cursor;
-    sg_host_t host;
-
-    std::vector<sg_host_t> hosts;
-
-    xbt_dynar_foreach(table, dynar_cursor, host) {
-      hosts.push_back(host);
-    }
-    this->addResources(hosts);
-    xbt_dynar_free(&table);
+    std::vector<sg_host_t> table;
+    from_as->getHosts(&table);
+    this->addResources(table);
   } else {
-    xbt_dict_foreach(routing_sons, cursor, key, elem) {
-      jed_container_t child_container = new simgrid::jedule::Container(std::string(elem->name()));
+    for (auto nz : *from_as->getChildren()) {
+      jed_container_t child_container = new simgrid::jedule::Container(std::string(nz->getCname()));
       this->addChild(child_container);
-      child_container->createHierarchy(elem);
+      child_container->createHierarchy(nz);
     }
   }
 }
@@ -95,7 +80,7 @@ std::vector<int> Container::getHierarchy()
 
   if(this->parent != nullptr ) {
 
-    if(!this->parent->children.empty()) {
+    if (not this->parent->children.empty()) {
       // we are in the last level
       return this->parent->getHierarchy();
     } else {
@@ -143,7 +128,7 @@ std::string Container::getHierarchyAsString()
 void Container::printResources(FILE * jed_file)
 {
   unsigned int i=0;
-  xbt_assert(!this->resource_list.empty());
+  xbt_assert(not this->resource_list.empty());
 
   unsigned int res_nb = this->resource_list.size();
   std::string resid = this->getHierarchyAsString();
@@ -164,7 +149,7 @@ void Container::print(FILE* jed_file)
 {
   xbt_assert( this != nullptr );
   fprintf(jed_file, "    <res name=\"%s\">\n", this->name.c_str());
-  if( !this->children.empty()){
+  if (not this->children.empty()) {
     for (auto child: this->children) {
       child->print(jed_file);
     }