https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
13namespace moose
14{
15namespace internal
16{
17
18ExecFlagRegistry &
20{
21 static ExecFlagRegistry exec_flag_registry;
22 return exec_flag_registry;
23}
24
25const ExecFlagType &
26ExecFlagRegistry::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
MooseEnumItem ExecFlagType
Definition Moose.h:123
const std::set< ExecFlagType > & items() const
Reference the all the available items.
void addAvailableFlags(const ExecFlagType &flag, Args... flags)
Add additional execute_on flags to the list of possible flags.
int getNextValidID() const
Compute the next valid ID.
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.
Class for containing MooseEnum item information.
Registry for statically defining execute flags with consistent numbering.
ExecFlagEnum _default_flags
The default flags.
ExecFlagEnum _flags
The registered flags.
static ExecFlagRegistry & getExecFlagRegistry()
Return Singleton instance.
const ExecFlagType & registerFlag(const std::string &name, const bool is_default)
Registers an execute flag.
std::string toUpper(std::string name)
Convert supplied string to upper case.