Trigger.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
9 #include "Utilities/FakeVirtual.hpp"
10 #include "Utilities/Registration.hpp"
11 #include "Utilities/TMPL.hpp"
12 
13 /// \cond
14 namespace Triggers {
15 template <typename TriggerRegistrars>
16 class Always;
17 template <typename TriggerRegistrars>
18 class And;
19 template <typename TriggerRegistrars>
20 class Not;
21 template <typename TriggerRegistrars>
22 class Or;
23 } // namespace Triggers
24 /// \endcond
25 
26 /// \ingroup EventsAndTriggersGroup
27 namespace Triggers {
28 /// Registrars for Triggers
29 namespace Registrars {}
30 } // namespace Triggers
31 
32 /// \ingroup EventsAndTriggersGroup
33 /// Base class for checking whether to run an Event.
34 template <typename TriggerRegistrars>
35 class Trigger : public PUP::able {
36  protected:
37  /// \cond
38  Trigger() = default;
39  Trigger(const Trigger&) = default;
40  Trigger(Trigger&&) = default;
41  Trigger& operator=(const Trigger&) = default;
42  Trigger& operator=(Trigger&&) = default;
43  /// \endcond
44 
45  public:
46  ~Trigger() override = default;
47 
49 
50  using default_triggers = tmpl::list<
53 
54  using creatable_classes =
55  tmpl::append<default_triggers,
57 
58  template <typename DbTags>
59  bool is_triggered(const db::DataBox<DbTags>& box) noexcept {
60  return call_with_dynamic_type<bool, creatable_classes>(
61  this,
62  [&box](auto* const trigger) noexcept {
63  using TriggerType = std::decay_t<decltype(*trigger)>;
64  return db::apply<typename TriggerType::argument_tags>(
65  *trigger, box);
66  });
67  }
68 };
69 
70 #include "Evolution/EventsAndTriggers/LogicalTriggers.hpp"
tmpl::transform< tmpl::remove_duplicates< RegistrarList >, detail::registrant< tmpl::pin< tmpl::remove_duplicates< RegistrarList > >, tmpl::_1 > > registrants
Transform a list of registrars into the list of associated registrants. This is usually used to defin...
Definition: Registration.hpp:65
Always triggers. This trigger is automatically registered.
Definition: LogicalTriggers.hpp:17
Defines macros to allow serialization of abstract template base classes.
Negates another trigger. This trigger is automatically registered.
Definition: LogicalTriggers.hpp:38
Defines classes and functions used for manipulating DataBox&#39;s.
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Short-circuiting logical AND of other triggers. This trigger is automatically registered.
Definition: LogicalTriggers.hpp:73
Short-circuiting logical OR of other triggers. This trigger is automatically registered.
Definition: LogicalTriggers.hpp:114
#define WRAPPED_PUPable_abstract(className)
Wraps the Charm++ macro, see the Charm++ documentation.
Definition: CharmPupable.hpp:39
Wraps the template metaprogramming library used (brigand)
Defines class template ConstGlobalCache.
Base class for checking whether to run an Event.
Definition: Trigger.hpp:35
Definition: LogicalTriggers.hpp:13