Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/mwapl/simgrid
[simgrid.git] / src / mc / explo / udpor / udpor_tests_private.hpp
1 /* Copyright (c) 2007-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 /** @file udpor_tests_private.hpp
7  *
8  * A private header file for tests involving events in
9  * configurations
10  */
11
12 #ifndef SIMGRID_MC_UDPOR_TEST_PRIVATE_HPP
13 #define SIMGRID_MC_UDPOR_TEST_PRIVATE_HPP
14
15 #include "src/mc/transition/Transition.hpp"
16
17 namespace simgrid::mc::udpor {
18
19 struct IndependentAction : public Transition {
20   IndependentAction() = default;
21   IndependentAction(Type type, aid_t issuer, int times_considered = 0) : Transition(type, issuer, times_considered) {}
22   IndependentAction(aid_t issuer, int times_considered = 0)
23       : IndependentAction(simgrid::mc::Transition::Type::UNKNOWN, issuer, times_considered)
24   {
25   }
26
27   // Independent with everyone else (even if run by the same actor). NOTE: This is
28   // only for the convenience of testing: in general, transitions are dependent with
29   // one another if run by the same actor
30   bool depends(const Transition* other) const override
31   {
32     if (aid_ == other->aid_) {
33       return true;
34     }
35     return false;
36   }
37 };
38
39 struct DependentAction : public Transition {
40   DependentAction() = default;
41   DependentAction(Type type, aid_t issuer, int times_considered = 0) : Transition(type, issuer, times_considered) {}
42   DependentAction(aid_t issuer, int times_considered = 0)
43       : DependentAction(simgrid::mc::Transition::Type::UNKNOWN, issuer, times_considered)
44   {
45   }
46
47   // Dependent with everyone else (except IndependentAction)
48   bool depends(const Transition* other) const override
49   {
50     if (aid_ == other->aid_) {
51       return true;
52     }
53     return dynamic_cast<const IndependentAction*>(other) == nullptr;
54   }
55 };
56
57 struct ConditionallyDependentAction : public Transition {
58   ConditionallyDependentAction() = default;
59   ConditionallyDependentAction(Type type, aid_t issuer, int times_considered = 0)
60       : Transition(type, issuer, times_considered)
61   {
62   }
63   ConditionallyDependentAction(aid_t issuer, int times_considered = 0)
64       : ConditionallyDependentAction(simgrid::mc::Transition::Type::UNKNOWN, issuer, times_considered)
65   {
66   }
67
68   // Dependent only with DependentAction (i.e. not itself)
69   bool depends(const Transition* other) const override
70   {
71     if (aid_ == other->aid_) {
72       return true;
73     }
74     return dynamic_cast<const DependentAction*>(other) != nullptr;
75   }
76 };
77
78 } // namespace simgrid::mc::udpor
79
80 #endif