Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
further reduce the amount of call sites for RemoteProcess::actors()
[simgrid.git] / src / mc / api.hpp
index f871ee6..2a9d250 100644 (file)
 #include <vector>
 
 #include "simgrid/forward.h"
+#include "src/mc/Session.hpp"
 #include "src/mc/api/State.hpp"
 #include "src/mc/mc_forward.hpp"
 #include "src/mc/mc_record.hpp"
 #include "xbt/automaton.hpp"
 #include "xbt/base.h"
 
-namespace simgrid {
-namespace mc {
+namespace simgrid::mc {
 
-XBT_DECLARE_ENUM_CLASS(CheckerAlgorithm, Safety, UDPOR, Liveness, CommDeterminism);
-
-/**
- * @brief Maintains the transition's information.
- */
-struct s_transition_detail {
-  simgrid::simix::Simcall call_ = simgrid::simix::Simcall::NONE;
-  long issuer_id                = -1;
-  RemotePtr<kernel::activity::MailboxImpl> mbox_remote_addr {}; // used to represent mailbox remote address for isend and ireceive transitions
-  RemotePtr<kernel::activity::ActivityImpl> comm_remote_addr {}; // the communication this transition concerns (to be used only for isend, ireceive, wait and test)
-};
-
-using transition_detail_t = std::unique_ptr<s_transition_detail>;
+XBT_DECLARE_ENUM_CLASS(ExplorationAlgorithm, Safety, UDPOR, Liveness, CommDeterminism);
 
 /*
 ** This class aimes to implement FACADE APIs for simgrid. The FACADE layer sits between the CheckerSide
@@ -48,10 +36,12 @@ private:
   struct DerefAndCompareByActorsCountAndUsedHeap {
     template <class X, class Y> bool operator()(X const& a, Y const& b) const
     {
-      return std::make_pair(a->actors_count, a->heap_bytes_used) < std::make_pair(b->actors_count, b->heap_bytes_used);
+      return std::make_pair(a->actor_count_, a->heap_bytes_used) < std::make_pair(b->actor_count_, b->heap_bytes_used);
     }
   };
 
+  std::unique_ptr<simgrid::mc::Session> session_;
+
 public:
   // No copy:
   Api(Api const&) = delete;
@@ -63,16 +53,12 @@ public:
     return api;
   }
 
-  simgrid::mc::Checker* initialize(char** argv, simgrid::mc::CheckerAlgorithm algo) const;
+  simgrid::mc::Exploration* initialize(char** argv, const std::unordered_map<std::string, std::string>& env,
+                                       simgrid::mc::ExplorationAlgorithm algo);
 
   // ACTOR APIs
-  std::vector<simgrid::mc::ActorInformation>& get_actors() const;
   unsigned long get_maxpid() const;
 
-  // COMMUNICATION APIs
-  xbt::string const& get_actor_name(smx_actor_t actor) const;
-  xbt::string const& get_actor_host_name(smx_actor_t actor) const;
-
   // REMOTE APIs
   std::size_t get_remote_heap_bytes() const;
 
@@ -81,23 +67,19 @@ public:
   unsigned long mc_get_visited_states() const;
   XBT_ATTRIB_NORETURN void mc_exit(int status) const;
 
-  // SIMCALL APIs
-  std::string request_get_dot_output(const Transition* t) const;
-
   // STATE APIs
-  void restore_state(std::shared_ptr<simgrid::mc::Snapshot> system_state) const;
+  void restore_state(const Snapshot* system_state) const;
 
   // SNAPSHOT APIs
   bool snapshot_equal(const Snapshot* s1, const Snapshot* s2) const;
   simgrid::mc::Snapshot* take_snapshot(long num_state) const;
 
   // SESSION APIs
-  void s_close() const;
+  simgrid::mc::Session const& get_session() const { return *session_; }
+  void s_close();
 
-// AUTOMATION APIs
-#if SIMGRID_HAVE_MC
+  // AUTOMATION APIs
   void automaton_load(const char* file) const;
-#endif
   std::vector<int> automaton_propositional_symbol_evaluate() const;
   std::vector<xbt_automaton_state_t> get_automaton_state() const;
   int compare_automaton_exp_label(const xbt_automaton_exp_label* l) const;
@@ -106,18 +88,10 @@ public:
   {
     return DerefAndCompareByActorsCountAndUsedHeap();
   }
-  inline int automaton_state_compare(const_xbt_automaton_state_t const& s1, const_xbt_automaton_state_t const& s2) const
-  {
-    return xbt_automaton_state_compare(s1, s2);
-  }
   xbt_automaton_exp_label_t get_automaton_transition_label(xbt_dynar_t const& dynar, int index) const;
   xbt_automaton_state_t get_automaton_transition_dst(xbt_dynar_t const& dynar, int index) const;
-
-  // DYNAR APIs
-  inline unsigned long get_dynar_length(const_xbt_dynar_t const& dynar) const { return xbt_dynar_length(dynar); }
 };
 
-} // namespace mc
-} // namespace simgrid
+} // namespace simgrid::mc
 
 #endif