From a46510650f4fe2e157740c0f1982da871ac9c3ce Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Sun, 11 Oct 2020 21:15:12 +0200 Subject: [PATCH] Define const get_sharing_policy(). --- src/plugins/link_energy.cpp | 6 +++--- src/plugins/link_energy_wifi.cpp | 2 +- src/plugins/link_load.cpp | 2 +- src/surf/network_cm02.cpp | 4 ++-- src/surf/network_interface.cpp | 2 +- src/surf/network_interface.hpp | 2 +- src/surf/network_ns3.hpp | 2 +- src/surf/network_wifi.cpp | 2 +- src/surf/network_wifi.hpp | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/plugins/link_energy.cpp b/src/plugins/link_energy.cpp index 8b8699e98b..23c4dde639 100644 --- a/src/plugins/link_energy.cpp +++ b/src/plugins/link_energy.cpp @@ -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 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()->update(); } diff --git a/src/plugins/link_energy_wifi.cpp b/src/plugins/link_energy_wifi.cpp index a422f978cb..c3f70b80ba 100644 --- a/src/plugins/link_energy_wifi.cpp +++ b/src/plugins/link_energy_wifi.cpp @@ -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()->update(action); } diff --git a/src/plugins/link_load.cpp b/src/plugins/link_load.cpp index d25079e430..cfde59dc7a 100644 --- a/src/plugins/link_load.cpp +++ b/src/plugins/link_load.cpp @@ -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(); if (link_load->is_tracked()) diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index d3c96bbf28..0f4c844add 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -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 diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 25320359a6..42902a42a2 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -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(); } diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 6646f8f01b..435e70c509 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -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; diff --git a/src/surf/network_ns3.hpp b/src/surf/network_ns3.hpp index 70a4586c8d..2b907ba3a5 100644 --- a/src/surf/network_ns3.hpp +++ b/src/surf/network_ns3.hpp @@ -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_; } }; /********** diff --git a/src/surf/network_wifi.cpp b/src/surf/network_wifi.cpp index 838c1507fc..48c23e638d 100644 --- a/src/surf/network_wifi.cpp +++ b/src/surf/network_wifi.cpp @@ -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; } diff --git a/src/surf/network_wifi.hpp b/src/surf/network_wifi.hpp index 8ef62e877c..c5111e45c0 100644 --- a/src/surf/network_wifi.hpp +++ b/src/surf/network_wifi.hpp @@ -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; } -- 2.20.1