Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
[simgrid.git] / src / mc / explo / odpor / odpor_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 odpor_tests_private.hpp
7  *
8  * A private header file for all ODPOR tests
9  */
10
11 #ifndef SIMGRID_MC_ODPOR_TEST_PRIVATE_HPP
12 #define SIMGRID_MC_ODPOR_TEST_PRIVATE_HPP
13
14 #include "src/mc/explo/udpor/udpor_tests_private.hpp"
15 #include "src/mc/transition/Transition.hpp"
16
17 namespace simgrid::mc::odpor {
18
19 struct DependentIfSameValueAction : public Transition {
20 private:
21   const int value;
22
23 public:
24   DependentIfSameValueAction(Type type, aid_t issuer, int value, int times_considered = 0)
25       : Transition(type, issuer, times_considered), value(value)
26   {
27   }
28   DependentIfSameValueAction(aid_t issuer, int value, int times_considered = 0)
29       : Transition(simgrid::mc::Transition::Type::UNKNOWN, issuer, times_considered), value(value)
30   {
31   }
32
33   // Dependent only with DependentAction (i.e. not itself)
34   bool depends(const Transition* other) const override
35   {
36     if (aid_ == other->aid_) {
37       return true;
38     }
39
40     if (const auto* same_value = dynamic_cast<const DependentIfSameValueAction*>(other); same_value != nullptr) {
41       return value == same_value->value;
42     }
43
44     // `DependentAction` is dependent with everyone who's not the `IndependentAction`
45     return dynamic_cast<const simgrid::mc::udpor::DependentAction*>(other) != nullptr;
46   }
47 };
48
49 } // namespace simgrid::mc::odpor
50
51 #endif