- if( container->container_children != NULL ) {
- unsigned int iter;
- jed_simgrid_container_t child_container;
- xbt_dynar_foreach(container->container_children, iter, child_container) {
- jed_free_container(child_container);
+void Container::addChild(jed_container_t child)
+{
+ xbt_assert(this != nullptr);
+ xbt_assert(child != nullptr);
+ this->children.push_back(child);
+ child->parent = this;
+}
+
+void Container::addResources(std::vector<sg_host_t> hosts)
+{
+ this->is_lowest = 1;
+ this->children.clear();
+ this->last_id = 0;
+
+ //FIXME do we need to sort?: xbt_dynar_sort_strings(host_names);
+
+ for (auto host : hosts) {
+ const char *host_name = sg_host_get_name(host);
+ this->name2id.insert({host_name, this->last_id});
+ (this->last_id)++;
+ host2_simgrid_parent_container.insert({host_name, this});
+ this->resource_list.push_back(host);
+ }
+}
+
+void Container::createHierarchy(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)) {
+ // 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);
+ } else {
+ xbt_dict_foreach(routing_sons, cursor, key, elem) {
+ jed_container_t child_container = new simgrid::jedule::Container(std::string(elem->name()));
+ this->addChild(child_container);
+ child_container->createHierarchy(elem);