}
HostContainer::HostContainer(simgrid::s4u::Host& host, NetZoneContainer* father)
- : Container::Container(host.get_cname(), "HOST", father)
+ : Container::Container(host.get_name(), "HOST", father)
{
xbt_assert(father, "Only the Root container has no father");
if (not netzone->get_children().empty()) {
// bottom-up recursion
for (auto const& nz_son : netzone->get_children()) {
- container_t child_container = container->children_.at(nz_son->get_cname());
+ container_t child_container = container->children_.at(nz_son->get_name());
recursiveGraphExtraction(nz_son, child_container, filter);
}
}
static void instr_host_on_speed_change(simgrid::s4u::Host& host)
{
- simgrid::instr::Container::by_name(host.get_cname())
+ simgrid::instr::Container::by_name(host.get_name())
->get_variable("speed")
->set_event(surf_get_clock(), host.get_core_count() * host.get_available_speed());
}
static void instr_link_on_bandwidth_change(simgrid::s4u::Link& link)
{
- simgrid::instr::Container::by_name(link.get_cname())
+ simgrid::instr::Container::by_name(link.get_name())
->get_variable("bandwidth")
->set_event(surf_get_clock(), sg_bandwidth_factor * link.get_bandwidth());
}
static void instr_netpoint_on_creation(simgrid::kernel::routing::NetPoint* netpoint)
{
if (netpoint->is_router())
- new simgrid::instr::RouterContainer(netpoint->get_cname(), currentContainer.back());
+ new simgrid::instr::RouterContainer(netpoint->get_name(), currentContainer.back());
}
static void instr_on_platform_created()
if (not netzone->get_children().empty()) {
// bottom-up recursion
for (auto const& netzone_child : netzone->get_children()) {
- container_t child_container = container->children_.at(netzone_child->get_cname());
+ container_t child_container = container->children_.at(netzone_child->get_name());
recursiveXBTGraphExtraction(graph, nodes, edges, netzone_child, child_container);
}
}
this->add_resources(table);
} else {
for (auto const& nz : from_as->get_children()) {
- jed_container_t child_container = new simgrid::jedule::Container(std::string(nz->get_cname()));
+ jed_container_t child_container = new simgrid::jedule::Container(nz->get_name());
this->add_child(child_container);
child_container->create_hierarchy(nz);
}
my_jedule = new simgrid::jedule::Jedule();
- jed_container_t root_container = new simgrid::jedule::Container(std::string(root_comp->get_cname()));
+ jed_container_t root_container = new simgrid::jedule::Container(root_comp->get_name());
root_container->create_hierarchy(root_comp);
my_jedule->root_container_ = root_container;
}
if (actor_->auto_restart_ && not actor_->host_->is_on()) {
XBT_DEBUG("Insert host %s to watched_hosts because it's off and %s needs to restart", actor_->host_->get_cname(),
actor_->get_cname());
- watched_hosts.insert(actor_->host_->get_cname());
+ watched_hosts.insert(actor_->host_->get_name());
}
// Execute the termination callbacks
std::string instr_pid(msg_process_t proc)
{
- return std::string(proc->get_cname()) + "-" + std::to_string(proc->get_pid());
+ return std::string(proc->get_name()) + "-" + std::to_string(proc->get_pid());
}
/******************************** Process ************************************/
sg_size_t read_size = local_storage_->read(std::min(size, size_ - current_position_));
current_position_ += read_size;
- if (strcmp(host->get_cname(), Host::current()->get_cname())) {
+ if (host->get_name() != Host::current()->get_name()) {
/* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", host->get_cname(), read_size);
std::vector<Host*> m_host_list = {Host::current(), host};
/* Find the host where the file is physically located (remote or local)*/
Host* host = local_storage_->get_host();
- if (strcmp(host->get_cname(), Host::current()->get_cname())) {
+ if (host->get_name() != Host::current()->get_name()) {
/* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", host->get_cname(), size);
std::vector<Host*> m_host_list = {Host::current(), host};
simgrid::s4u::Link::on_state_change.connect([](simgrid::s4u::Link& link) { link.extension<LinkEnergy>()->update(); });
simgrid::s4u::Link::on_destruction.connect([](simgrid::s4u::Link& link) {
- if (strcmp(link.get_cname(), "__loopback__"))
+ if (link.get_name() != "__loopback__")
XBT_INFO("Energy consumption of link '%s': %f Joules", link.get_cname(),
link.extension<LinkEnergy>()->get_consumed_energy());
});
simgrid::instr::Container::by_name(vm_->get_name())->remove_from_parent();
// create new container on the new_host location
- new simgrid::instr::Container(vm_->get_cname(), "VM", simgrid::instr::Container::by_name(dst_pm_->get_name()));
+ new simgrid::instr::Container(vm_->get_name(), "VM", simgrid::instr::Container::by_name(dst_pm_->get_name()));
// end link
msg = simgrid::instr::Container::by_name(vm_->get_name());
return simgrid::s4u::Host::by_name_or_null(name);
}
-static int hostcmp_voidp(const void* pa, const void* pb)
-{
- return strcmp((*static_cast<simgrid::s4u::Host* const*>(pa))->get_cname(),
- (*static_cast<simgrid::s4u::Host* const*>(pb))->get_cname());
-}
-
xbt_dynar_t sg_hosts_as_dynar()
{
xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t), nullptr);
if (host && host->pimpl_netpoint && host->pimpl_netpoint->is_host())
xbt_dynar_push(res, &host);
}
- xbt_dynar_sort(res, hostcmp_voidp);
+ xbt_dynar_sort(res, [](const void* pa, const void* pb) {
+ const std::string& na = (*static_cast<simgrid::s4u::Host* const*>(pa))->get_name();
+ const std::string& nb = (*static_cast<simgrid::s4u::Host* const*>(pb))->get_name();
+ return na.compare(nb);
+ });
return res;
}
{
if (not host_->is_on())
throw_exception(std::make_exception_ptr(simgrid::HostFailureException(
- XBT_THROW_POINT, std::string("Host ") + std::string(host_->get_cname()) + " failed, you cannot sleep there.")));
+ XBT_THROW_POINT, std::string("Host ") + host_->get_cname() + " failed, you cannot sleep there.")));
return simgrid::kernel::activity::SleepImplPtr(new simgrid::kernel::activity::SleepImpl("sleep", host_))
->start(duration);
simgrid::s4u::on_platform_created.connect(surf_presolve);
simgrid::s4u::Storage::on_creation.connect([](simgrid::s4u::Storage& storage) {
- sg_storage_t s = simgrid::s4u::Storage::by_name(storage.get_cname());
+ sg_storage_t s = simgrid::s4u::Storage::by_name(storage.get_name());
xbt_assert(s != nullptr, "Storage not found for name %s", storage.get_cname());
});
}