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 "DataStructures/DataBox/MetavariablesTag.hpp" 8 : #include "Utilities/CallWithDynamicType.hpp" 9 : #include "Utilities/Serialization/CharmPupable.hpp" 10 : #include "Utilities/TMPL.hpp" 11 : 12 : /*! 13 : * \ingroup EventsAndTriggersGroup 14 : * \brief Contains the available triggers. 15 : */ 16 : namespace Triggers {} 17 : 18 : /// \ingroup EventsAndTriggersGroup 19 : /// Base class for checking whether to run an Event. 20 1 : class Trigger : public PUP::able { 21 : protected: 22 : /// \cond 23 : Trigger() = default; 24 : Trigger(const Trigger&) = default; 25 : Trigger(Trigger&&) = default; 26 : Trigger& operator=(const Trigger&) = default; 27 : Trigger& operator=(Trigger&&) = default; 28 : /// \endcond 29 : 30 : public: 31 0 : ~Trigger() override = default; 32 : 33 0 : WRAPPED_PUPable_abstract(Trigger); // NOLINT 34 : 35 : template <typename DbTags> 36 0 : bool is_triggered(const db::DataBox<DbTags>& box) const { 37 : using factory_classes = 38 : typename std::decay_t<decltype(db::get<Parallel::Tags::Metavariables>( 39 : box))>::factory_creation::factory_classes; 40 : return call_with_dynamic_type<bool, tmpl::at<factory_classes, Trigger>>( 41 : this, [&box](auto* const trigger) { return db::apply(*trigger, box); }); 42 : } 43 : };