Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include "DataStructures/DataBox/DataBox.hpp" 7 : #include "Parallel/Tags/Metavariables.hpp" 8 : #include "Utilities/CallWithDynamicType.hpp" 9 : #include "Utilities/Serialization/CharmPupable.hpp" 10 : #include "Utilities/TMPL.hpp" 11 : 12 : /// \ingroup EventsAndTriggersGroup 13 : namespace Triggers {} 14 : 15 : /// \ingroup EventsAndTriggersGroup 16 : /// Base class for checking whether to run an Event. 17 1 : class Trigger : public PUP::able { 18 : protected: 19 : /// \cond 20 : Trigger() = default; 21 : Trigger(const Trigger&) = default; 22 : Trigger(Trigger&&) = default; 23 : Trigger& operator=(const Trigger&) = default; 24 : Trigger& operator=(Trigger&&) = default; 25 : /// \endcond 26 : 27 : public: 28 0 : ~Trigger() override = default; 29 : 30 0 : WRAPPED_PUPable_abstract(Trigger); // NOLINT 31 : 32 : template <typename DbTags> 33 0 : bool is_triggered(const db::DataBox<DbTags>& box) const { 34 : using factory_classes = 35 : typename std::decay_t<decltype(db::get<Parallel::Tags::Metavariables>( 36 : box))>::factory_creation::factory_classes; 37 : return call_with_dynamic_type<bool, tmpl::at<factory_classes, Trigger>>( 38 : this, [&box](auto* const trigger) { return db::apply(*trigger, box); }); 39 : } 40 : };