Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make the factor callbacks private in NetworkModelFactors
[simgrid.git] / src / kernel / resource / NetworkModelFactors.cpp
index 52e8ba0..6641350 100644 (file)
@@ -24,7 +24,17 @@ static config::Flag<std::string> cfg_bandwidth_factor_str(
     "network/bandwidth-factor", std::initializer_list<const char*>{"smpi/bw-factor"},
     "Correction factor to apply to the provided bandwidth (default value overridden by network model)", "1.0");
 
-#if 0
+double NetworkModelFactors::get_bandwidth_factor()
+{
+  xbt_assert(not bw_factor_cb_,
+             "Cannot access the global bandwidth factor since a callback is used. Please go for the advanced API.");
+
+  if (not cfg_bandwidth_factor.is_initialized())
+    cfg_bandwidth_factor.parse(cfg_bandwidth_factor_str.get());
+
+  return cfg_bandwidth_factor(0);
+}
+
 double NetworkModelFactors::get_latency_factor()
 {
   xbt_assert(not lat_factor_cb_,
@@ -36,6 +46,7 @@ double NetworkModelFactors::get_latency_factor()
   return cfg_latency_factor(0);
 }
 
+#if 0
 double NetworkModelFactors::get_latency_factor(double size, const s4u::Host* src, const s4u::Host* dst,
                                                const std::vector<s4u::Link*>& links,
                                                const std::unordered_set<s4u::NetZone*>& netzones)
@@ -48,16 +59,6 @@ double NetworkModelFactors::get_latency_factor(double size, const s4u::Host* src
 
   return cfg_latency_factor(size);
 }
-double NetworkModelFactors::get_bandwidth_factor()
-{
-  xbt_assert(not bw_factor_cb_,
-             "Cannot access the global bandwidth factor since a callback is used. Please go for the advanced API.");
-
-  if (not cfg_bandwidth_factor.is_initialized())
-    cfg_bandwidth_factor.parse(cfg_bandwidth_factor_str.get());
-
-  return cfg_bandwidth_factor(0);
-}
 
 double NetworkModelFactors::get_bandwidth_factor(double size, const s4u::Host* src, const s4u::Host* dst,
                                                  const std::vector<s4u::Link*>& links,
@@ -73,15 +74,25 @@ double NetworkModelFactors::get_bandwidth_factor(double size, const s4u::Host* s
 }
 #endif
 
-double NetworkModelFactors::get_latency_factor(double size)
+double NetworkModelFactors::get_latency_factor(double size, const s4u::Host* src, const s4u::Host* dst,
+                                               const std::vector<s4u::Link*>& links,
+                                               const std::unordered_set<s4u::NetZone*>& netzones)
 {
+  if (lat_factor_cb_)
+    return lat_factor_cb_(size, src, dst, links, netzones);
+
   if (not cfg_latency_factor.is_initialized()) // lazy initiaization to avoid initialization fiasco
     cfg_latency_factor.parse(cfg_latency_factor_str.get());
 
   return cfg_latency_factor(size);
 }
-double NetworkModelFactors::get_bandwidth_factor(double size)
+double NetworkModelFactors::get_bandwidth_factor(double size, const s4u::Host* src, const s4u::Host* dst,
+                                                 const std::vector<s4u::Link*>& links,
+                                                 const std::unordered_set<s4u::NetZone*>& netzones)
 {
+  if (bw_factor_cb_)
+    return bw_factor_cb_(size, src, dst, links, netzones);
+
   if (not cfg_bandwidth_factor.is_initialized())
     cfg_bandwidth_factor.parse(cfg_bandwidth_factor_str.get());