Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : #pragma once 10 : #include "MooseEnum.h" 11 : 12 : /** 13 : * Reporter producer/consumer modes 14 : * 15 : * @see Reporter, ReporterState, ReporterContext 16 : * 17 : * This is used to define the "mode" in which the value is being produced or consumed. The default 18 : * for both the producer and consumer is ROOT. This means that it is assumed that the 19 : * correct/complete value of the Reporter value exists on the root processor. 20 : * 21 : * On the producer side, it is the responsibility of the Reporter object to perform the necessary 22 : * operations to compute the value in the specified mode. The ReporterContext objects are helpers 23 : * for the producer to get the value in the desired mode. 24 : * 25 : * On the consumer side, if needed the data supplied will be converted to the correct mode 26 : * automatically if needed and possible. If the producer mode is not compatible with 27 : * the consumer mode, then an error is produced. The base ReporterContext handles the automatic 28 : * operations and error handling. 29 : * 30 : * The UNSET is used as the default to allow the ReporterContext objects to set the value 31 : * programmatically and error if it is set to something wrong by the user. 32 : */ 33 : class ReporterMode; 34 : extern const ReporterMode REPORTER_MODE_UNSET; 35 : extern const ReporterMode REPORTER_MODE_ROOT; 36 : extern const ReporterMode REPORTER_MODE_REPLICATED; 37 : extern const ReporterMode REPORTER_MODE_DISTRIBUTED; 38 : 39 : /** 40 : * MooseEnumItem that automatically creates the ID and doesn't allow the ID to be assigned 41 : * 42 : * This protects user from hitting an ID collision when creating custom modes. 43 : */ 44 : class ReporterMode : public MooseEnumItem 45 : { 46 : public: 47 : ReporterMode(const std::string & key); 48 : 49 : private: 50 : // Automatically incremented in construction 51 : static int ID_COUNTER; 52 : }; 53 : 54 : /** 55 : * MooseEnum designed for the ReporterContext objects to define how a ReporterValue can and is 56 : * being produced. The available items indicate how it can be produced and the current item is 57 : * how the value is being produced. 58 : * 59 : * @see ReporterContext.h 60 : */ 61 : class ReporterProducerEnum : public MooseEnum 62 : { 63 : public: 64 : ReporterProducerEnum(); 65 : 66 : /// Clear all available items (i.e., create an empty MooseEnum) 67 : void clear(); 68 : 69 : ///@{ 70 : /// Add possible items to the enumeration. 71 : template <typename... Args> 72 : void insert(const ReporterMode & mode, Args... modes); 73 : void insert(const ReporterMode & mode); 74 : ///@} 75 : }; 76 : 77 : template <typename... Args> 78 : void 79 155250 : ReporterProducerEnum::insert(const ReporterMode & mode, Args... modes) 80 : { 81 155250 : insert(mode); 82 155250 : insert(modes...); 83 155250 : }