Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Allow to set the network factors callback from userland w/o relying on NetworkModelIntf
[simgrid.git] / src / s4u / s4u_Netzone.cpp
index 8f01821..ec5b427 100644 (file)
@@ -14,8 +14,7 @@
 
 #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;
@@ -76,7 +75,7 @@ std::vector<Host*> NetZone::get_all_hosts() const
   return pimpl_->get_all_hosts();
 }
 
-int NetZone::get_host_count() const
+size_t NetZone::get_host_count() const
 {
   return pimpl_->get_host_count();
 }
@@ -114,6 +113,20 @@ NetZone* NetZone::seal()
   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)
+{
+  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)
+{
+  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)
 {
@@ -200,8 +213,7 @@ kernel::resource::NetworkModelIntf* NetZone::get_network_model() const
   kernel::resource::NetworkModelIntf* model = pimpl_->get_network_model().get();
   return model;
 }
-} // namespace s4u
-} // namespace simgrid
+} // namespace simgrid::s4u
 
 /* **************************** Public C interface *************************** */