Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Split TransitionAny and TransitionRandom to their own files
[simgrid.git] / src / mc / transition / TransitionRandom.cpp
diff --git a/src/mc/transition/TransitionRandom.cpp b/src/mc/transition/TransitionRandom.cpp
new file mode 100644 (file)
index 0000000..fb87d0d
--- /dev/null
@@ -0,0 +1,33 @@
+/* Copyright (c) 2015-2022. 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. */
+
+#include "src/mc/transition/TransitionRandom.hpp"
+#include "xbt/asserts.h"
+#include "xbt/string.hpp"
+
+#include <sstream>
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_trans_rand, mc_transition, "Logging specific to MC Random transitions");
+
+namespace simgrid {
+namespace mc {
+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)
+{
+  xbt_assert(stream >> min_ >> max_);
+}
+
+std::string RandomTransition::dot_label() const
+{
+  return Transition::dot_label() + to_c_str(type_);
+}
+
+} // namespace mc
+} // namespace simgrid