TestTrigger.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
7 
8 #include <pup.h>
9 
10 #include "Evolution/EventsAndDenseTriggers/DenseTrigger.hpp"
11 #include "Options/Options.hpp"
13 #include "Utilities/Registration.hpp"
14 #include "Utilities/TMPL.hpp"
15 
16 namespace TestHelpers::DenseTriggers {
17 template <typename RegistrarList>
19 
20 namespace Registrars {
21 using TestTrigger =
23 } // namespace Registrars
24 
25 template <typename RegistrarList = tmpl::list<Registrars::TestTrigger>>
26 class TestTrigger : public DenseTrigger<RegistrarList> {
27  public:
28  /// \cond
29  TestTrigger() = default;
30  explicit TestTrigger(CkMigrateMessage* const msg) noexcept
32  using PUP::able::register_constructor;
33  WRAPPED_PUPable_decl_template(TestTrigger); // NOLINT
34  /// \endcond
35 
36  using Result = typename DenseTrigger<RegistrarList>::Result;
37 
38  struct IsReady {
39  using type = bool;
40  constexpr static Options::String help = "IsReady";
41  };
42 
43  struct IsTriggered {
44  using type = bool;
45  constexpr static Options::String help = "IsTriggered";
46  };
47 
48  struct NextCheck {
49  using type = double;
50  constexpr static Options::String help = "NextCheck";
51  };
52 
53  using options = tmpl::list<IsReady, IsTriggered, NextCheck>;
54  constexpr static Options::String help = "help";
55 
56  TestTrigger(const bool is_ready, const bool is_triggered,
57  const double next_check) noexcept
58  : is_ready_(is_ready),
59  is_triggered_(is_triggered),
60  next_check_(next_check) {}
61 
62  using is_triggered_argument_tags = tmpl::list<>;
63  Result is_triggered() const noexcept {
64  CHECK(is_ready_);
65  return {is_triggered_, next_check_};
66  }
67 
68  using is_ready_argument_tags = tmpl::list<>;
69  bool is_ready() const noexcept { return is_ready_; }
70 
71  // NOLINTNEXTLINE(google-runtime-references)
72  void pup(PUP::er& p) noexcept override {
74  p | is_ready_;
75  p | is_triggered_;
76  p | next_check_;
77  }
78 
79  private:
80  bool is_ready_;
81  bool is_triggered_;
82  double next_check_;
83 };
84 
85 /// \cond
86 template <typename RegistrarList>
87 PUP::able::PUP_ID TestTrigger<RegistrarList>::my_PUP_ID = 0; // NOLINT
88 /// \endcond
89 } // namespace TestHelpers::DenseTriggers
CharmPupable.hpp
Options.hpp
TestHelpers::DenseTriggers::TestTrigger
Definition: TestTrigger.hpp:18
TestingFramework.hpp
TestHelpers::DenseTriggers::TestTrigger::IsTriggered
Definition: TestTrigger.hpp:43
Registration::Registrar
A template for defining a registrar.
Definition: Registration.hpp:42
DenseTrigger
Definition: DenseTrigger.hpp:31
TestHelpers::DenseTriggers::TestTrigger::IsReady
Definition: TestTrigger.hpp:38
WRAPPED_PUPable_decl_template
#define WRAPPED_PUPable_decl_template(className)
Mark derived classes as serializable.
Definition: CharmPupable.hpp:22
DenseTrigger::Result
Result type for the is_triggered method.
Definition: DenseTrigger.hpp:38
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
TestHelpers::DenseTriggers::TestTrigger::NextCheck
Definition: TestTrigger.hpp:48
TMPL.hpp