Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into 'python_bindings_host_load_plugin'
[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 <sstream>
14 #include <string>
15
16 namespace simgrid::mc {
17
18 class TestAnyTransition : public Transition {
19   std::vector<Transition*> transitions_;
20
21 public:
22   TestAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream);
23   std::string to_string(bool verbose) const override;
24   bool depends(const Transition* other) const override;
25
26   Transition* get_current_transition() const { return transitions_.at(times_considered_); }
27   bool result() const
28   {
29     return std::any_of(begin(transitions_), end(transitions_), [](const Transition* transition) {
30       const auto* tested_transition = static_cast<const CommTestTransition*>(transition);
31       return (tested_transition->get_sender() != -1 && tested_transition->get_receiver() != -1);
32     });
33   }
34 };
35
36 class WaitAnyTransition : public Transition {
37   std::vector<Transition*> transitions_;
38
39 public:
40   WaitAnyTransition(aid_t issuer, int times_considered, std::stringstream& stream);
41   std::string to_string(bool verbose) const override;
42   bool depends(const Transition* other) const override;
43
44   Transition* get_current_transition() const { return transitions_.at(times_considered_); }
45 };
46
47 } // namespace simgrid::mc
48
49 #endif