Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Define const get_sharing_policy().
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 11 Oct 2020 19:15:12 +0000 (21:15 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 11 Oct 2020 19:29:57 +0000 (21:29 +0200)
src/plugins/link_energy.cpp
src/plugins/link_energy_wifi.cpp
src/plugins/link_load.cpp
src/surf/network_cm02.cpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/network_ns3.hpp
src/surf/network_wifi.cpp
src/surf/network_wifi.hpp

index 8b8699e..23c4dde 100644 (file)
@@ -151,7 +151,7 @@ using simgrid::plugin::LinkEnergy;
 static void on_communicate(const simgrid::kernel::resource::NetworkAction& action)
 {
   XBT_DEBUG("onCommunicate is called");
-  for (simgrid::kernel::resource::LinkImpl* link : action.get_links()) {
+  for (auto const* link : action.get_links()) {
     if (link == nullptr || link->get_sharing_policy() == simgrid::s4u::Link::SharingPolicy::WIFI)
       continue;
 
@@ -167,7 +167,7 @@ static void on_simulation_end()
   std::vector<simgrid::s4u::Link*> links = simgrid::s4u::Engine::get_instance()->get_all_links();
 
   double total_energy = 0.0; // Total dissipated energy (whole platform)
-  for (const auto link : links) {
+  for (auto const* link : links) {
     if (link == nullptr || link->get_sharing_policy() == simgrid::s4u::Link::SharingPolicy::WIFI)
       continue;
 
@@ -219,7 +219,7 @@ void sg_link_energy_plugin_init()
   simgrid::s4u::Link::on_communication_state_change.connect(
       [](simgrid::kernel::resource::NetworkAction const& action,
          simgrid::kernel::resource::Action::State /* previous */) {
-        for (simgrid::kernel::resource::LinkImpl* link : action.get_links()) {
+        for (auto const* link : action.get_links()) {
           if (link != nullptr && link->get_sharing_policy() != simgrid::s4u::Link::SharingPolicy::WIFI)
             link->get_iface()->extension<LinkEnergy>()->update();
         }
index a422f97..c3f70b8 100644 (file)
@@ -324,7 +324,7 @@ void sg_wifi_energy_plugin_init()
       [](simgrid::kernel::resource::NetworkAction const& action,
          simgrid::kernel::resource::Action::State /* previous */) {
         // update WiFi links encountered during the communication
-        for (simgrid::kernel::resource::LinkImpl* link : action.get_links()) {
+        for (auto const* link : action.get_links()) {
           if (link != nullptr && link->get_sharing_policy() == simgrid::s4u::Link::SharingPolicy::WIFI) {
             link->get_iface()->extension<LinkEnergyWifi>()->update(action);
           }
index d25079e..cfde59d 100644 (file)
@@ -218,7 +218,7 @@ void sg_link_load_plugin_init()
   simgrid::s4u::Link::on_communication_state_change.connect(
       [](simgrid::kernel::resource::NetworkAction const& action,
          simgrid::kernel::resource::Action::State /* previous */) {
-        for (simgrid::kernel::resource::LinkImpl* link : action.get_links()) {
+        for (auto const* link : action.get_links()) {
           if (link != nullptr && link->get_sharing_policy() != simgrid::s4u::Link::SharingPolicy::WIFI) {
             auto link_load = link->get_iface()->extension<LinkLoad>();
             if (link_load->is_tracked())
index d3c96bb..0f4c844 100644 (file)
@@ -273,7 +273,7 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
     get_maxmin_system()->expand(dst_wifi_link->get_constraint(), action->get_variable(),
                                 1.0 / dst_wifi_link->get_host_rate(dst));
 
-  for (auto const& link : route) {
+  for (auto const* link : route) {
     // WIFI links are handled manually just above, so skip them now
     if (link->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI) {
       xbt_assert(link == src_wifi_link || link == dst_wifi_link,
@@ -292,7 +292,7 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz
     if (src_wifi_link != nullptr)
       get_maxmin_system()->expand(src_wifi_link->get_constraint(), action->get_variable(),
                                   .05 / src_wifi_link->get_host_rate(src));
-    for (auto const& link : back_route)
+    for (auto const* link : back_route)
       if (link->get_sharing_policy() != s4u::Link::SharingPolicy::WIFI)
         get_maxmin_system()->expand(link->get_constraint(), action->get_variable(), .05);
     // Change concurrency_share here, if you want that cross-traffic is included in the SURF concurrency
index 2532035..42902a4 100644 (file)
@@ -119,7 +119,7 @@ double LinkImpl::get_bandwidth()
   return bandwidth_.peak * bandwidth_.scale;
 }
 
-s4u::Link::SharingPolicy LinkImpl::get_sharing_policy()
+s4u::Link::SharingPolicy LinkImpl::get_sharing_policy() const
 {
   return get_constraint()->get_sharing_policy();
 }
index 6646f8f..435e70c 100644 (file)
@@ -137,7 +137,7 @@ public:
   virtual void set_latency(double value) = 0;
 
   /** @brief The sharing policy */
-  virtual s4u::Link::SharingPolicy get_sharing_policy();
+  virtual s4u::Link::SharingPolicy get_sharing_policy() const;
 
   /** @brief Check if the Link is used */
   bool is_used() override;
index 70a4586..2b907ba 100644 (file)
@@ -41,7 +41,7 @@ public:
   void set_latency(double) override { THROW_UNIMPLEMENTED; }
   void set_bandwidth_profile(profile::Profile* profile) override;
   void set_latency_profile(profile::Profile* profile) override;
-  s4u::Link::SharingPolicy get_sharing_policy() override {return sharing_policy_;}
+  s4u::Link::SharingPolicy get_sharing_policy() const override { return sharing_policy_; }
 };
 
 /**********
index 838c150..48c23e6 100644 (file)
@@ -57,7 +57,7 @@ double NetworkWifiLink::get_host_rate(const s4u::Host* host)
   return rate.peak * rate.scale;
 }
 
-s4u::Link::SharingPolicy NetworkWifiLink::get_sharing_policy()
+s4u::Link::SharingPolicy NetworkWifiLink::get_sharing_policy() const
 {
   return s4u::Link::SharingPolicy::WIFI;
 }
index 8ef62e8..c5111e4 100644 (file)
@@ -49,7 +49,7 @@ public:
   /** @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);
 
-  s4u::Link::SharingPolicy get_sharing_policy() override;
+  s4u::Link::SharingPolicy get_sharing_policy() const override;
   void apply_event(kernel::profile::Event*, double) override { THROW_UNIMPLEMENTED; }
   void set_bandwidth(double) override { THROW_UNIMPLEMENTED; }
   void set_latency(double) override { THROW_UNIMPLEMENTED; }