Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplify the serialization protocol to implement TestAny & WaitAny in a moment
[simgrid.git] / src / mc / api / Transition.hpp
index 9955b01..8b8458b 100644 (file)
@@ -8,7 +8,9 @@
 #define SIMGRID_MC_TRANSITION_HPP
 
 #include "simgrid/forward.h" // aid_t
+#include "xbt/utility.hpp"   // XBT_DECLARE_ENUM_CLASS
 
+#include <sstream>
 #include <string>
 
 namespace simgrid {
@@ -29,10 +31,10 @@ class Transition {
 
   friend State; // FIXME remove this once we have a proper class to handle the statistics
 
-protected:
-  std::string textual_ = "";
-
 public:
+  XBT_DECLARE_ENUM_CLASS(Type, UNKNOWN, RANDOM, COMM_RECV, COMM_SEND, COMM_TEST, COMM_WAIT);
+  Type type_ = Type::UNKNOWN;
+
   aid_t aid_ = 0;
 
   /* Which transition was executed for this simcall
@@ -46,11 +48,14 @@ public:
   int times_considered_ = 0;
 
   Transition() = default;
+  Transition(Type type, aid_t issuer, int times_considered)
+      : type_(type), aid_(issuer), times_considered_(times_considered)
+  {
+  }
   virtual ~Transition();
-  Transition(aid_t issuer, int times_considered) : aid_(issuer), times_considered_(times_considered) {}
 
-  virtual std::string to_string(bool verbose = false);
-  const char* to_cstring(bool verbose = false);
+  virtual std::string to_string(bool verbose = false) const;
+  virtual std::string dot_label() const;
 
   /* Moves the application toward a path that was already explored, but don't change the current transition */
   void replay() const;
@@ -63,6 +68,17 @@ public:
   static unsigned long get_replayed_transitions() { return replayed_transitions_; }
 };
 
+class RandomTransition : public Transition {
+  int min_;
+  int max_;
+
+public:
+  std::string to_string(bool verbose) const override;
+  std::string dot_label() const override;
+  RandomTransition(aid_t issuer, int times_considered, std::stringstream& stream);
+  bool depends(const Transition* other) const override { return false; } // Independent with any other transition
+};
+
 } // namespace mc
 } // namespace simgrid