Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : /// Protocols related to observers 7 1 : namespace observers::protocols { 8 : /*! 9 : * \brief Conforming classes can create an informative message from reduction 10 : * data. The message will be printed to screen when the formatter is passed to a 11 : * reduction action such as `observers::Actions::ContributeReductionData`. 12 : * 13 : * Conforming classes must provide the following type aliases: 14 : * - `reduction_data`: The `Parallel::ReductionData` that the formatter is 15 : * applicable to. 16 : * 17 : * Conforming classes must implement the following member functions: 18 : * - `operator()`: A call operator that takes the values of the reduction data 19 : * and returns a `std::string`. The string should be an informative message 20 : * such as "Global minimum grid spacing at time 5.4 is: 0.1". 21 : * - `pup`: A PUP function for serialization. 22 : * 23 : * Here's an example for a formatter: 24 : * 25 : * \snippet Test_ReductionObserver.cpp formatter_example 26 : */ 27 1 : struct ReductionDataFormatter { 28 : template <typename ConformingType> 29 0 : struct test { 30 0 : using reduction_data = typename ConformingType::reduction_data; 31 : }; 32 : }; 33 : } // namespace observers::protocols