Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add some const qualifier, needed for later changes.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 18 Mar 2019 13:13:07 +0000 (14:13 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 18 Mar 2019 13:13:07 +0000 (14:13 +0100)
17 files changed:
include/simgrid/kernel/routing/NetPoint.hpp
include/simgrid/s4u/Actor.hpp
include/simgrid/s4u/Link.hpp
include/simgrid/s4u/VirtualMachine.hpp
include/xbt/Extendable.hpp
src/instr/instr_paje_containers.cpp
src/instr/instr_paje_containers.hpp
src/kernel/activity/ExecImpl.cpp
src/kernel/activity/ExecImpl.hpp
src/s4u/s4u_Actor.cpp
src/s4u/s4u_Link.cpp
src/surf/cpu_interface.cpp
src/surf/cpu_interface.hpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/network_ns3.cpp
src/surf/network_ns3.hpp

index 7984766..24b1148 100644 (file)
@@ -36,9 +36,9 @@ public:
   /** @brief the NetZone in which this NetPoint is included */
   NetZoneImpl* get_englobing_zone() { return englobing_zone_; }
 
   /** @brief the NetZone in which this NetPoint is included */
   NetZoneImpl* get_englobing_zone() { return englobing_zone_; }
 
-  bool is_netzone() { return component_type_ == Type::NetZone; }
-  bool is_host() { return component_type_ == Type::Host; }
-  bool is_router() { return component_type_ == Type::Router; }
+  bool is_netzone() const { return component_type_ == Type::NetZone; }
+  bool is_host() const { return component_type_ == Type::Host; }
+  bool is_router() const { return component_type_ == Type::Router; }
 
   static simgrid::xbt::signal<void(NetPoint*)> on_creation;
 
 
   static simgrid::xbt::signal<void(NetPoint*)> on_creation;
 
index 1ccfd6a..28e5e37 100644 (file)
@@ -207,7 +207,7 @@ public:
   /** Retrieves the name of that actor as a C string */
   const char* get_cname() const;
   /** Retrieves the host on which that actor is running */
   /** Retrieves the name of that actor as a C string */
   const char* get_cname() const;
   /** Retrieves the host on which that actor is running */
-  Host* get_host();
+  Host* get_host() const;
   /** Retrieves the actor ID of that actor */
   aid_t get_pid() const;
   /** Retrieves the actor ID of that actor's creator */
   /** Retrieves the actor ID of that actor */
   aid_t get_pid() const;
   /** Retrieves the actor ID of that actor's creator */
@@ -236,7 +236,7 @@ public:
    * It will be set to true if the actor was killed or failed because of an exception,
    * while it will remain to false if the actor terminated gracefully.
    */
    * It will be set to true if the actor was killed or failed because of an exception,
    * while it will remain to false if the actor terminated gracefully.
    */
-  void on_exit(const std::function<void(bool /*failed*/)>& fun);
+  void on_exit(const std::function<void(bool /*failed*/)>& fun) const;
 
   /** Sets the time at which that actor should be killed */
   void set_kill_time(double time);
 
   /** Sets the time at which that actor should be killed */
   void set_kill_time(double time);
@@ -286,7 +286,7 @@ public:
   static void kill_all();
 
   /** Returns the internal implementation of this actor */
   static void kill_all();
 
   /** Returns the internal implementation of this actor */
-  kernel::actor::ActorImpl* get_impl();
+  kernel::actor::ActorImpl* get_impl() const { return pimpl_; }
 
   /** Retrieve the property value (or nullptr if not set) */
   std::unordered_map<std::string, std::string>*
 
   /** Retrieve the property value (or nullptr if not set) */
   std::unordered_map<std::string, std::string>*
index be6dfb2..07b0e85 100644 (file)
@@ -45,10 +45,10 @@ public:
   const char* get_cname() const;
 
   /** @brief Get the bandwidth in bytes per second of current Link */
   const char* get_cname() const;
 
   /** @brief Get the bandwidth in bytes per second of current Link */
-  double get_bandwidth();
+  double get_bandwidth() const;
 
   /** @brief Get the latency in seconds of current Link */
 
   /** @brief Get the latency in seconds of current Link */
-  double get_latency();
+  double get_latency() const;
 
   /** @brief Describes how the link is shared between flows */
   SharingPolicy get_sharing_policy();
 
   /** @brief Describes how the link is shared between flows */
   SharingPolicy get_sharing_policy();
index b2bd8aa..25f2e1b 100644 (file)
@@ -38,7 +38,7 @@ public:
     DESTROYED
   };
 
     DESTROYED
   };
 
-  vm::VirtualMachineImpl* get_impl() { return pimpl_vm_; }
+  vm::VirtualMachineImpl* get_impl() const { return pimpl_vm_; }
   void start();
   void suspend();
   void resume();
   void start();
   void suspend();
   void resume();
index 5acaebe..37a7d41 100644 (file)
@@ -26,7 +26,7 @@ class Extension {
 public:
   explicit constexpr Extension() : id_(INVALID_ID) {}
   std::size_t id() const { return id_; }
 public:
   explicit constexpr Extension() : id_(INVALID_ID) {}
   std::size_t id() const { return id_; }
-  bool valid() { return id_ != INVALID_ID; }
+  bool valid() const { return id_ != INVALID_ID; }
 };
 
 /** An Extendable is an object that you can extend with external elements.
 };
 
 /** An Extendable is an object that you can extend with external elements.
@@ -83,7 +83,7 @@ public:
   }
 
   // Type-unsafe versions of the facet access methods:
   }
 
   // Type-unsafe versions of the facet access methods:
-  void* extension(std::size_t rank)
+  void* extension(std::size_t rank) const
   {
     if (rank >= extensions_.size())
       return nullptr;
   {
     if (rank >= extensions_.size())
       return nullptr;
@@ -101,11 +101,7 @@ public:
   }
 
   // Type safe versions of the facet access methods:
   }
 
   // Type safe versions of the facet access methods:
-  template<class U>
-  U* extension(Extension<T,U> rank)
-  {
-    return static_cast<U*>(extension(rank.id()));
-  }
+  template <class U> U* extension(Extension<T, U> rank) const { return static_cast<U*>(extension(rank.id())); }
   template<class U>
   void extension_set(Extension<T,U> rank, U* value, bool use_dtor = true)
   {
   template<class U>
   void extension_set(Extension<T,U> rank, U* value, bool use_dtor = true)
   {
@@ -113,7 +109,7 @@ public:
   }
 
   // Convenience extension access when the type has a associated EXTENSION ID:
   }
 
   // Convenience extension access when the type has a associated EXTENSION ID:
-  template<class U> U* extension()           { return extension<U>(U::EXTENSION_ID); }
+  template <class U> U* extension() const { return extension<U>(U::EXTENSION_ID); }
   template<class U> void extension_set(U* p) { extension_set<U>(U::EXTENSION_ID, p); }
 };
 
   template<class U> void extension_set(U* p) { extension_set<U>(U::EXTENSION_ID, p); }
 };
 
index 49271aa..dedda24 100644 (file)
@@ -59,7 +59,7 @@ RouterContainer::RouterContainer(const std::string& name, Container* father)
   trivaNodeTypes.insert(type_->get_name());
 }
 
   trivaNodeTypes.insert(type_->get_name());
 }
 
-HostContainer::HostContainer(simgrid::s4u::Host& host, NetZoneContainer* father)
+HostContainer::HostContainer(simgrid::s4u::Host const& host, NetZoneContainer* father)
     : Container::Container(host.get_name(), "HOST", father)
 {
   xbt_assert(father, "Only the Root container has no father");
     : Container::Container(host.get_name(), "HOST", father)
 {
   xbt_assert(father, "Only the Root container has no father");
index e4c33e6..17241ef 100644 (file)
@@ -58,7 +58,7 @@ public:
 
 class HostContainer : public Container {
 public:
 
 class HostContainer : public Container {
 public:
-  HostContainer(simgrid::s4u::Host& host, NetZoneContainer* father);
+  HostContainer(simgrid::s4u::Host const& host, NetZoneContainer* father);
 };
 }
 }
 };
 }
 }
index bffe2f5..462eb70 100644 (file)
@@ -117,7 +117,7 @@ void ExecImpl::cancel()
     surf_action_->cancel();
 }
 
     surf_action_->cancel();
 }
 
-double ExecImpl::get_remaining()
+double ExecImpl::get_remaining() const
 {
   return surf_action_ ? surf_action_->get_remains() : 0;
 }
 {
   return surf_action_ ? surf_action_->get_remains() : 0;
 }
index e784634..ea96c28 100644 (file)
@@ -29,7 +29,7 @@ public:
   void cancel();
   void post() override;
   void finish() override;
   void cancel();
   void post() override;
   void finish() override;
-  double get_remaining();
+  double get_remaining() const;
   double get_seq_remaining_ratio();
   double get_par_remaining_ratio();
   void set_bound(double bound);       // deprecated. To be removed in v3.25
   double get_seq_remaining_ratio();
   double get_par_remaining_ratio();
   void set_bound(double bound);       // deprecated. To be removed in v3.25
index b44df14..7f2a401 100644 (file)
@@ -113,7 +113,7 @@ void Actor::on_exit(const std::function<void(int, void*)>& fun, void* data) /* d
   on_exit([fun, data](bool exit) { fun(exit, data); });
 }
 
   on_exit([fun, data](bool exit) { fun(exit, data); });
 }
 
-void Actor::on_exit(const std::function<void(bool /*failed*/)>& fun)
+void Actor::on_exit(const std::function<void(bool /*failed*/)>& fun) const
 {
   simix::simcall(
       [this, fun] { SIMIX_process_on_exit(pimpl_, [fun](int a, void* /*data*/) { fun(a != 0); }, nullptr); });
 {
   simix::simcall(
       [this, fun] { SIMIX_process_on_exit(pimpl_, [fun](int a, void* /*data*/) { fun(a != 0); }, nullptr); });
@@ -138,7 +138,7 @@ void Actor::migrate(Host* new_host)
   s4u::Actor::on_migration_end(this);
 }
 
   s4u::Actor::on_migration_end(this);
 }
 
-s4u::Host* Actor::get_host()
+s4u::Host* Actor::get_host() const
 {
   return this->pimpl_->get_host();
 }
 {
   return this->pimpl_->get_host();
 }
@@ -223,11 +223,6 @@ void Actor::kill()
   });
 }
 
   });
 }
 
-kernel::actor::ActorImpl* Actor::get_impl()
-{
-  return pimpl_;
-}
-
 // ***** Static functions *****
 
 ActorPtr Actor::by_pid(aid_t pid)
 // ***** Static functions *****
 
 ActorPtr Actor::by_pid(aid_t pid)
index 86f5c31..3b34973 100644 (file)
@@ -49,12 +49,12 @@ bool Link::is_used()
   return this->pimpl_->is_used();
 }
 
   return this->pimpl_->is_used();
 }
 
-double Link::get_latency()
+double Link::get_latency() const
 {
   return this->pimpl_->get_latency();
 }
 
 {
   return this->pimpl_->get_latency();
 }
 
-double Link::get_bandwidth()
+double Link::get_bandwidth() const
 {
   return this->pimpl_->get_bandwidth();
 }
 {
   return this->pimpl_->get_bandwidth();
 }
index c507a90..83a6e16 100644 (file)
@@ -186,7 +186,8 @@ void CpuAction::set_state(Action::State state)
 }
 
 /** @brief returns a list of all CPUs that this action is using */
 }
 
 /** @brief returns a list of all CPUs that this action is using */
-std::list<Cpu*> CpuAction::cpus() {
+std::list<Cpu*> CpuAction::cpus() const
+{
   std::list<Cpu*> retlist;
   int llen = get_variable()->get_number_of_constraint();
 
   std::list<Cpu*> retlist;
   int llen = get_variable()->get_number_of_constraint();
 
index cdecf0e..27aa3c9 100644 (file)
@@ -179,7 +179,7 @@ public:
   void set_state(simgrid::kernel::resource::Action::State state) override;
 
   void update_remains_lazy(double now) override;
   void set_state(simgrid::kernel::resource::Action::State state) override;
 
   void update_remains_lazy(double now) override;
-  std::list<Cpu*> cpus();
+  std::list<Cpu*> cpus() const;
 
   void suspend() override;
   void resume() override;
 
   void suspend() override;
   void resume() override;
index 9bdcd82..b430e8f 100644 (file)
@@ -170,7 +170,7 @@ void NetworkAction::set_state(Action::State state)
 }
 
 /** @brief returns a list of all Links that this action is using */
 }
 
 /** @brief returns a list of all Links that this action is using */
-std::list<LinkImpl*> NetworkAction::links()
+std::list<LinkImpl*> NetworkAction::links() const
 {
   std::list<LinkImpl*> retlist;
   int llen = get_variable()->get_number_of_constraint();
 {
   std::list<LinkImpl*> retlist;
   int llen = get_variable()->get_number_of_constraint();
index de80df1..c3dbfc0 100644 (file)
@@ -198,7 +198,7 @@ public:
   NetworkAction(Model* model, double cost, bool failed, lmm::Variable* var) : Action(model, cost, failed, var){};
 
   void set_state(Action::State state) override;
   NetworkAction(Model* model, double cost, bool failed, lmm::Variable* var) : Action(model, cost, failed, var){};
 
   void set_state(Action::State state) override;
-  virtual std::list<LinkImpl*> links();
+  virtual std::list<LinkImpl*> links() const;
 
   double latency_    = {};
   double lat_current_ = {};
 
   double latency_    = {};
   double lat_current_ = {};
index 0a71792..109906a 100644 (file)
@@ -339,7 +339,7 @@ void NetworkNS3Action::resume() {
   THROW_UNIMPLEMENTED;
 }
 
   THROW_UNIMPLEMENTED;
 }
 
-std::list<LinkImpl*> NetworkNS3Action::links()
+std::list<LinkImpl*> NetworkNS3Action::links() const
 {
   THROW_UNIMPLEMENTED;
 }
 {
   THROW_UNIMPLEMENTED;
 }
index 632fe81..af200b8 100644 (file)
@@ -50,7 +50,7 @@ public:
 
   void suspend() override;
   void resume() override;
 
   void suspend() override;
   void resume() override;
-  std::list<LinkImpl*> links() override;
+  std::list<LinkImpl*> links() const override;
   void update_remains_lazy(double now) override;
 
   // private:
   void update_remains_lazy(double now) override;
 
   // private: