Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Split TransitionAny and TransitionRandom to their own files
[simgrid.git] / src / mc / transition / TransitionComm.cpp
similarity index 70%
rename from src/mc/api/TransitionComm.cpp
rename to src/mc/transition/TransitionComm.cpp
index cab3f10..8aaf811 100644 (file)
@@ -3,7 +3,7 @@
 /* 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/api/TransitionComm.hpp"
+#include "src/mc/transition/TransitionComm.hpp"
 #include "xbt/asserts.h"
 #include <simgrid/config.h>
 #if SIMGRID_HAVE_MC
@@ -163,51 +163,6 @@ std::string CommSendTransition::to_string(bool verbose = false) const
   res += ")";
   return res;
 }
-TestAnyTransition::TestAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream)
-    : Transition(Type::TESTANY, issuer, times_considered)
-{
-  int size;
-  xbt_assert(stream >> size);
-  for (int i = 0; i < size; i++) {
-    Transition* t = deserialize_transition(issuer, 0, stream);
-    XBT_DEBUG("TestAny received a transition %s", t->to_string(true).c_str());
-    transitions_.push_back(t);
-  }
-}
-std::string TestAnyTransition::to_string(bool verbose) const
-{
-  auto res = xbt::string_printf("%ld: TestAny{ ", aid_);
-  for (auto const* t : transitions_)
-    res += t->to_string(verbose);
-  res += "}";
-  return res;
-}
-bool TestAnyTransition::depends(const Transition* other) const
-{
-  return transitions_[times_considered_]->depends(other);
-}
-WaitAnyTransition::WaitAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream)
-    : Transition(Type::WAITANY, issuer, times_considered)
-{
-  int size;
-  xbt_assert(stream >> size);
-  for (int i = 0; i < size; i++) {
-    Transition* t = deserialize_transition(issuer, 0, stream);
-    transitions_.push_back(t);
-  }
-}
-std::string WaitAnyTransition::to_string(bool verbose) const
-{
-  auto res = xbt::string_printf("%ld: WaitAny{ ", aid_);
-  for (auto const* t : transitions_)
-    res += t->to_string(verbose);
-  res += "}";
-  return res;
-}
-bool WaitAnyTransition::depends(const Transition* other) const
-{
-  return transitions_[times_considered_]->depends(other);
-}
 
 bool CommSendTransition::depends(const Transition* other) const
 {
@@ -245,38 +200,5 @@ bool CommSendTransition::depends(const Transition* other) const
   return true;
 }
 
-Transition* deserialize_transition(aid_t issuer, int times_considered, std::stringstream& stream)
-{
-  short type;
-  xbt_assert(stream >> type);
-  xbt_assert(type >= 0 && type <= static_cast<short>(Transition::Type::UNKNOWN), "Invalid transition type %d received",
-             type);
-
-  auto simcall = static_cast<Transition::Type>(type);
-
-  switch (simcall) {
-    case Transition::Type::COMM_RECV:
-      return new CommRecvTransition(issuer, times_considered, stream);
-    case Transition::Type::COMM_SEND:
-      return new CommSendTransition(issuer, times_considered, stream);
-    case Transition::Type::COMM_TEST:
-      return new CommTestTransition(issuer, times_considered, stream);
-    case Transition::Type::COMM_WAIT:
-      return new CommWaitTransition(issuer, times_considered, stream);
-
-    case Transition::Type::TESTANY:
-      return new TestAnyTransition(issuer, times_considered, stream);
-    case Transition::Type::WAITANY:
-      return new WaitAnyTransition(issuer, times_considered, stream);
-
-    case Transition::Type::RANDOM:
-      return new RandomTransition(issuer, times_considered, stream);
-
-    case Transition::Type::UNKNOWN:
-      return new Transition(Transition::Type::UNKNOWN, issuer, times_considered);
-  }
-  THROW_IMPOSSIBLE; // Some compilers don't detect that each branch of the above switch has a return
-}
-
 } // namespace mc
 } // namespace simgrid