Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <type_traits> 7 : 8 : #include "Utilities/ProtocolHelpers.hpp" 9 : 10 0 : namespace db::protocols { 11 : 12 : /// \brief A DataBox mutator 13 : /// 14 : /// A class conforming to this protocol can be used as the template argument for 15 : /// a call to db::mutate_apply(const gsl::not_null<DataBox<BoxTags>*> box, 16 : /// Args&&... args). The conforming class must provide the following: 17 : /// 18 : /// - `return_tags`: A type list of tags corresponding to mutable items in the 19 : /// DataBox passed to `db::mutate_apply` that may be modified. 20 : /// - `argument_tags`: A type list of tags corresponding to items in the DataBox 21 : /// passed to `db::mutate_apply` that may not be modified. 22 : /// - `apply`: A static function whose return value is returned by 23 : /// `db::mutate_apply`, and that takes as arguments: 24 : /// - A `const gsl::not_null<Tag::type*>` for each `Tag` in `return_tags` 25 : /// - A `const db::const_item_type<Tag, BoxTags>` for each `Tag` in 26 : /// `argument_tags` 27 : /// - The additional arguments passed to `db::mutate_apply` 28 : /// 29 : /// Note: use the explicit type whenever possible, not the type aliases. 30 : /// `db::const_item_type` will usually be `Tag::type` unless that is a 31 : /// `std::unique_ptr<T>`, in which case it will be `T` 32 : /// 33 : /// Here is an example for a class conforming to this protocol: 34 : /// 35 : /// \snippet DataBox/Examples.hpp mutator_protocol 36 1 : struct Mutator { 37 : template <typename ConformingType> 38 0 : struct test { 39 0 : using argument_tags = typename ConformingType::argument_tags; 40 0 : using return_tags = typename ConformingType::return_tags; 41 : }; 42 : }; 43 : } // namespace db::protocols