Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix Manifest.in
[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() = default;
25   DependentIfSameValueAction(Type type, aid_t issuer, int value, int times_considered = 0)
26       : Transition(type, issuer, times_considered), value(value)
27   {
28   }
29   DependentIfSameValueAction(aid_t issuer, int value, int times_considered = 0)
30       : Transition(simgrid::mc::Transition::Type::UNKNOWN, issuer, times_considered), value(value)
31   {
32   }
33
34   // Dependent only with DependentAction (i.e. not itself)
35   bool depends(const Transition* other) const override
36   {
37     if (aid_ == other->aid_) {
38       return true;
39     }
40
41     if (const auto* same_value = dynamic_cast<const DependentIfSameValueAction*>(other); same_value != nullptr) {
42       return value == same_value->value;
43     }
44
45     // `DependentAction` is dependent with everyone who's not the `IndependentAction`
46     return dynamic_cast<const simgrid::mc::udpor::DependentAction*>(other) != nullptr;
47   }
48 };
49
50 } // namespace simgrid::mc::odpor
51
52 #endif