]> AND Public Git Repository - simgrid.git/blobdiff - src/mc/api/Transition.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Blank lines (codefactor.io).
[simgrid.git] / src / mc / api / Transition.cpp
index 40caa931a88383fd9c9fc3e8854ae16917bcbad2..5e63923ade4fdecc820b932ba7e38c9f12efad53 100644 (file)
@@ -5,7 +5,9 @@
 
 #include "src/mc/api/Transition.hpp"
 #include "xbt/asserts.h"
+#include "xbt/string.hpp"
 #include <simgrid/config.h>
+
 #if SIMGRID_HAVE_MC
 #include "src/mc/ModelChecker.hpp"
 #endif
@@ -19,32 +21,40 @@ namespace mc {
 unsigned long Transition::executed_transitions_ = 0;
 unsigned long Transition::replayed_transitions_ = 0;
 
-Transition::~Transition() {
-} // Make sure that we have a vtable for Transition by putting this virtual function out of the header
+// Do not move this to the header, to ensure that we have a vtable for Transition
+Transition::~Transition() = default;
 
-std::string Transition::to_string(bool verbose)
-{
-  return textual_;
-}
-const char* Transition::to_cstring(bool verbose)
+std::string Transition::to_string(bool) const
 {
-  to_string();
-  return textual_.c_str();
+  return "";
 }
-void Transition::init(aid_t aid, int times_considered)
+std::string Transition::dot_label() const
 {
-  aid_              = aid;
-  times_considered_ = times_considered;
+  return xbt::string_printf("[(%ld)] %s", aid_, Transition::to_c_str(type_));
 }
 void Transition::replay() const
 {
   replayed_transitions_++;
 
 #if SIMGRID_HAVE_MC
-  mc_model_checker->handle_simcall(*this, false);
+  mc_model_checker->handle_simcall(aid_, times_considered_, false);
   mc_model_checker->wait_for_requests();
 #endif
 }
+std::string RandomTransition::to_string(bool verbose) const
+{
+  return xbt::string_printf("Random([%d;%d] ~> %d)", min_, max_, times_considered_);
+}
+
+RandomTransition::RandomTransition(aid_t issuer, int times_considered, std::stringstream& stream)
+    : Transition(Type::RANDOM, issuer, times_considered)
+{
+  stream >> min_ >> max_;
+}
+std::string RandomTransition::dot_label() const
+{
+  return Transition::dot_label() + to_c_str(type_);
+}
 
 } // namespace mc
 } // namespace simgrid