1 /* Copyright (c) 2015-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "src/mc/transition/TransitionAny.hpp"
7 #include "simgrid/config.h"
8 #include "xbt/asserts.h"
9 #include "xbt/string.hpp"
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_trans_any, mc_transition, "Logging specific to MC WaitAny / TestAny transitions");
15 namespace simgrid::mc {
17 TestAnyTransition::TestAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream)
18 : Transition(Type::TESTANY, issuer, times_considered)
21 xbt_assert(stream >> size);
22 for (int i = 0; i < size; i++) {
23 Transition* t = deserialize_transition(issuer, 0, stream);
24 XBT_INFO("TestAny received a transition %s", t->to_string(true).c_str());
25 transitions_.push_back(t);
28 std::string TestAnyTransition::to_string(bool verbose) const
30 auto res = xbt::string_printf("TestAny(%s){ ", this->result() ? "TRUE" : "FALSE");
31 for (auto const* t : transitions_) {
32 res += t->to_string(verbose);
38 bool TestAnyTransition::depends(const Transition* other) const
40 // Actions executed by the same actor are always dependent
41 if (other->aid_ == aid_)
44 return transitions_[times_considered_]->depends(other);
46 WaitAnyTransition::WaitAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream)
47 : Transition(Type::WAITANY, issuer, times_considered)
50 xbt_assert(stream >> size);
51 for (int i = 0; i < size; i++) {
52 Transition* t = deserialize_transition(issuer, 0, stream);
53 XBT_INFO("WaitAny received transition %d/%d %s", (i + 1), size, t->to_string(true).c_str());
54 transitions_.push_back(t);
57 std::string WaitAnyTransition::to_string(bool verbose) const
59 auto res = xbt::string_printf("WaitAny{ ");
60 for (auto const* t : transitions_)
61 res += t->to_string(verbose);
62 res += " } (times considered = " + std::to_string(times_considered_) + ")";
65 bool WaitAnyTransition::depends(const Transition* other) const
67 // Actions executed by the same actor are always dependent
68 if (other->aid_ == aid_)
70 return transitions_[times_considered_]->depends(other);
73 } // namespace simgrid::mc