https://mooseframework.inl.gov
ExecFlagRegistry.C
Go to the documentation of this file.
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 #include "ExecFlagRegistry.h"
11 #include "MooseUtils.h"
12 
13 namespace moose
14 {
15 namespace internal
16 {
17 
18 ExecFlagRegistry &
20 {
21  static ExecFlagRegistry exec_flag_registry;
22  return exec_flag_registry;
23 }
24 
25 const ExecFlagType &
26 ExecFlagRegistry::registerFlag(const std::string & name, const bool is_default)
27 {
28  const auto name_upper = MooseUtils::toUpper(name);
29  const auto flag_iter = _flags.find(name_upper);
30  if (flag_iter != _flags.items().end())
31  {
32  // Assume that this is not a duplicate name, but a "double registration" due
33  // to the dynamic load functionality.
34  return *flag_iter;
35  }
36 
37  const auto & flag = _flags.addAvailableFlags(ExecFlagType(name_upper, _flags.getNextValidID()));
38 
39  if (is_default)
41 
42  return flag;
43 }
44 
45 } // internal
46 } // moose
std::string name(const ElemQuality q)
int getNextValidID() const
Compute the next valid ID.
Registry for statically defining execute flags with consistent numbering.
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
MooseEnumItem ExecFlagType
Definition: Moose.h:113
void addAvailableFlags(const ExecFlagType &flag, Args... flags)
Add additional execute_on flags to the list of possible flags.
Definition: ExecFlagEnum.h:82
static ExecFlagRegistry & getExecFlagRegistry()
Return Singleton instance.
const ExecFlagType & registerFlag(const std::string &name, const bool is_default)
Registers an execute flag.
const std::set< ExecFlagType > & items() const
Reference the all the available items.
Definition: ExecFlagEnum.h:71
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
ExecFlagEnum _flags
The registered flags.
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.
ExecFlagEnum _default_flags
The default flags.