Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Declare functions "const" in src/surf/.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 2 Jul 2020 12:01:57 +0000 (14:01 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 2 Jul 2020 13:48:31 +0000 (15:48 +0200)
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/StorageImpl.hpp
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp
src/surf/network_ib.cpp
src/surf/network_ib.hpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp

index 2366c33..0d3bfc9 100644 (file)
@@ -55,7 +55,7 @@ HostImpl::~HostImpl()
  *
  * Weird things will happen if you turn on a host that is already on. S4U is fool-proof, not this.
  */
-void HostImpl::turn_on()
+void HostImpl::turn_on() const
 {
   for (auto const& arg : actors_at_boot_) {
     XBT_DEBUG("Booting Actor %s(%s) right now", arg->name.c_str(), arg->host->get_cname());
@@ -98,12 +98,12 @@ std::vector<s4u::ActorPtr> HostImpl::get_all_actors()
     res.push_back(actor.ciface());
   return res;
 }
-size_t HostImpl::get_actor_count()
+size_t HostImpl::get_actor_count() const
 {
   return actor_list_.size();
 }
 
-std::vector<s4u::Disk*> HostImpl::get_disks()
+std::vector<s4u::Disk*> HostImpl::get_disks() const
 {
   std::vector<s4u::Disk*> disks;
   for (auto const& d : disks_)
index c566740..7ce2468 100644 (file)
@@ -53,7 +53,7 @@ public:
   explicit HostImpl(s4u::Host* host);
   virtual ~HostImpl();
 
-  std::vector<s4u::Disk*> get_disks();
+  std::vector<s4u::Disk*> get_disks() const;
   void set_disks(const std::vector<kernel::resource::DiskImpl*>& disks, s4u::Host* host);
   void add_disk(const s4u::Disk* disk);
   void remove_disk(const std::string& disk_name);
@@ -65,10 +65,10 @@ public:
 
   s4u::Host* get_iface() { return piface_; }
 
-  void turn_on();
+  void turn_on() const;
   void turn_off(kernel::actor::ActorImpl* issuer);
   std::vector<s4u::ActorPtr> get_all_actors();
-  size_t get_actor_count();
+  size_t get_actor_count() const;
   void add_actor(kernel::actor::ActorImpl* actor) { actor_list_.push_back(*actor); }
   void remove_actor(kernel::actor::ActorImpl* actor) { xbt::intrusive_erase(actor_list_, *actor); }
   void add_actor_at_boot(kernel::actor::ProcessArg* arg) { actors_at_boot_.emplace_back(arg); }
index 955fb3f..ba17f01 100644 (file)
@@ -83,7 +83,7 @@ public:
   ~StorageImpl() override;
 
   s4u::Storage* get_iface() { return &piface_; }
-  const char* get_type() { return typeId_.c_str(); }
+  const char* get_type() const { return typeId_.c_str(); }
   lmm::Constraint* get_read_constraint() const { return constraint_read_; }
   lmm::Constraint* get_write_constraint() const { return constraint_write_; }
   /** @brief Check if the Storage is used (if an action currently uses its resources) */
index a76cf60..7118711 100644 (file)
@@ -218,7 +218,7 @@ CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double sp
 {
 }
 
-int CpuCas01Action::requested_core()
+int CpuCas01Action::requested_core() const
 {
   return requested_core_;
 }
index 2950172..1621b1b 100644 (file)
@@ -69,7 +69,7 @@ public:
   CpuCas01Action(const CpuCas01Action&) = delete;
   CpuCas01Action& operator=(const CpuCas01Action&) = delete;
   ~CpuCas01Action() override;
-  int requested_core();
+  int requested_core() const;
 
 private:
   int requested_core_ = 1;
@@ -79,4 +79,4 @@ private:
 } // namespace kernel
 } // namespace simgrid
 
-#endif
\ No newline at end of file
+#endif
index 0e1e208..788dff2 100644 (file)
@@ -50,7 +50,7 @@ CpuTiProfile::CpuTiProfile(const profile::Profile* profile)
  * @param b      End of interval
  * @return the integrate value. -1 if an error occurs.
  */
-double CpuTiTmgr::integrate(double a, double b)
+double CpuTiTmgr::integrate(double a, double b) const
 {
   if ((a < 0.0) || (a > b)) {
     xbt_die("Error, invalid integration interval [%.2f,%.2f]. "
@@ -90,7 +90,7 @@ double CpuTiTmgr::integrate(double a, double b)
  * @param a  Initial point
  * @param b  Final point
  */
-double CpuTiProfile::integrate_simple(double a, double b)
+double CpuTiProfile::integrate_simple(double a, double b) const
 {
   return integrate_simple_point(b) - integrate_simple_point(a);
 }
@@ -99,7 +99,7 @@ double CpuTiProfile::integrate_simple(double a, double b)
  * @brief Auxiliary function to compute the integral at point a.
  * @param a        point
  */
-double CpuTiProfile::integrate_simple_point(double a)
+double CpuTiProfile::integrate_simple_point(double a) const
 {
   double integral = 0;
   double a_aux = a;
@@ -126,7 +126,7 @@ double CpuTiProfile::integrate_simple_point(double a)
  * @param amount  Amount to be executed
  * @return  End time
  */
-double CpuTiTmgr::solve(double a, double amount)
+double CpuTiTmgr::solve(double a, double amount) const
 {
   /* Fix very small negative numbers */
   if ((a < 0.0) && (a > -EPSILON)) {
@@ -182,7 +182,7 @@ double CpuTiTmgr::solve(double a, double amount)
  * @param amount  Amount of flops
  * @return The date when amount is available.
  */
-double CpuTiProfile::solve_simple(double a, double amount)
+double CpuTiProfile::solve_simple(double a, double amount) const
 {
   double integral_a = integrate_simple_point(a);
   int ind           = binary_search(integral_, integral_a + amount);
@@ -200,7 +200,7 @@ double CpuTiProfile::solve_simple(double a, double amount)
  * @param a        Time
  * @return CPU speed scale
  */
-double CpuTiTmgr::get_power_scale(double a)
+double CpuTiTmgr::get_power_scale(double a) const
 {
   double reduced_a          = a - floor(a / last_time_) * last_time_;
   int point                       = CpuTiProfile::binary_search(profile_->time_points_, reduced_a);
index 4ce90e2..92a0527 100644 (file)
@@ -29,9 +29,9 @@ class CpuTiProfile {
 public:
   explicit CpuTiProfile(const profile::Profile* profile);
 
-  double integrate_simple(double a, double b);
-  double integrate_simple_point(double a);
-  double solve_simple(double a, double amount);
+  double integrate_simple(double a, double b) const;
+  double integrate_simple_point(double a) const;
+  double solve_simple(double a, double amount) const;
 
   std::vector<double> time_points_;
   std::vector<double> integral_;
@@ -50,9 +50,9 @@ public:
   CpuTiTmgr(const CpuTiTmgr&) = delete;
   CpuTiTmgr& operator=(const CpuTiTmgr&) = delete;
 
-  double integrate(double a, double b);
-  double solve(double a, double amount);
-  double get_power_scale(double a);
+  double integrate(double a, double b) const;
+  double solve(double a, double amount) const;
+  double get_power_scale(double a) const;
 
 private:
   Type type_ = Type::FIXED;
index dfcaf91..0a8c889 100644 (file)
@@ -110,7 +110,7 @@ NetworkIBModel::NetworkIBModel() : NetworkSmpiModel()
   }
 }
 
-void NetworkIBModel::computeIBfactors(IBNode* root)
+void NetworkIBModel::computeIBfactors(IBNode* root) const
 {
   double num_comm_out    = root->ActiveCommsUp.size();
   double max_penalty_out = 0.0;
@@ -157,7 +157,7 @@ void NetworkIBModel::computeIBfactors(IBNode* root)
   XBT_DEBUG("Finished computing IB penalties");
 }
 
-void NetworkIBModel::updateIBfactors_rec(IBNode* root, std::vector<bool>& updatedlist)
+void NetworkIBModel::updateIBfactors_rec(IBNode* root, std::vector<bool>& updatedlist) const
 {
   if (not updatedlist[root->id]) {
     XBT_DEBUG("IB - Updating rec %d", root->id);
@@ -174,7 +174,7 @@ void NetworkIBModel::updateIBfactors_rec(IBNode* root, std::vector<bool>& update
   }
 }
 
-void NetworkIBModel::updateIBfactors(NetworkAction* action, IBNode* from, IBNode* to, int remove)
+void NetworkIBModel::updateIBfactors(NetworkAction* action, IBNode* from, IBNode* to, int remove) const
 {
   if (from == to) // disregard local comms (should use loopback)
     return;
index 4b14ff2..72eecd3 100644 (file)
@@ -42,15 +42,15 @@ class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel {
   double Bs;
   double Be;
   double ys;
-  void updateIBfactors_rec(IBNode* root, std::vector<bool>& updatedlist);
-  void computeIBfactors(IBNode* root);
+  void updateIBfactors_rec(IBNode* root, std::vector<bool>& updatedlist) const;
+  void computeIBfactors(IBNode* root) const;
 
 public:
   NetworkIBModel();
   explicit NetworkIBModel(const char* name);
   NetworkIBModel(const NetworkIBModel&) = delete;
   NetworkIBModel& operator=(const NetworkIBModel&) = delete;
-  void updateIBfactors(NetworkAction* action, IBNode* from, IBNode* to, int remove);
+  void updateIBfactors(NetworkAction* action, IBNode* from, IBNode* to, int remove) const;
 
   std::unordered_map<std::string, IBNode> active_nodes;
   std::unordered_map<NetworkAction*, std::pair<IBNode*, IBNode*>> active_comms;
index e5e7b92..764c414 100644 (file)
@@ -151,7 +151,7 @@ void LinkImpl::turn_off()
   }
 }
 
-void LinkImpl::on_bandwidth_change()
+void LinkImpl::on_bandwidth_change() const
 {
   s4u::Link::on_bandwidth_change(this->piface_);
 }
index 087dadf..9cb6cc7 100644 (file)
@@ -144,7 +144,7 @@ public:
   void turn_on() override;
   void turn_off() override;
 
-  void on_bandwidth_change();
+  void on_bandwidth_change() const;
 
   virtual void
   set_bandwidth_profile(kernel::profile::Profile* profile); /*< setup the profile file with bandwidth events