Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
96a721226cfb87cdd9eb46113cdbed1a67c788e9
[simgrid.git] / src / mc / transition / TransitionAny.hpp
1 /* Copyright (c) 2015-2023. 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 #ifndef SIMGRID_MC_TRANSITION_ANY_HPP
7 #define SIMGRID_MC_TRANSITION_ANY_HPP
8
9 #include "src/kernel/actor/SimcallObserver.hpp"
10 #include "src/mc/transition/Transition.hpp"
11 #include "src/mc/transition/TransitionComm.hpp"
12
13 #include <algorithm>
14 #include <sstream>
15 #include <string>
16
17 namespace simgrid::mc {
18
19 class TestAnyTransition : public Transition {
20   std::vector<Transition*> transitions_;
21
22 public:
23   TestAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream);
24   std::string to_string(bool verbose) const override;
25   bool depends(const Transition* other) const override;
26
27   Transition* get_current_transition() const { return transitions_.at(times_considered_); }
28   bool result() const
29   {
30     return std::any_of(begin(transitions_), end(transitions_), [](const Transition* transition) {
31       const auto* tested_transition = static_cast<const CommTestTransition*>(transition);
32       return (tested_transition->get_sender() != -1 && tested_transition->get_receiver() != -1);
33     });
34   }
35 };
36
37 class WaitAnyTransition : public Transition {
38   std::vector<Transition*> transitions_;
39
40 public:
41   WaitAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream);
42   std::string to_string(bool verbose) const override;
43   bool depends(const Transition* other) const override;
44
45   Transition* get_current_transition() const { return transitions_.at(times_considered_); }
46 };
47
48 } // namespace simgrid::mc
49
50 #endif