explicit NetZone(NetZone * father, const char* name);
virtual ~NetZone();
- std::vector<Host*>* hosts_ = nullptr;
+ std::vector<Host*>* hosts_ = new std::vector<Host*>();
public:
/** @brief Seal your netzone once you're done adding content, and before routing stuff through it */
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);
+ this->addResources(*from_as->hosts());
} else {
xbt_dict_foreach(routing_sons, cursor, key, elem) {
jed_container_t child_container = new simgrid::jedule::Container(std::string(elem->name()));
NetZone::NetZone(NetZone* father, const char* name) : father_(father), name_(xbt_strdup(name))
{
- for (auto card : vertices_) {
- s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->name());
- if (host != nullptr)
- hosts_->push_back(host);
- }
}
void NetZone::seal()
delete static_cast<NetZone*>(elem);
}
+ delete hosts_;
xbt_dict_free(&children_);
xbt_free(name_);
}
std::vector<s4u::Host*>* NetZone::hosts()
{
+ for (auto card : vertices_) {
+ s4u::Host* host = simgrid::s4u::Host::by_name_or_null(card->name());
+ if (host != nullptr)
+ hosts_->push_back(host);
+ }
return hosts_;
}