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