Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Const in network_wifi and link_energy_wifi.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 11 Oct 2020 19:37:12 +0000 (21:37 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 11 Oct 2020 19:45:23 +0000 (21:45 +0200)
src/plugins/link_energy_wifi.cpp
src/surf/network_wifi.cpp
src/surf/network_wifi.hpp

index c3f70b8..13a8f49 100644 (file)
@@ -59,12 +59,12 @@ public:
    */
   void init_watts_range_list();
 
-  double get_consumed_energy(void) { return eDyn_ + eStat_; }
+  double get_consumed_energy(void) const { return eDyn_ + eStat_; }
   /** Get the dynamic part of the energy for this link */
-  double get_energy_dynamic(void) { return eDyn_; }
-  double get_energy_static(void) { return eStat_; }
-  double get_duration_comm(void) { return dur_TxRx_; }
-  double get_duration_idle(void) { return dur_idle_; }
+  double get_energy_dynamic(void) const { return eDyn_; }
+  double get_energy_static(void) const { return eStat_; }
+  double get_duration_comm(void) const { return dur_TxRx_; }
+  double get_duration_idle(void) const { return dur_idle_; }
 
   /** Set the power consumed by this link while idle */
   void set_power_idle(double value) { pIdle_ = value; }
@@ -110,8 +110,7 @@ xbt::Extension<s4u::Link, LinkEnergyWifi> LinkEnergyWifi::EXTENSION_ID;
 
 void LinkEnergyWifi::update_destroy()
 {
-  simgrid::kernel::resource::NetworkWifiLink* wifi_link =
-    static_cast<simgrid::kernel::resource::NetworkWifiLink*>(link_->get_impl());
+  auto const* wifi_link = static_cast<simgrid::kernel::resource::NetworkWifiLink*>(link_->get_impl());
   double duration = surf_get_clock() - prev_update_;
   prev_update_    = surf_get_clock();
 
@@ -135,8 +134,7 @@ void LinkEnergyWifi::update(const simgrid::kernel::resource::NetworkAction&)
   if(duration < 1e-6)
     return;
 
-  simgrid::kernel::resource::NetworkWifiLink* wifi_link =
-      static_cast<simgrid::kernel::resource::NetworkWifiLink*>(link_->get_impl());
+  auto const* wifi_link = static_cast<simgrid::kernel::resource::NetworkWifiLink*>(link_->get_impl());
 
   const kernel::lmm::Variable* var;
   const kernel::lmm::Element* elem = nullptr;
index 48c23e6..1eba216 100644 (file)
@@ -37,10 +37,9 @@ void NetworkWifiLink::set_host_rate(const s4u::Host* host, int rate_level)
   refresh_decay_bandwidths();
 }
 
-double NetworkWifiLink::get_host_rate(const s4u::Host* host)
+double NetworkWifiLink::get_host_rate(const s4u::Host* host) const
 {
-  std::map<xbt::string, int>::iterator host_rates_it;
-  host_rates_it = host_rates_.find(host->get_name());
+  auto host_rates_it = host_rates_.find(host->get_name());
 
   if (host_rates_it == host_rates_.end())
     return -1;
@@ -62,7 +61,7 @@ s4u::Link::SharingPolicy NetworkWifiLink::get_sharing_policy() const
   return s4u::Link::SharingPolicy::WIFI;
 }
 
-int NetworkWifiLink::get_host_count()
+int NetworkWifiLink::get_host_count() const
 {
   return host_rates_.size();
 }
index c5111e4..5f06aa4 100644 (file)
@@ -47,7 +47,7 @@ public:
 
   void set_host_rate(const s4u::Host* host, int rate_level);
   /** @brief Get the AP rate associated to the host (or -1 if not associated to the AP) */
-  double get_host_rate(const s4u::Host* host);
+  double get_host_rate(const s4u::Host* host) const;
 
   s4u::Link::SharingPolicy get_sharing_policy() const override;
   void apply_event(kernel::profile::Event*, double) override { THROW_UNIMPLEMENTED; }
@@ -55,7 +55,7 @@ public:
   void set_latency(double) override { THROW_UNIMPLEMENTED; }
   void refresh_decay_bandwidths();
   bool toggle_decay_model();
-  int get_host_count();
+  int get_host_count() const;
 };
 
 class NetworkWifiAction : public NetworkCm02Action {