-/* Copyright (c) 2006-2022. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2006-2023. 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 "src/kernel/resource/NetworkModel.hpp"
-namespace simgrid {
-namespace s4u {
+namespace simgrid::s4u {
xbt::signal<void(NetZone const&)> NetZone::on_creation;
xbt::signal<void(NetZone const&)> NetZone::on_seal;
return pimpl_->get_all_hosts();
}
-int NetZone::get_host_count() const
+size_t NetZone::get_host_count() const
{
return pimpl_->get_host_count();
}
kernel::actor::simcall_answered([this] { pimpl_->seal(); });
return this;
}
+void NetZone::set_latency_factor_cb(
+ std::function<double(double size, const s4u::Host* src, const s4u::Host* dst,
+ const std::vector<s4u::Link*>& /*links*/,
+ const std::unordered_set<s4u::NetZone*>& /*netzones*/)> const& cb) const
+{
+ kernel::actor::simcall_answered([this, &cb]() { pimpl_->get_network_model()->set_lat_factor_cb(cb); });
+}
+void NetZone::set_bandwidth_factor_cb(
+ std::function<double(double size, const s4u::Host* src, const s4u::Host* dst,
+ const std::vector<s4u::Link*>& /*links*/,
+ const std::unordered_set<s4u::NetZone*>& /*netzones*/)> const& cb) const
+{
+ kernel::actor::simcall_answered([this, &cb]() { pimpl_->get_network_model()->set_bw_factor_cb(cb); });
+}
s4u::Host* NetZone::create_host(const std::string& name, double speed)
{
try {
speed = xbt_parse_get_bandwidth("", 0, bandwidth, "");
} catch (const simgrid::ParseError&) {
- throw std::invalid_argument(std::string("Impossible to create split-duplex link: ") + name +
- std::string(". Invalid bandwidth: ") + bandwidth);
+ throw std::invalid_argument("Impossible to create split-duplex link: " + name +
+ ". Invalid bandwidth: " + bandwidth);
}
return create_split_duplex_link(name, speed);
}
double speed = xbt_parse_get_bandwidth("", 0, speed_str, "");
bw.push_back(speed);
} catch (const simgrid::ParseError&) {
- throw std::invalid_argument(std::string("Impossible to create link: ") + name +
- std::string(". Invalid bandwidth: ") + speed_str);
+ throw std::invalid_argument("Impossible to create link: " + name + ". Invalid bandwidth: " + speed_str);
}
}
return create_link(name, bw);
return pimpl_->get_netpoint();
}
-kernel::resource::NetworkModelIntf* NetZone::get_network_model() const
+kernel::resource::NetworkModel* NetZone::get_network_model() const
{
- kernel::resource::NetworkModelIntf* model = pimpl_->get_network_model().get();
- return model;
+ return pimpl_->get_network_model().get();
}
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
/* **************************** Public C interface *************************** */