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/TMPL.hpp"
9 :
10 : namespace control_system::protocols {
11 : /*!
12 : * \brief Definition of a portion of a measurement for the control
13 : * systems
14 : *
15 : * These structs are referenced from structs conforming to the
16 : * Measurement protocol. They define independent parts of a control
17 : * system measurement, such as individual horizon-finds in a
18 : * two-horizon measurement.
19 : *
20 : * A conforming struct must provide
21 : *
22 : * - An `interpolation_target_tag` type alias templated on the \ref
23 : * ControlSystem "control systems" using this submeasurement. (This template
24 : * parameter must be used in the call to `RunCallbacks` discussed below.) This
25 : * alias may be `void` if the submeasurement does not use an interpolation
26 : * target tag. This is only used to collect the tags that must be registered
27 : * in the metavariables.
28 : * - A `horizon_metavars` type alias templated on the \ref ControlSystem
29 : * "control systems" using this submeasurement. (This template parameter must
30 : * be used in the call to `RunCallbacks` discussed below.) This alias may be
31 : * `void` if the submeasurement does not find a horizon. This is only used to
32 : * collect the tags that must be registered in the metavariables.
33 : * - An `event` type alias also templated on the \ref ControlSystem "control
34 : * systems" using this submeasurement which is an `::Event`. It is templated
35 : * on the control systems because the event usually takes the
36 : * `interpolation_target_tag` or `horizon_metavars` as a template parameter.
37 : * Currently, this event must be fully functional when it is default
38 : * constructed. It will not be constructed with any arguments.
39 : *
40 : * The `event` will be run on every element, and they must collectively
41 : * result in a single call on one chare (which need not be one of the element
42 : * chares) to `control_system::RunCallbacks<ConformingStructBeingDefinedHere,
43 : * ControlSystems>::apply`. This will almost always require performing a
44 : * reduction. The `ControlSystems` template parameter passed to `RunCallbacks`
45 : * here must be the same type that was passed to the `interpolation_target_tag`
46 : * (or `horizon_metavars`) and `event` type aliases. The `ControlSystems`
47 : * template parameter will be a list of all control systems that use the same
48 : * Submeasurement.
49 : *
50 : * Here's an example for a class conforming to this protocol:
51 : *
52 : * \snippet Helpers/ControlSystem/Examples.hpp Submeasurement
53 : */
54 1 : struct Submeasurement {
55 : template <typename ConformingType>
56 0 : struct test {
57 : struct DummyControlSystem;
58 :
59 0 : using interpolation_target_tag =
60 : typename ConformingType::template interpolation_target_tag<
61 : tmpl::list<DummyControlSystem>>;
62 :
63 0 : using horizon_metavars = typename ConformingType::template horizon_metavars<
64 : tmpl::list<DummyControlSystem>>;
65 :
66 0 : using event =
67 : typename ConformingType::template event<tmpl::list<DummyControlSystem>>;
68 : };
69 : };
70 : } // namespace control_system::protocols
|