Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce the amount of header files loading xbt/string.hpp
[simgrid.git] / src / mc / transition / TransitionAny.cpp
1 /* Copyright (c) 2015-2022. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #include "src/mc/transition/TransitionAny.hpp"
7 #include "simgrid/config.h"
8 #include "xbt/asserts.h"
9 #include "xbt/string.hpp"
10 #if SIMGRID_HAVE_MC
11 #include "src/mc/ModelChecker.hpp"
12 #include "src/mc/api/RemoteApp.hpp"
13 #include "src/mc/api/State.hpp"
14 #endif
15
16 #include <sstream>
17
18 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_trans_any, mc_transition, "Logging specific to MC WaitAny / TestAny transitions");
19
20 namespace simgrid::mc {
21
22 TestAnyTransition::TestAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream)
23     : Transition(Type::TESTANY, issuer, times_considered)
24 {
25   int size;
26   xbt_assert(stream >> size);
27   for (int i = 0; i < size; i++) {
28     Transition* t = deserialize_transition(issuer, 0, stream);
29     XBT_DEBUG("TestAny received a transition %s", t->to_string(true).c_str());
30     transitions_.push_back(t);
31   }
32 }
33 std::string TestAnyTransition::to_string(bool verbose) const
34 {
35   auto res = xbt::string_printf("TestAny{ ");
36   for (auto const* t : transitions_)
37     res += t->to_string(verbose);
38   res += " }";
39   return res;
40 }
41 bool TestAnyTransition::depends(const Transition* other) const
42 {
43   return transitions_[times_considered_]->depends(other);
44 }
45 WaitAnyTransition::WaitAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream)
46     : Transition(Type::WAITANY, issuer, times_considered)
47 {
48   int size;
49   xbt_assert(stream >> size);
50   for (int i = 0; i < size; i++) {
51     Transition* t = deserialize_transition(issuer, 0, stream);
52     transitions_.push_back(t);
53   }
54 }
55 std::string WaitAnyTransition::to_string(bool verbose) const
56 {
57   auto res = xbt::string_printf("WaitAny{ ");
58   for (auto const* t : transitions_)
59     res += t->to_string(verbose);
60   res += " }";
61   return res;
62 }
63 bool WaitAnyTransition::depends(const Transition* other) const
64 {
65   return transitions_[times_considered_]->depends(other);
66 }
67
68 } // namespace simgrid::mc