Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Const for methods.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 2 Mar 2021 15:24:04 +0000 (16:24 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 2 Mar 2021 20:46:42 +0000 (21:46 +0100)
src/mc/api.cpp
src/mc/api.hpp
src/mc/checker/SimcallInspector.cpp
src/mc/checker/SimcallInspector.hpp

index 7fb3fff..ff5f7ae 100644 (file)
@@ -630,7 +630,7 @@ smx_simcall_t Api::mc_state_choose_request(simgrid::mc::State* state) const
   return nullptr;
 }
 
-std::list<transition_detail_t> Api::get_enabled_transitions(simgrid::mc::State* state)
+std::list<transition_detail_t> Api::get_enabled_transitions(simgrid::mc::State* state) const
 {
   std::list<transition_detail_t> tr_list{};
 
index eb9f907..a425bc4 100644 (file)
@@ -108,7 +108,7 @@ public:
   smx_simcall_t mc_state_choose_request(simgrid::mc::State* state) const;
 
   // UDPOR APIs
-  std::list<transition_detail_t> get_enabled_transitions(simgrid::mc::State* state);
+  std::list<transition_detail_t> get_enabled_transitions(simgrid::mc::State* state) const;
 
   // SIMCALL APIs
   std::string request_to_string(smx_simcall_t req, int value, RequestType request_type) const;
index 94b3438..ff08bc9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -12,23 +12,25 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_inspector, mc, "Logging specific to MC simcal
 namespace simgrid {
 namespace mc {
 
-std::string SimcallInspector::to_string(int time_considered)
+std::string SimcallInspector::to_string(int /*time_considered*/) const
 {
   return simgrid::xbt::string_printf("[(%ld)%s (%s)] ", get_issuer()->get_pid(), issuer_->get_host()->get_cname(),
                                      issuer_->get_cname());
 }
 
-std::string RandomSimcall::to_string(int time_considered)
+std::string RandomSimcall::to_string(int time_considered) const
 {
   return SimcallInspector::to_string(time_considered) + "MC_RANDOM(" + std::to_string(time_considered) + ")";
 }
-std::string SimcallInspector::dot_label()
+
+std::string SimcallInspector::dot_label() const
 {
   if (issuer_->get_host())
     return xbt::string_printf("[(%ld)%s]", issuer_->get_pid(), issuer_->get_cname());
   return xbt::string_printf("[(%ld)]", issuer_->get_pid());
 }
-std::string RandomSimcall::dot_label()
+
+std::string RandomSimcall::dot_label() const
 {
   return SimcallInspector::dot_label() + " MC_RANDOM (" + std::to_string(next_value_) + ")";
 }
@@ -38,11 +40,13 @@ void RandomSimcall::prepare(int times_considered)
   next_value_ = min_ + times_considered;
   XBT_DEBUG("MC_RANDOM(%d, %d) will return %d after %d times", min_, max_, next_value_, times_considered);
 }
-int RandomSimcall::get_max_consider()
+
+int RandomSimcall::get_max_consider() const
 {
   return max_ - min_ + 1;
 }
-int RandomSimcall::get_value()
+
+int RandomSimcall::get_value() const
 {
   return next_value_;
 }
index 1a7d3c7..a2687c4 100644 (file)
@@ -17,14 +17,14 @@ class SimcallInspector {
   kernel::actor::ActorImpl* issuer_;
 
 public:
-  SimcallInspector(kernel::actor::ActorImpl* issuer) : issuer_(issuer) {}
-  kernel::actor::ActorImpl* get_issuer() { return issuer_; }
+  explicit SimcallInspector(kernel::actor::ActorImpl* issuer) : issuer_(issuer) {}
+  kernel::actor::ActorImpl* get_issuer() const { return issuer_; }
   /** Whether this transition can currently be taken without blocking.
    *
    * For example, a mutex_lock is not enabled when the mutex is not free.
    * A comm_receive is not enabled before the corresponding send has been issued.
    */
-  virtual bool is_enabled() { return true; }
+  virtual bool is_enabled() const { return true; }
 
   /** Returns the amount of time that this transition can be used.
    *
@@ -32,7 +32,7 @@ public:
    * If it's more than one (as with mc_random or waitany), we need to consider this transition several times to start
    * differing branches
    */
-  virtual int get_max_consider() { return 1; }
+  virtual int get_max_consider() const { return 1; }
 
   /** Prepares the simcall to be used.
    *
@@ -43,13 +43,13 @@ public:
    *
    * The first time a simcall is considered, times_considered is 0, not 1.
    */
-  virtual void prepare(int times_considered) {}
+  virtual void prepare(int times_considered) { /* Nothing to do by default */}
 
   /** Some simcalls may only be observable under some circumstances.
    * Most simcalls are not visible from the MC because they don't have an inspector at all. */
-  virtual bool is_visible() { return true; }
-  virtual std::string to_string(int times_considered);
-  virtual std::string dot_label() = 0;
+  virtual bool is_visible() const { return true; }
+  virtual std::string to_string(int times_considered) const;
+  virtual std::string dot_label() const;
 };
 
 class RandomSimcall : public SimcallInspector {
@@ -59,11 +59,11 @@ class RandomSimcall : public SimcallInspector {
 
 public:
   RandomSimcall(smx_actor_t actor, int min, int max) : SimcallInspector(actor), min_(min), max_(max) {}
-  int get_max_consider() override;
+  int get_max_consider() const override;
   void prepare(int times_considered) override;
-  std::string to_string(int times_considered) override;
-  std::string dot_label() override;
-  int get_value();
+  std::string to_string(int times_considered) const override;
+  std::string dot_label() const override;
+  int get_value() const;
 };
 } // namespace mc
 } // namespace simgrid