Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Declare functions "const" in src/plugins/.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 2 Jul 2020 13:45:10 +0000 (15:45 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 2 Jul 2020 13:55:57 +0000 (15:55 +0200)
include/simgrid/plugins/file_system.h
src/plugins/dirty_page_tracking.cpp
src/plugins/file_system/s4u_FileSystem.cpp
src/plugins/host_energy.cpp
src/plugins/host_load.cpp
src/plugins/link_energy.cpp
src/plugins/vm/VirtualMachineImpl.hpp

index 31e356e..fcc4f99 100644 (file)
@@ -122,7 +122,7 @@ public:
   ~File();
 
   /** Retrieves the path to the file */
-  const char* get_path() { return fullpath_.c_str(); }
+  const char* get_path() const { return fullpath_.c_str(); }
 
   /** Simulates a local read action. Returns the size of data actually read */
   sg_size_t read(sg_size_t size);
@@ -135,17 +135,17 @@ public:
   /** Retrieves the previously stored data */
   XBT_ATTRIB_DEPRECATED_v329("Please use get_data()") void* get_userdata() { return get_data(); }
 
-  sg_size_t size();
+  sg_size_t size() const;
   void seek(sg_offset_t pos);             /** Sets the file head to the given position. */
   void seek(sg_offset_t pos, int origin); /** Sets the file head to the given position from a given origin. */
-  sg_size_t tell();                       /** Retrieves the current file position */
+  sg_size_t tell() const;                 /** Retrieves the current file position */
 
   /** Rename a file. WARNING: It is forbidden to move the file to another mount point */
-  void move(const std::string& fullpath);
+  void move(const std::string& fullpath) const;
   int remote_copy(sg_host_t host, const char* fullpath);
   int remote_move(sg_host_t host, const char* fullpath);
 
-  int unlink(); /** Remove a file from the contents of a disk */
+  int unlink() const; /** Remove a file from the contents of a disk */
   void dump();
 };
 
@@ -163,7 +163,7 @@ public:
   FileSystemDiskExt& operator=(const FileSystemDiskExt&) = delete;
   std::map<std::string, sg_size_t>* parse_content(const std::string& filename);
   std::map<std::string, sg_size_t>* get_content() const { return content_.get(); }
-  const char* get_mount_point() { return mount_point_.c_str(); }
+  const char* get_mount_point() const { return mount_point_.c_str(); }
   const char* get_mount_point(s4u::Host* remote_host) { return remote_mount_points_[remote_host].c_str(); }
   void add_remote_mount(Host* host, const std::string& mount_point)
   {
@@ -187,8 +187,8 @@ public:
   FileSystemStorageExt& operator=(const FileSystemStorageExt&) = delete;
   std::map<std::string, sg_size_t>* parse_content(const std::string& filename);
   std::map<std::string, sg_size_t>* get_content() { return content_.get(); }
-  sg_size_t get_size() { return size_; }
-  sg_size_t get_used_size() { return used_size_; }
+  sg_size_t get_size() const { return size_; }
+  sg_size_t get_used_size() const { return used_size_; }
   void decr_used_size(sg_size_t size);
   void incr_used_size(sg_size_t size);
 };
index 1cd921a..daaba85 100644 (file)
@@ -23,19 +23,19 @@ class DirtyPageTrackingExt {
 public:
   void start_tracking();
   void stop_tracking() { dp_tracking_ = false; }
-  bool is_tracking() { return dp_tracking_; }
+  bool is_tracking() const { return dp_tracking_; }
   void track(kernel::activity::ExecImpl const* exec, double amount) { dp_objs_.insert({exec, amount}); }
   void untrack(kernel::activity::ExecImpl const* exec) { dp_objs_.erase(exec); }
   double get_stored_remains(kernel::activity::ExecImpl const* exec) { return dp_objs_.at(exec); }
   void update_dirty_page_count(double delta) { dp_updated_by_deleted_tasks_ += delta; }
   double computed_flops_lookup();
-  double get_intensity() { return dp_intensity_; }
+  double get_intensity() const { return dp_intensity_; }
   void set_intensity(double intensity) { dp_intensity_ = intensity; }
-  double get_working_set_memory() { return working_set_memory_; }
+  double get_working_set_memory() const { return working_set_memory_; }
   void set_working_set_memory(sg_size_t size) { working_set_memory_ = size; }
   void set_migration_speed(double speed) { mig_speed_ = speed; }
-  double get_migration_speed() { return mig_speed_; }
-  double get_max_downtime() { return max_downtime_; }
+  double get_migration_speed() const { return mig_speed_; }
+  double get_max_downtime() const { return max_downtime_; }
 
   static simgrid::xbt::Extension<VirtualMachineImpl, DirtyPageTrackingExt> EXTENSION_ID;
   virtual ~DirtyPageTrackingExt() = default;
index d291a32..43854f9 100644 (file)
@@ -297,7 +297,7 @@ sg_size_t File::write(sg_size_t size, bool write_inside)
   return 0;
 }
 
-sg_size_t File::size()
+sg_size_t File::size() const
 {
   return size_;
 }
@@ -324,12 +324,12 @@ void File::seek(sg_offset_t offset, int origin)
   }
 }
 
-sg_size_t File::tell()
+sg_size_t File::tell() const
 {
   return current_position_;
 }
 
-void File::move(const std::string& fullpath)
+void File::move(const std::string& fullpath) const
 {
   /* Check if the new full path is on the same mount point */
   if (fullpath.compare(0, mount_point_.length(), mount_point_) == 0) {
@@ -355,7 +355,7 @@ void File::move(const std::string& fullpath)
   }
 }
 
-int File::unlink()
+int File::unlink() const
 {
   /* Check if the file is on local storage */
   std::map<std::string, sg_size_t>* content = nullptr;
index 0b1ed29..866e9f6 100644 (file)
@@ -156,13 +156,13 @@ public:
   ~HostEnergy();
 
   double get_current_watts_value();
-  double get_current_watts_value(double cpu_load);
+  double get_current_watts_value(double cpu_load) const;
   double get_consumed_energy();
-  double get_watt_idle_at(int pstate);
-  double get_watt_min_at(int pstate);
-  double get_watt_max_at(int pstate);
-  double get_power_range_slope_at(int pstate);
-  double get_last_update_time() { return last_updated_; }
+  double get_watt_idle_at(int pstate) const;
+  double get_watt_min_at(int pstate) const;
+  double get_watt_max_at(int pstate) const;
+  double get_power_range_slope_at(int pstate) const;
+  double get_last_update_time() const { return last_updated_; }
   void update();
 };
 
@@ -228,28 +228,28 @@ HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host_(ptr)
 
 HostEnergy::~HostEnergy() = default;
 
-double HostEnergy::get_watt_idle_at(int pstate)
+double HostEnergy::get_watt_idle_at(int pstate) const
 {
   xbt_assert(not power_range_watts_list_.empty(), "No power range properties specified for host %s",
              host_->get_cname());
   return power_range_watts_list_[pstate].idle_;
 }
 
-double HostEnergy::get_watt_min_at(int pstate)
+double HostEnergy::get_watt_min_at(int pstate) const
 {
   xbt_assert(not power_range_watts_list_.empty(), "No power range properties specified for host %s",
              host_->get_cname());
   return power_range_watts_list_[pstate].epsilon_;
 }
 
-double HostEnergy::get_watt_max_at(int pstate)
+double HostEnergy::get_watt_max_at(int pstate) const
 {
   xbt_assert(not power_range_watts_list_.empty(), "No power range properties specified for host %s",
              host_->get_cname());
   return power_range_watts_list_[pstate].max_;
 }
 
-double HostEnergy::get_power_range_slope_at(int pstate)
+double HostEnergy::get_power_range_slope_at(int pstate) const
 {
   xbt_assert(not power_range_watts_list_.empty(), "No power range properties specified for host %s",
              host_->get_cname());
@@ -292,7 +292,7 @@ double HostEnergy::get_current_watts_value()
  *
  * Whether the host is ON or OFF is not taken into account.
  */
-double HostEnergy::get_current_watts_value(double cpu_load)
+double HostEnergy::get_current_watts_value(double cpu_load) const
 {
   xbt_assert(not power_range_watts_list_.empty(), "No power range properties specified for host %s",
              host_->get_cname());
index f881f1d..2188d2c 100644 (file)
@@ -68,7 +68,7 @@ public:
   explicit HostLoad(simgrid::s4u::Host& ptr) = delete;
   explicit HostLoad(simgrid::s4u::Host&& ptr) = delete;
 
-  double get_current_load();
+  double get_current_load() const;
   /** Get the the average load since last reset(), as a ratio
    *
    * That's the ratio (amount of flops that were actually computed) / (amount of flops that could have been computed at full speed)
@@ -168,7 +168,7 @@ void HostLoad::update()
  * But still, if you call this function between the two events (in the simulator course), it
  * returns 0 although there is no time (in the simulated time) where this value is valid.
  */
-double HostLoad::get_current_load()
+double HostLoad::get_current_load() const
 {
   // We don't need to call update() here because it is called every time an action terminates or starts
   return current_flops_ / (host_->get_speed() * host_->get_core_count());
index 4f076c0..3d68a3b 100644 (file)
@@ -55,7 +55,7 @@ public:
   void update();
 
 private:
-  double get_power();
+  double get_power() const;
 
   s4u::Link* link_{};
 
@@ -123,7 +123,7 @@ void LinkEnergy::init_watts_range_list()
   }
 }
 
-double LinkEnergy::get_power()
+double LinkEnergy::get_power() const
 {
   if (!inited_)
     return 0.0;
index a3c5464..a12b01f 100644 (file)
@@ -48,7 +48,7 @@ public:
   /** @brief Change the physical host on which the given VM is running */
   virtual void set_physical_host(s4u::Host* dest);
   /** @brief Get the physical host on which the given VM is running */
-  s4u::Host* get_physical_host() { return physical_host_; }
+  s4u::Host* get_physical_host() const { return physical_host_; }
 
   sg_size_t get_ramsize() const { return ramsize_; }
   void set_ramsize(sg_size_t ramsize) { ramsize_ = ramsize; }
@@ -56,8 +56,8 @@ public:
   s4u::VirtualMachine::state get_state() const { return vm_state_; }
   void set_state(s4u::VirtualMachine::state state) { vm_state_ = state; }
 
-  unsigned int get_core_amount() { return core_amount_; }
-  kernel::resource::Action* get_action() { return action_; }
+  unsigned int get_core_amount() const { return core_amount_; }
+  kernel::resource::Action* get_action() const { return action_; }
 
   virtual void set_bound(double bound);