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 : 10 : #pragma once 11 : 12 : #include "ExecFlagEnum.h" 13 : 14 : namespace moose 15 : { 16 : namespace internal 17 : { 18 : 19 : /** 20 : * Registry for statically defining execute flags with consistent numbering. 21 : */ 22 : class ExecFlagRegistry 23 : { 24 : public: 25 : /** 26 : * Registers an execute flag. 27 : * @param name The name of the execute flag. 28 : * @param is_default Whether or not to define the flag as a default (available to all objects that 29 : * use the SetupInterface). 30 : */ 31 : const ExecFlagType & registerFlag(const std::string & name, const bool is_default); 32 : 33 : /** 34 : * \returns The registered exec flags. 35 : */ 36 62755 : const ExecFlagEnum & getFlags() const { return _flags; }; 37 : 38 : /** 39 : * \returns The registered default exec flags. 40 : */ 41 16955876 : const ExecFlagEnum & getDefaultFlags() const { return _default_flags; }; 42 : 43 : /// Return Singleton instance 44 : static ExecFlagRegistry & getExecFlagRegistry(); 45 : 46 : ///@{ Don't allow creation through copy/move construction or assignment 47 : ExecFlagRegistry(ExecFlagRegistry const &) = delete; 48 : ExecFlagRegistry & operator=(ExecFlagRegistry const &) = delete; 49 : 50 : ExecFlagRegistry(ExecFlagRegistry &&) = delete; 51 : ExecFlagRegistry & operator=(ExecFlagRegistry &&) = delete; 52 : ///@} 53 : 54 : private: 55 : // Private constructor for singleton pattern 56 51208 : ExecFlagRegistry() {} 57 : 58 : /// The registered flags 59 : ExecFlagEnum _flags; 60 : 61 : /// The default flags 62 : ExecFlagEnum _default_flags; 63 : }; 64 : 65 : } // internal 66 : } // moose 67 : 68 : #define registerExecFlag(flag) \ 69 : moose::internal::ExecFlagRegistry::getExecFlagRegistry().registerFlag(flag, false) 70 : #define registerDefaultExecFlag(flag) \ 71 : moose::internal::ExecFlagRegistry::getExecFlagRegistry().registerFlag(flag, true)