Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Constify pointer and reference parameters in src/surf/.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 29 Dec 2019 22:37:48 +0000 (23:37 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 29 Dec 2019 22:55:27 +0000 (23:55 +0100)
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp
src/surf/network_ib.cpp
src/surf/network_wifi.cpp
src/surf/network_wifi.hpp
src/surf/sg_platf.cpp
src/surf/xml/platf_private.hpp
src/surf/xml/surfxml_sax_cb.cpp

index d8d97be..bbf5152 100644 (file)
@@ -82,7 +82,7 @@ void HostImpl::turn_off(kernel::actor::ActorImpl* issuer)
   }
   // When a host is turned off, we want to keep only the actors that should restart for when it will boot again.
   // Then get rid of the others.
   }
   // When a host is turned off, we want to keep only the actors that should restart for when it will boot again.
   // Then get rid of the others.
-  auto elm = remove_if(begin(actors_at_boot_), end(actors_at_boot_), [](kernel::actor::ProcessArg* arg) {
+  auto elm = remove_if(begin(actors_at_boot_), end(actors_at_boot_), [](const kernel::actor::ProcessArg* arg) {
     if (arg->auto_restart)
       return false;
     delete arg;
     if (arg->auto_restart)
       return false;
     delete arg;
@@ -111,7 +111,7 @@ std::vector<s4u::Disk*> HostImpl::get_disks()
   return disks;
 }
 
   return disks;
 }
 
-void HostImpl::add_disk(s4u::Disk* disk)
+void HostImpl::add_disk(const s4u::Disk* disk)
 {
   disks_.push_back(disk->get_impl());
 }
 {
   disks_.push_back(disk->get_impl());
 }
index d48e4bb..bb2a68d 100644 (file)
@@ -52,7 +52,7 @@ public:
   virtual ~HostImpl();
 
   std::vector<s4u::Disk*> get_disks();
   virtual ~HostImpl();
 
   std::vector<s4u::Disk*> get_disks();
-  void add_disk(s4u::Disk* disk);
+  void add_disk(const s4u::Disk* disk);
   void remove_disk(const std::string& disk_name);
 
   /** @brief Get the vector of storages (by names) attached to the Host */
   void remove_disk(const std::string& disk_name);
 
   /** @brief Get the vector of storages (by names) attached to the Host */
index 53da8a2..cdef36a 100644 (file)
@@ -23,7 +23,7 @@ namespace resource {
  * Trace *
  *********/
 
  * Trace *
  *********/
 
-CpuTiProfile::CpuTiProfile(profile::Profile* profile)
+CpuTiProfile::CpuTiProfile(const profile::Profile* profile)
 {
   double integral = 0;
   double time = 0;
 {
   double integral = 0;
   double time = 0;
index 823149a..f97ef07 100644 (file)
@@ -27,7 +27,7 @@ class XBT_PRIVATE CpuTi;
  *********/
 class CpuTiProfile {
 public:
  *********/
 class CpuTiProfile {
 public:
-  explicit CpuTiProfile(profile::Profile* profile);
+  explicit CpuTiProfile(const profile::Profile* profile);
 
   double integrate_simple(double a, double b);
   double integrate_simple_point(double a);
 
   double integrate_simple(double a, double b);
   double integrate_simple_point(double a);
index 1fba58d..f6a94c6 100644 (file)
@@ -41,8 +41,8 @@ static void IB_action_state_changed_callback(simgrid::kernel::resource::NetworkA
   ((NetworkIBModel*)surf_network_model)->active_comms.erase(&action);
 }
 
   ((NetworkIBModel*)surf_network_model)->active_comms.erase(&action);
 }
 
-static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction& action, simgrid::s4u::Host* src,
-                                    simgrid::s4u::Host* dst)
+static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction& action, const simgrid::s4u::Host* src,
+                                    const simgrid::s4u::Host* dst)
 {
   simgrid::kernel::resource::NetworkIBModel* ibModel = (simgrid::kernel::resource::NetworkIBModel*)surf_network_model;
   simgrid::kernel::resource::IBNode* act_src         = &ibModel->active_nodes.at(src->get_name());
 {
   simgrid::kernel::resource::NetworkIBModel* ibModel = (simgrid::kernel::resource::NetworkIBModel*)surf_network_model;
   simgrid::kernel::resource::IBNode* act_src         = &ibModel->active_nodes.at(src->get_name());
index f7b761f..6ea1038 100644 (file)
@@ -27,14 +27,14 @@ NetworkWifiLink::NetworkWifiLink(NetworkCm02Model* model, const std::string& nam
   simgrid::s4u::Link::on_creation(*get_iface());
 }
 
   simgrid::s4u::Link::on_creation(*get_iface());
 }
 
-void NetworkWifiLink::set_host_rate(s4u::Host* host, int rate_level)
+void NetworkWifiLink::set_host_rate(const s4u::Host* host, int rate_level)
 {
   auto insert_done = host_rates_.insert(std::make_pair(host->get_name(), rate_level));
   if (insert_done.second == false)
     insert_done.first->second = rate_level;
 }
 
 {
   auto insert_done = host_rates_.insert(std::make_pair(host->get_name(), rate_level));
   if (insert_done.second == false)
     insert_done.first->second = rate_level;
 }
 
-double NetworkWifiLink::get_host_rate(sg_host_t host)
+double NetworkWifiLink::get_host_rate(const s4u::Host* host)
 {
   std::map<xbt::string, int>::iterator host_rates_it;
   host_rates_it = host_rates_.find(host->get_name());
 {
   std::map<xbt::string, int>::iterator host_rates_it;
   host_rates_it = host_rates_.find(host->get_name());
index c84527b..4092d12 100644 (file)
@@ -30,9 +30,9 @@ public:
   NetworkWifiLink(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
                   lmm::System* system);
 
   NetworkWifiLink(NetworkCm02Model* model, const std::string& name, std::vector<double> bandwidths,
                   lmm::System* system);
 
-  void set_host_rate(s4u::Host* host, int rate_level);
+  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) */
   /** @brief Get the AP rate associated to the host (or -1 if not associated to the AP) */
-  double get_host_rate(s4u::Host* host);
+  double get_host_rate(const s4u::Host* host);
 
   s4u::Link::SharingPolicy get_sharing_policy() override;
   void apply_event(kernel::profile::Event*, double) override { THROW_UNIMPLEMENTED; }
 
   s4u::Link::SharingPolicy get_sharing_policy() override;
   void apply_event(kernel::profile::Event*, double) override { THROW_UNIMPLEMENTED; }
index 6247def..5b3db61 100644 (file)
@@ -116,7 +116,7 @@ simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name,
   return netpoint;
 }
 
   return netpoint;
 }
 
-static void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link, const std::string& link_name)
+static void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link, const std::string& link_name)
 {
   simgrid::kernel::resource::LinkImpl* l =
       surf_network_model->create_link(link_name, link->bandwidths, link->latency, link->policy);
 {
   simgrid::kernel::resource::LinkImpl* l =
       surf_network_model->create_link(link_name, link->bandwidths, link->latency, link->policy);
@@ -133,7 +133,7 @@ static void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link,
     l->set_state_profile(link->state_trace);
 }
 
     l->set_state_profile(link->state_trace);
 }
 
-void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link)
+void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link)
 {
   if (link->policy == simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX) {
     sg_platf_new_link(link, link->id + "_UP");
 {
   if (link->policy == simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX) {
     sg_platf_new_link(link, link->id + "_UP");
@@ -309,7 +309,7 @@ void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb)
   XBT_DEBUG("Add a backbone to AS '%s'", current_routing->get_cname());
 }
 
   XBT_DEBUG("Add a backbone to AS '%s'", current_routing->get_cname());
 }
 
-void sg_platf_new_cabinet(simgrid::kernel::routing::CabinetCreationArgs* cabinet)
+void sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet)
 {
   for (int const& radical : *cabinet->radicals) {
     std::string hostname = cabinet->prefix + std::to_string(radical) + cabinet->suffix;
 {
   for (int const& radical : *cabinet->radicals) {
     std::string hostname = cabinet->prefix + std::to_string(radical) + cabinet->suffix;
@@ -336,7 +336,7 @@ void sg_platf_new_cabinet(simgrid::kernel::routing::CabinetCreationArgs* cabinet
   delete cabinet->radicals;
 }
 
   delete cabinet->radicals;
 }
 
-simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(simgrid::kernel::routing::DiskCreationArgs* disk)
+simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk)
 {
   simgrid::kernel::resource::DiskImpl* d = surf_disk_model->createDisk(disk->id, disk->read_bw, disk->write_bw);
   if (disk->properties) {
 {
   simgrid::kernel::resource::DiskImpl* d = surf_disk_model->createDisk(disk->id, disk->read_bw, disk->write_bw);
   if (disk->properties) {
@@ -386,7 +386,7 @@ void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage
   }
 }
 
   }
 }
 
-void sg_platf_new_storage_type(simgrid::kernel::routing::StorageTypeCreationArgs* storage_type)
+void sg_platf_new_storage_type(const simgrid::kernel::routing::StorageTypeCreationArgs* storage_type)
 {
   xbt_assert(storage_types.find(storage_type->id) == storage_types.end(),
              "Reading a storage type, processing unit \"%s\" already exists", storage_type->id.c_str());
 {
   xbt_assert(storage_types.find(storage_type->id) == storage_types.end(),
              "Reading a storage type, processing unit \"%s\" already exists", storage_type->id.c_str());
@@ -493,7 +493,7 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
   }
 }
 
   }
 }
 
-void sg_platf_new_peer(simgrid::kernel::routing::PeerCreationArgs* peer)
+void sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer)
 {
   simgrid::kernel::routing::VivaldiZone* as = dynamic_cast<simgrid::kernel::routing::VivaldiZone*>(current_routing);
   xbt_assert(as, "<peer> tag can only be used in Vivaldi netzones.");
 {
   simgrid::kernel::routing::VivaldiZone* as = dynamic_cast<simgrid::kernel::routing::VivaldiZone*>(current_routing);
   xbt_assert(as, "<peer> tag can only be used in Vivaldi netzones.");
@@ -565,7 +565,7 @@ static void surf_config_models_setup()
  *
  * @param zone the parameters defining the Zone to build.
  */
  *
  * @param zone the parameters defining the Zone to build.
  */
-simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCreationArgs* zone)
+simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone)
 {
   if (not surf_parse_models_setup_already_called) {
     simgrid::s4u::Engine::on_platform_creation();
 {
   if (not surf_parse_models_setup_already_called) {
     simgrid::s4u::Engine::on_platform_creation();
@@ -641,7 +641,7 @@ simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(simgrid::kernel::
   return new_zone;
 }
 
   return new_zone;
 }
 
-void sg_platf_new_Zone_set_properties(std::unordered_map<std::string, std::string>* props)
+void sg_platf_new_Zone_set_properties(const std::unordered_map<std::string, std::string>* props)
 {
   xbt_assert(current_routing, "Cannot set properties of the current Zone: none under construction");
 
 {
   xbt_assert(current_routing, "Cannot set properties of the current Zone: none under construction");
 
@@ -664,7 +664,7 @@ void sg_platf_new_Zone_seal()
 }
 
 /** @brief Add a link connecting a host to the rest of its AS (which must be cluster or vivaldi) */
 }
 
 /** @brief Add a link connecting a host to the rest of its AS (which must be cluster or vivaldi) */
-void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* hostlink)
+void sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* hostlink)
 {
   simgrid::kernel::routing::NetPoint* netpoint = simgrid::s4u::Host::by_name(hostlink->id)->get_netpoint();
   xbt_assert(netpoint, "Host '%s' not found!", hostlink->id.c_str());
 {
   simgrid::kernel::routing::NetPoint* netpoint = simgrid::s4u::Host::by_name(hostlink->id)->get_netpoint();
   xbt_assert(netpoint, "Host '%s' not found!", hostlink->id.c_str());
index fb0c3f0..6120051 100644 (file)
@@ -199,16 +199,20 @@ void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb);
 /*** END of the parsing cruft ***/
 
 XBT_PUBLIC simgrid::kernel::routing::NetZoneImpl*
 /*** END of the parsing cruft ***/
 
 XBT_PUBLIC simgrid::kernel::routing::NetZoneImpl*
-sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCreationArgs* zone);         // Begin description of new Zone
-XBT_PUBLIC void sg_platf_new_Zone_set_properties(std::unordered_map<std::string, std::string>* props);
+sg_platf_new_Zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone
+XBT_PUBLIC void sg_platf_new_Zone_set_properties(const std::unordered_map<std::string, std::string>* props);
 XBT_PUBLIC void sg_platf_new_Zone_seal();                                          // That Zone is fully described
 
 XBT_PUBLIC void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* host);      // Add a host      to the current Zone
 XBT_PUBLIC void sg_platf_new_Zone_seal();                                          // That Zone is fully described
 
 XBT_PUBLIC void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* host);      // Add a host      to the current Zone
-XBT_PUBLIC void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* h);     // Add a host_link to the current Zone
-XBT_PUBLIC void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link);          // Add a link      to the current Zone
-XBT_PUBLIC void sg_platf_new_peer(simgrid::kernel::routing::PeerCreationArgs* peer);          // Add a peer      to the current Zone
+XBT_PUBLIC void
+sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone
+XBT_PUBLIC void
+sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone
+XBT_PUBLIC void
+sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer); // Add a peer to the current Zone
 XBT_PUBLIC void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* clust);   // Add a cluster   to the current Zone
 XBT_PUBLIC void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* clust);   // Add a cluster   to the current Zone
-XBT_PUBLIC void sg_platf_new_cabinet(simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet   to the current Zone
+XBT_PUBLIC void
+sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone
 XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a router    to the current Zone
     sg_platf_new_router(const std::string&, const char* coords);
 
 XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a router    to the current Zone
     sg_platf_new_router(const std::string&, const char* coords);
 
@@ -218,10 +222,10 @@ XBT_PUBLIC void sg_platf_new_bypassRoute(simgrid::kernel::routing::RouteCreation
 XBT_PUBLIC void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* trace);
 
 XBT_PUBLIC simgrid::kernel::resource::DiskImpl*
 XBT_PUBLIC void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* trace);
 
 XBT_PUBLIC simgrid::kernel::resource::DiskImpl*
-sg_platf_new_disk(simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
+sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host
 
 XBT_PUBLIC void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage); // Add a storage to the current Zone
 
 XBT_PUBLIC void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage); // Add a storage to the current Zone
-XBT_PUBLIC void sg_platf_new_storage_type(simgrid::kernel::routing::StorageTypeCreationArgs* storage_type);
+XBT_PUBLIC void sg_platf_new_storage_type(const simgrid::kernel::routing::StorageTypeCreationArgs* storage_type);
 XBT_PUBLIC void sg_platf_new_mount(simgrid::kernel::routing::MountCreationArgs* mount);
 
 XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor);
 XBT_PUBLIC void sg_platf_new_mount(simgrid::kernel::routing::MountCreationArgs* mount);
 
 XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor);
index 2cd4006..d2320a3 100644 (file)
@@ -55,7 +55,7 @@ void surf_parse_assert_netpoint(const std::string& hostname, const std::string&
   std::vector<simgrid::kernel::routing::NetPoint*> netpoints =
       simgrid::s4u::Engine::get_instance()->get_all_netpoints();
   std::sort(netpoints.begin(), netpoints.end(),
   std::vector<simgrid::kernel::routing::NetPoint*> netpoints =
       simgrid::s4u::Engine::get_instance()->get_all_netpoints();
   std::sort(netpoints.begin(), netpoints.end(),
-            [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) {
+            [](const simgrid::kernel::routing::NetPoint* a, const simgrid::kernel::routing::NetPoint* b) {
               return a->get_name() < b->get_name();
             });
   bool first = true;
               return a->get_name() < b->get_name();
             });
   bool first = true;