www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ExecFlagEnum Class Reference

A MultiMooseEnum object to hold "execute_on" flags. More...

#include <ExecFlagEnum.h>

Inheritance diagram for ExecFlagEnum:
[legend]

Public Member Functions

 ExecFlagEnum ()
 
 ExecFlagEnum (const ExecFlagEnum &other)
 
 ExecFlagEnum (const MultiMooseEnum &other)
 
std::string getDocString () const
 Generate a documentation string for the "execute_on" parameter. More...
 
const std::set< ExecFlagType > & items () const
 Reference the all the available items. More...
 
const std::string & operator[] (unsigned int i) const
 Indexing operator Operator to retrieve an item from the MultiMooseEnum. More...
 
unsigned int get (unsigned int i) const
 Indexing operator Operator to retrieve an item from the MultiMooseEnum. More...
 
void clear ()
 Clear the MultiMooseEnum. More...
 
unsigned int size () const
 Return the number of items in the MultiMooseEnum. More...
 
virtual bool isValid () const override
 IsValid. More...
 
virtual void deprecate (const std::string &name, const std::string &raw_name="")
 Deprecates various options in the MOOSE enum. More...
 
std::vector< std::string > getNames () const
 Method for returning a vector of all valid enumeration names for this instance. More...
 
std::string getRawNames () const
 Method for returning the raw name strings for this instance. More...
 
std::vector< int > getIDs () const
 Method for returning a vector of ids for this instance. More...
 
bool isOutOfRangeAllowed () const
 isOutOfRangeAllowed More...
 
const std::set< MooseEnumItem > & items ()
 Return the complete set of available flags. More...
 
int getNextValidID () const
 Compute the next valid ID. More...
 
template<typename... Args>
void addAvailableFlags (const ExecFlagType &flag, Args... flags)
 Add additional execute_on flags to the list of possible flags. More...
 
void addAvailableFlags (const ExecFlagType &flag)
 
ExecFlagEnumoperator= (const std::initializer_list< ExecFlagType > &flags)
 
ExecFlagEnumoperator= (const ExecFlagType &flags)
 
ExecFlagEnumoperator+= (const std::initializer_list< ExecFlagType > &flags)
 
ExecFlagEnumoperator+= (const ExecFlagType &flags)
 
MultiMooseEnumoperator= (const std::string &names)
 Assignment operators for setting the current flags. More...
 
MultiMooseEnumoperator= (const std::vector< std::string > &names)
 Assignment operators for setting the current flags. More...
 
MultiMooseEnumoperator= (const std::set< std::string > &names)
 Assignment operators for setting the current flags. More...
 
template<typename... Args>
void removeAvailableFlags (const ExecFlagType &flag, Args... flags)
 Remove flags from being available. More...
 
void removeAvailableFlags (const ExecFlagType &flag)
 
bool operator== (const MultiMooseEnum &value) const
 Comparison operators for comparing with character constants, MultiMooseEnums or integer values. More...
 
bool operator!= (const MultiMooseEnum &value) const
 
bool contains (const std::string &value) const
 Contains methods for seeing if a value is in the MultiMooseEnum. More...
 
bool contains (int value) const
 
bool contains (unsigned short value) const
 
bool contains (const MultiMooseEnum &value) const
 
bool contains (const MooseEnumItem &value) const
 
void erase (const std::string &names)
 Un-assign a value. More...
 
void erase (const std::vector< std::string > &names)
 
void erase (const std::set< std::string > &names)
 
void push_back (const std::string &names)
 Insert operators Operator to insert (push_back) values into the enum. More...
 
void push_back (const std::vector< std::string > &names)
 
void push_back (const std::set< std::string > &names)
 
MooseEnumIterator begin () const
 Returns a begin/end iterator to all of the items in the enum. More...
 
MooseEnumIterator end () const
 
std::set< MooseEnumItem >::const_iterator find (const MooseEnumItem &other) const
 Locate an item. More...
 
std::set< MooseEnumItem >::const_iterator find (const std::string &name) const
 
std::set< MooseEnumItem >::const_iterator find (int id) const
 

Protected Member Functions

void appendCurrent (const ExecFlagType &item)
 Append the list of current flags. More...
 
virtual void checkDeprecated () const override
 Check whether any of the current values are deprecated when called. More...
 
void checkDeprecated (const MooseEnumItem &item) const
 Check and warn deprecated values. More...
 
template<typename InputIterator >
MultiMooseEnumassign (InputIterator first, InputIterator last, bool append)
 Helper method for all inserts and assignment operators. More...
 
template<typename InputIterator >
void remove (InputIterator first, InputIterator last)
 Helper method for un-assigning enumeration values. More...
 
void setCurrentItems (const std::vector< MooseEnumItem > &current)
 Set the current items. More...
 
void addEnumerationNames (const std::string &names)
 Methods to add possible enumeration value to the enum. More...
 
void addEnumerationName (const std::string &raw_name)
 
void addEnumerationName (const std::string &name, const int &value)
 
void addEnumerationItem (const MooseEnumItem &item)
 

Protected Attributes

std::vector< MooseEnumItem_current
 The current id. More...
 
std::set< MooseEnumItem_items
 Storage for the assigned items. More...
 
std::map< MooseEnumItem, MooseEnumItem_deprecated_items
 The map of deprecated names and optional replacements. More...
 
bool _allow_out_of_range
 Flag to enable enumeration items not previously defined. More...
 

Detailed Description

A MultiMooseEnum object to hold "execute_on" flags.

This object allows available flags to be added or removed thus each object can control the flags that are available.

Definition at line 25 of file ExecFlagEnum.h.

Constructor & Destructor Documentation

◆ ExecFlagEnum() [1/3]

ExecFlagEnum::ExecFlagEnum ( )

Definition at line 14 of file ExecFlagEnum.C.

14 : MultiMooseEnum() {}
MultiMooseEnum()
Protected constructor for use by libmesh::Parameters.

◆ ExecFlagEnum() [2/3]

ExecFlagEnum::ExecFlagEnum ( const ExecFlagEnum other)

Definition at line 16 of file ExecFlagEnum.C.

16 : MultiMooseEnum(other) {}
MultiMooseEnum()
Protected constructor for use by libmesh::Parameters.

◆ ExecFlagEnum() [3/3]

ExecFlagEnum::ExecFlagEnum ( const MultiMooseEnum other)

Definition at line 15 of file ExecFlagEnum.C.

15 : MultiMooseEnum(other) {}
MultiMooseEnum()
Protected constructor for use by libmesh::Parameters.

Member Function Documentation

◆ addAvailableFlags() [1/2]

template<typename... Args>
void ExecFlagEnum::addAvailableFlags ( const ExecFlagType flag,
Args...  flags 
)

Add additional execute_on flags to the list of possible flags.

Use a recursive variadic template function to allow for an arbitrary number arguments: addAvaiableFlags(EXEC_INITIAL); addAvaiableFlags(EXEC_INITIAL, EXEC_TIMESTEP_END);

Definition at line 85 of file ExecFlagEnum.h.

Referenced by MooseApp::addExecFlag(), AdvancedOutput::addValidParams(), Output::getDefaultExecFlagEnum(), MooseUtils::getDefaultExecFlagEnum(), Output::getExecuteOptions(), validParams< AuxKernel >(), and validParams< MultiAppTransfer >().

86 {
87  addAvailableFlags(flag);
88  addAvailableFlags(flags...);
89 }
void addAvailableFlags(const ExecFlagType &flag, Args... flags)
Add additional execute_on flags to the list of possible flags.
Definition: ExecFlagEnum.h:85

◆ addAvailableFlags() [2/2]

void ExecFlagEnum::addAvailableFlags ( const ExecFlagType flag)

Definition at line 19 of file ExecFlagEnum.C.

20 {
21  addEnumerationItem(flag);
22 }
void addEnumerationItem(const MooseEnumItem &item)

◆ addEnumerationItem()

void MooseEnumBase::addEnumerationItem ( const MooseEnumItem item)
protectedinherited

Definition at line 117 of file MooseEnumBase.C.

Referenced by addAvailableFlags(), MooseEnumBase::addEnumerationName(), and MultiMooseEnum::assign().

118 {
119  if (_items.count(item) > 0) // do nothing for identical insertions
120  return;
121 
122  if (find(item.id()) != _items.end())
123  mooseError("The supplied id ",
124  item.id(),
125  " already exists in the enumeration, cannot not add '",
126  item,
127  "'.");
128  if (find(item.name()) != _items.end())
129  mooseError("The name '", item.name(), "' already exists in the enumeration.");
130 
131  _items.insert(item);
132 }
const std::string & name() const
Definition: MooseEnumItem.h:38
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::set< MooseEnumItem > _items
Storage for the assigned items.
const int & id() const
Return the numeric, name, or raw name.
Definition: MooseEnumItem.h:37
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.

◆ addEnumerationName() [1/2]

void MooseEnumBase::addEnumerationName ( const std::string &  raw_name)
protectedinherited

Definition at line 73 of file MooseEnumBase.C.

Referenced by MooseEnumBase::addEnumerationNames().

74 {
75  // Make sure the option is not malformed
76  if (raw_name.find_first_of('=') == 0 || raw_name.find_last_of('=') == raw_name.length() - 1)
77  mooseError("You cannot place whitespace around the '=' character in MooseEnumBase");
78 
79  // Split on equals sign
80  std::vector<std::string> name_value;
81  MooseUtils::tokenize(MooseUtils::trim(raw_name), name_value, 1, "=");
82 
83  // There should be one or two items in the name_value
84  if (name_value.size() < 1 || name_value.size() > 2)
85  mooseError("Invalid option supplied in MooseEnumBase: ", raw_name);
86 
87  // Remove un-wanted space around string
88  name_value[0] = MooseUtils::trim(name_value[0]);
89 
90  // See if there is a value supplied for this option
91  // strtol allows for proper conversions of both int and hex strings
92  int value;
93  if (name_value.size() == 2)
94  value = std::strtol(name_value[1].c_str(), NULL, 0);
95  else
96  value = getNextValidID();
97 
98  addEnumerationName(name_value[0], value);
99 }
int getNextValidID() const
Compute the next valid ID.
void tokenize(const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/")
This function will split the passed in string on a set of delimiters appending the substrings to the ...
Definition: MooseUtils.h:377
void addEnumerationName(const std::string &raw_name)
Definition: MooseEnumBase.C:73
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::string trim(const std::string &str, const std::string &white_space=" \\\)
Standard scripting language trim function.
Definition: MooseUtils.C:112

◆ addEnumerationName() [2/2]

void MooseEnumBase::addEnumerationName ( const std::string &  name,
const int &  value 
)
protectedinherited

Definition at line 111 of file MooseEnumBase.C.

112 {
113  addEnumerationItem(MooseEnumItem(name, value));
114 }
void addEnumerationItem(const MooseEnumItem &item)
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:22

◆ addEnumerationNames()

void MooseEnumBase::addEnumerationNames ( const std::string &  names)
protectedinherited

Methods to add possible enumeration value to the enum.

The MooseEnum/MultiMooseEnum are not designed to be modified, with respect to the list of possible values. However, this is not the case for the ExecFlagEnum which is a special type of MultiMooseEnum for managing the "execute_on" flags. These methods are used by ExecFlagEnum to allow users to modify the available execute flags for their object.

Definition at line 64 of file MooseEnumBase.C.

Referenced by MooseEnumBase::MooseEnumBase().

65 {
66  std::vector<std::string> elements;
67  MooseUtils::tokenize(names, elements, 1, " ");
68  for (const std::string & raw_name : elements)
69  addEnumerationName(raw_name);
70 }
void tokenize(const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/")
This function will split the passed in string on a set of delimiters appending the substrings to the ...
Definition: MooseUtils.h:377
void addEnumerationName(const std::string &raw_name)
Definition: MooseEnumBase.C:73

◆ appendCurrent()

void ExecFlagEnum::appendCurrent ( const ExecFlagType item)
protected

Append the list of current flags.

Definition at line 82 of file ExecFlagEnum.C.

Referenced by operator+=().

83 {
84  if (find(item) == _items.end())
85  mooseError("The supplied item '",
86  item,
87  "' is not an available item for the "
88  "ExecFlagEnum object, thus it cannot be set as current.");
89  _current.push_back(item);
90 }
std::vector< MooseEnumItem > _current
The current id.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::set< MooseEnumItem > _items
Storage for the assigned items.
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.

◆ assign()

template<typename InputIterator >
MultiMooseEnum & MultiMooseEnum::assign ( InputIterator  first,
InputIterator  last,
bool  append 
)
protectedinherited

Helper method for all inserts and assignment operators.

Definition at line 183 of file MultiMooseEnum.C.

Referenced by MultiMooseEnum::operator=(), and MultiMooseEnum::push_back().

184 {
185  if (!append)
186  clear();
187 
188  for (InputIterator it = first; it != last; ++it)
189  {
190  const auto iter = find(*it);
191  if (iter == _items.end())
192  {
193  if (!_allow_out_of_range) // Are out of range values allowed?
194  mooseError("Invalid option \"",
195  *it,
196  "\" in MultiMooseEnum. Valid options (not case-sensitive) are \"",
197  getRawNames(),
198  "\".");
199  else
200  {
201  MooseEnumItem created(*it, getNextValidID());
202  addEnumerationItem(created);
203  _current.push_back(created);
204  }
205  }
206  else
207  _current.push_back(*iter);
208  }
209  checkDeprecated();
210  return *this;
211 }
int getNextValidID() const
Compute the next valid ID.
virtual void checkDeprecated() const override
Check whether any of the current values are deprecated when called.
std::vector< MooseEnumItem > _current
The current id.
void addEnumerationItem(const MooseEnumItem &item)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::string getRawNames() const
Method for returning the raw name strings for this instance.
void clear()
Clear the MultiMooseEnum.
std::set< MooseEnumItem > _items
Storage for the assigned items.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:22
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.
bool _allow_out_of_range
Flag to enable enumeration items not previously defined.

◆ begin()

MooseEnumIterator MultiMooseEnum::begin ( ) const
inlineinherited

Returns a begin/end iterator to all of the items in the enum.

Items will always be capitalized.

Definition at line 139 of file MultiMooseEnum.h.

Referenced by ExecuteMooseObjectWarehouse< Transfer >::addObjectMask().

139 { return _current.begin(); }
std::vector< MooseEnumItem > _current
The current id.

◆ checkDeprecated() [1/2]

void MooseEnumBase::checkDeprecated ( const MooseEnumItem item) const
protectedinherited

Check and warn deprecated values.

Definition at line 135 of file MooseEnumBase.C.

136 {
137  std::map<MooseEnumItem, MooseEnumItem>::const_iterator it = _deprecated_items.find(item);
138  if (it != _deprecated_items.end())
139  {
140  if (it->second.name().empty())
141  mooseWarning(item.name() + " is deprecated");
142  else
143  mooseWarning(item.name() + " is deprecated, consider using " + it->second.name());
144  }
145 }
const std::string & name() const
Definition: MooseEnumItem.h:38
std::map< MooseEnumItem, MooseEnumItem > _deprecated_items
The map of deprecated names and optional replacements.
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:220

◆ checkDeprecated() [2/2]

void MultiMooseEnum::checkDeprecated ( ) const
overrideprotectedvirtualinherited

Check whether any of the current values are deprecated when called.

Implements MooseEnumBase.

Definition at line 240 of file MultiMooseEnum.C.

Referenced by MultiMooseEnum::assign(), and operator+=().

241 {
242  for (const auto & item : _current)
244 }
std::vector< MooseEnumItem > _current
The current id.
virtual void checkDeprecated() const =0
Method that must be implemented to check derived class values against the _deprecated_names.

◆ clear()

void MultiMooseEnum::clear ( )
inherited

Clear the MultiMooseEnum.

Definition at line 228 of file MultiMooseEnum.C.

Referenced by MultiMooseEnum::assign(), AdvancedOutput::initExecutionTypes(), operator=(), and SetupInterface::SetupInterface().

229 {
230  _current.clear();
231 }
std::vector< MooseEnumItem > _current
The current id.

◆ contains() [1/5]

bool MultiMooseEnum::contains ( const std::string &  value) const
inherited

Contains methods for seeing if a value is in the MultiMooseEnum.

Returns
bool - the truth value indicating whether the value is present

Definition at line 62 of file MultiMooseEnum.C.

Referenced by FEProblemBase::addTransfer(), AdvancedOutput::addValidParams(), ChangeOverTimePostprocessor::ChangeOverTimePostprocessor(), MultiMooseEnum::contains(), EigenExecutionerBase::init(), Console::initialSetup(), AdvancedOutput::initPostprocessorOrVectorPostprocessorLists(), EigenExecutionerBase::inversePowerIteration(), MultiMooseEnum::operator==(), Console::output(), Console::outputSystemInformation(), EigenExecutionerBase::postExecute(), removeAvailableFlags(), Output::shouldOutput(), and PetscOutput::solveSetup().

63 {
64  return std::find_if(_current.begin(), _current.end(), [&value](const MooseEnumItem & item) {
65  return item == value;
66  }) != _current.end();
67 }
std::vector< MooseEnumItem > _current
The current id.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:22

◆ contains() [2/5]

bool MultiMooseEnum::contains ( int  value) const
inherited

Definition at line 70 of file MultiMooseEnum.C.

71 {
72  return std::find_if(_current.begin(), _current.end(), [&value](const MooseEnumItem & item) {
73  return item == value;
74  }) != _current.end();
75 }
std::vector< MooseEnumItem > _current
The current id.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:22

◆ contains() [3/5]

bool MultiMooseEnum::contains ( unsigned short  value) const
inherited

Definition at line 78 of file MultiMooseEnum.C.

79 {
80  return std::find_if(_current.begin(), _current.end(), [&value](const MooseEnumItem & item) {
81  return item == value;
82  }) != _current.end();
83 }
std::vector< MooseEnumItem > _current
The current id.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:22

◆ contains() [4/5]

bool MultiMooseEnum::contains ( const MultiMooseEnum value) const
inherited

Definition at line 86 of file MultiMooseEnum.C.

87 {
88  for (const auto & item : value._current)
89  if (!contains(item))
90  return false;
91  return true;
92 }
std::vector< MooseEnumItem > _current
The current id.
bool contains(const std::string &value) const
Contains methods for seeing if a value is in the MultiMooseEnum.

◆ contains() [5/5]

bool MultiMooseEnum::contains ( const MooseEnumItem value) const
inherited

Definition at line 95 of file MultiMooseEnum.C.

96 {
97  return std::find_if(_current.begin(), _current.end(), [&value](const MooseEnumItem & item) {
98  return item == value;
99  }) != _current.end();
100 }
std::vector< MooseEnumItem > _current
The current id.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:22

◆ deprecate()

void MooseEnumBase::deprecate ( const std::string &  name,
const std::string &  raw_name = "" 
)
virtualinherited

Deprecates various options in the MOOSE enum.

For each deprecated option, you may supply an optional new option that will be used in a message telling the user which new option replaces the old one.

Definition at line 45 of file MooseEnumBase.C.

46 {
47  std::set<MooseEnumItem>::const_iterator deprecated = find(name);
48  if (deprecated == _items.end())
49  mooseError("Cannot deprecate the enum item ", name, ", is not an available value.");
50 
51  std::set<MooseEnumItem>::const_iterator replaced = find(raw_name);
52  if (replaced == _items.end())
53  mooseError("Cannot deprecate the enum item ",
54  name,
55  ", since the replaced item ",
56  raw_name,
57  " it is not an available value.");
58 
59  _deprecated_items.emplace(std::make_pair(*deprecated, *replaced));
61 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::map< MooseEnumItem, MooseEnumItem > _deprecated_items
The map of deprecated names and optional replacements.
virtual void checkDeprecated() const =0
Method that must be implemented to check derived class values against the _deprecated_names.
std::set< MooseEnumItem > _items
Storage for the assigned items.
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.

◆ end()

MooseEnumIterator MultiMooseEnum::end ( ) const
inlineinherited

Definition at line 140 of file MultiMooseEnum.h.

140 { return _current.end(); }
std::vector< MooseEnumItem > _current
The current id.

◆ erase() [1/3]

void MultiMooseEnum::erase ( const std::string &  names)
inherited

Un-assign a value.

Parameters
names- a string, set, or vector giving the name to erase from the enumeration values

Definition at line 123 of file MultiMooseEnum.C.

Referenced by Console::Console().

124 {
125  std::vector<std::string> names_vector;
126  MooseUtils::tokenize(names, names_vector, 1, " ");
127  remove(names_vector.begin(), names_vector.end());
128 }
void tokenize(const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/")
This function will split the passed in string on a set of delimiters appending the substrings to the ...
Definition: MooseUtils.h:377

◆ erase() [2/3]

void MultiMooseEnum::erase ( const std::vector< std::string > &  names)
inherited

Definition at line 131 of file MultiMooseEnum.C.

132 {
133  remove(names.begin(), names.end());
134 }

◆ erase() [3/3]

void MultiMooseEnum::erase ( const std::set< std::string > &  names)
inherited

Definition at line 137 of file MultiMooseEnum.C.

138 {
139  remove(names.begin(), names.end());
140 }

◆ find() [1/3]

std::set< MooseEnumItem >::const_iterator MooseEnumBase::find ( const MooseEnumItem other) const
inherited

Locate an item.

Definition at line 190 of file MooseEnumBase.C.

Referenced by MooseEnumBase::addEnumerationItem(), MooseApp::addExecFlag(), appendCurrent(), MultiMooseEnum::assign(), MooseEnumBase::deprecate(), MooseEnum::operator=(), MooseEnum::operator==(), and removeAvailableFlags().

191 {
192  return std::find_if(_items.begin(), _items.end(), [&other](MooseEnumItem const & item) {
193  return item.id() == other.id();
194  });
195 }
std::set< MooseEnumItem > _items
Storage for the assigned items.
const int & id() const
Return the numeric, name, or raw name.
Definition: MooseEnumItem.h:37
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:22

◆ find() [2/3]

std::set< MooseEnumItem >::const_iterator MooseEnumBase::find ( const std::string &  name) const
inherited

Definition at line 174 of file MooseEnumBase.C.

175 {
176  std::string upper = MooseUtils::toUpper(name);
177  return std::find_if(_items.begin(), _items.end(), [&upper](MooseEnumItem const & item) {
178  return item.name() == upper;
179  });
180 }
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
Definition: MooseUtils.C:708
std::set< MooseEnumItem > _items
Storage for the assigned items.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:22

◆ find() [3/3]

std::set< MooseEnumItem >::const_iterator MooseEnumBase::find ( int  id) const
inherited

Definition at line 183 of file MooseEnumBase.C.

184 {
185  return std::find_if(
186  _items.begin(), _items.end(), [&id](MooseEnumItem const & item) { return item.id() == id; });
187 }
std::set< MooseEnumItem > _items
Storage for the assigned items.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:22

◆ get()

unsigned int MultiMooseEnum::get ( unsigned int  i) const
inherited

Indexing operator Operator to retrieve an item from the MultiMooseEnum.

Parameters
iindex
Returns
the id of the MooseEnumItem at the supplied index

Definition at line 172 of file MultiMooseEnum.C.

Referenced by InputParameters::getParamHelper(), PiecewiseMulticonstant::sample(), and Parser::setScalarParameter().

173 {
174  mooseAssert(i < _current.size(),
175  "Access out of bounds in MultiMooseEnum (i: " << i << " size: " << _current.size()
176  << ")");
177 
178  return _current[i].id();
179 }
std::vector< MooseEnumItem > _current
The current id.

◆ getDocString()

std::string ExecFlagEnum::getDocString ( ) const

Generate a documentation string for the "execute_on" parameter.

Definition at line 39 of file ExecFlagEnum.C.

Referenced by validParams< CommonOutputAction >(), validParams< Output >(), and validParams< SetupInterface >().

40 {
41  std::string doc("The list of flag(s) indicating when this object should be executed, the "
42  "available options include ");
43  doc += Moose::stringify(getNames(), ", ");
44  doc += ".";
45  return doc;
46 }
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:58
std::vector< std::string > getNames() const
Method for returning a vector of all valid enumeration names for this instance.

◆ getIDs()

std::vector< int > MooseEnumBase::getIDs ( ) const
inherited

Method for returning a vector of ids for this instance.

Returns
a vector of ints containing the possible ids for this enumeration

Definition at line 164 of file MooseEnumBase.C.

Referenced by MooseEnum::operator=().

165 {
166  std::vector<int> out;
167  out.reserve(_items.size());
168  for (const auto & item : _items)
169  out.push_back(item.id());
170  return out;
171 }
std::set< MooseEnumItem > _items
Storage for the assigned items.

◆ getNames()

std::vector< std::string > MooseEnumBase::getNames ( ) const
inherited

Method for returning a vector of all valid enumeration names for this instance.

Returns
a vector of names

Definition at line 148 of file MooseEnumBase.C.

Referenced by getDocString().

149 {
150  std::vector<std::string> out;
151  out.reserve(_items.size());
152  for (const auto & item : _items)
153  out.push_back(item.name());
154  return out;
155 }
std::set< MooseEnumItem > _items
Storage for the assigned items.

◆ getNextValidID()

int MooseEnumBase::getNextValidID ( ) const
inherited

Compute the next valid ID.

Definition at line 102 of file MooseEnumBase.C.

Referenced by MooseEnumBase::addEnumerationName(), MooseApp::addExecFlag(), MultiMooseEnum::assign(), and MooseEnum::operator=().

103 {
104  int value = -1; // Use -1 so if no values exist the first will be zero
105  for (const auto & item : _items)
106  value = std::max(value, item.id());
107  return ++value;
108 }
std::set< MooseEnumItem > _items
Storage for the assigned items.

◆ getRawNames()

std::string MooseEnumBase::getRawNames ( ) const
inherited

Method for returning the raw name strings for this instance.

Returns
a space separated list of names

Definition at line 158 of file MooseEnumBase.C.

Referenced by MultiMooseEnum::assign(), AdvancedOutput::enableOutputTypes(), MooseEnum::operator=(), MooseEnum::operator==(), validParams< ComparisonPostprocessor >(), validParams< LeastSquaresFit >(), validParams< PiecewiseConstant >(), and validParams< Residual >().

159 {
160  return Moose::stringify(_items, " ");
161 }
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:58
std::set< MooseEnumItem > _items
Storage for the assigned items.

◆ isOutOfRangeAllowed()

bool MooseEnumBase::isOutOfRangeAllowed ( ) const
inlineinherited

isOutOfRangeAllowed

Returns
- a Boolean indicating whether enum names out of range are allowed

Definition at line 83 of file MooseEnumBase.h.

83 { return _allow_out_of_range; }
bool _allow_out_of_range
Flag to enable enumeration items not previously defined.

◆ isValid()

virtual bool MultiMooseEnum::isValid ( ) const
inlineoverridevirtualinherited

IsValid.

Returns
- a Boolean indicating whether this Enumeration has been set

Implements MooseEnumBase.

Definition at line 157 of file MultiMooseEnum.h.

157 { return !_current.empty(); }
std::vector< MooseEnumItem > _current
The current id.

◆ items() [1/2]

const std::set<ExecFlagType>& ExecFlagEnum::items ( ) const
inline

Reference the all the available items.

Definition at line 74 of file ExecFlagEnum.h.

Referenced by MooseApp::addExecFlag(), ExecuteMooseObjectWarehouse< Transfer >::ExecuteMooseObjectWarehouse(), EigenExecutionerBase::normalizeSolution(), and MooseApp::setupOptions().

74 { return _items; }
std::set< MooseEnumItem > _items
Storage for the assigned items.

◆ items() [2/2]

const std::set<MooseEnumItem>& MooseEnumBase::items ( )
inlineinherited

Return the complete set of available flags.

Definition at line 88 of file MooseEnumBase.h.

88 { return _items; }
std::set< MooseEnumItem > _items
Storage for the assigned items.

◆ operator!=()

bool MultiMooseEnum::operator!= ( const MultiMooseEnum value) const
inherited

Definition at line 56 of file MultiMooseEnum.C.

57 {
58  return !(*this == value);
59 }

◆ operator+=() [1/2]

ExecFlagEnum & ExecFlagEnum::operator+= ( const std::initializer_list< ExecFlagType > &  flags)

Definition at line 65 of file ExecFlagEnum.C.

66 {
67  for (const ExecFlagType & flag : flags)
68  appendCurrent(flag);
70  return *this;
71 }
virtual void checkDeprecated() const override
Check whether any of the current values are deprecated when called.
void appendCurrent(const ExecFlagType &item)
Append the list of current flags.
Definition: ExecFlagEnum.C:82
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:22

◆ operator+=() [2/2]

ExecFlagEnum & ExecFlagEnum::operator+= ( const ExecFlagType flags)

Definition at line 74 of file ExecFlagEnum.C.

75 {
76  appendCurrent(flag);
78  return *this;
79 }
virtual void checkDeprecated() const override
Check whether any of the current values are deprecated when called.
void appendCurrent(const ExecFlagType &item)
Append the list of current flags.
Definition: ExecFlagEnum.C:82

◆ operator=() [1/5]

MultiMooseEnum & MultiMooseEnum::operator=

Assignment operators for setting the current flags.

Definition at line 111 of file MultiMooseEnum.C.

112 {
113  return assign(names.begin(), names.end(), false);
114 }
MultiMooseEnum & assign(InputIterator first, InputIterator last, bool append)
Helper method for all inserts and assignment operators.

◆ operator=() [2/5]

MultiMooseEnum & MultiMooseEnum::operator=

Assignment operators for setting the current flags.

Definition at line 103 of file MultiMooseEnum.C.

104 {
105  std::vector<std::string> names_vector;
106  MooseUtils::tokenize(names, names_vector, 1, " ");
107  return assign(names_vector.begin(), names_vector.end(), false);
108 }
MultiMooseEnum & assign(InputIterator first, InputIterator last, bool append)
Helper method for all inserts and assignment operators.
void tokenize(const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/")
This function will split the passed in string on a set of delimiters appending the substrings to the ...
Definition: MooseUtils.h:377

◆ operator=() [3/5]

MultiMooseEnum & MultiMooseEnum::operator=

Assignment operators for setting the current flags.

Definition at line 117 of file MultiMooseEnum.C.

118 {
119  return assign(names.begin(), names.end(), false);
120 }
MultiMooseEnum & assign(InputIterator first, InputIterator last, bool append)
Helper method for all inserts and assignment operators.

◆ operator=() [4/5]

ExecFlagEnum & ExecFlagEnum::operator= ( const std::initializer_list< ExecFlagType > &  flags)

Definition at line 49 of file ExecFlagEnum.C.

50 {
51  clear();
52  *this += flags;
53  return *this;
54 }
void clear()
Clear the MultiMooseEnum.

◆ operator=() [5/5]

ExecFlagEnum & ExecFlagEnum::operator= ( const ExecFlagType flags)

Definition at line 57 of file ExecFlagEnum.C.

58 {
59  clear();
60  *this += flag;
61  return *this;
62 }
void clear()
Clear the MultiMooseEnum.

◆ operator==()

bool MultiMooseEnum::operator== ( const MultiMooseEnum value) const
inherited

Comparison operators for comparing with character constants, MultiMooseEnums or integer values.

Parameters
value- RHS value to compare against
Returns
bool - the truth value for the comparison

Definition at line 44 of file MultiMooseEnum.C.

45 {
46  // Not the same if the lengths are different
47  if (value.size() != size())
48  return false;
49 
50  // Return false if this enum does not contain an item from the other, since they are the same
51  // size at this point if this is true then they are equal.
52  return contains(value);
53 }
unsigned int size() const
Return the number of items in the MultiMooseEnum.
bool contains(const std::string &value) const
Contains methods for seeing if a value is in the MultiMooseEnum.

◆ operator[]()

const std::string & MultiMooseEnum::operator[] ( unsigned int  i) const
inherited

Indexing operator Operator to retrieve an item from the MultiMooseEnum.

The reference may not be used to change the item.

Parameters
iindex
Returns
a read/read-write reference to the item as a string.

Definition at line 162 of file MultiMooseEnum.C.

163 {
164  mooseAssert(i < _current.size(),
165  "Access out of bounds in MultiMooseEnum (i: " << i << " size: " << _current.size()
166  << ")");
167 
168  return _current[i].rawName();
169 }
std::vector< MooseEnumItem > _current
The current id.

◆ push_back() [1/3]

void MultiMooseEnum::push_back ( const std::string &  names)
inherited

Insert operators Operator to insert (push_back) values into the enum.

Existing values are preserved and duplicates are stored.

Parameters
names- a string, set, or vector representing one of the enumeration values.

Definition at line 143 of file MultiMooseEnum.C.

Referenced by Console::Console(), Output::Output(), PetscOutput::PetscOutput(), and Split::setup().

144 {
145  std::vector<std::string> names_vector;
146  MooseUtils::tokenize(names, names_vector, 1, " ");
147  assign(names_vector.begin(), names_vector.end(), true);
148 }
MultiMooseEnum & assign(InputIterator first, InputIterator last, bool append)
Helper method for all inserts and assignment operators.
void tokenize(const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/")
This function will split the passed in string on a set of delimiters appending the substrings to the ...
Definition: MooseUtils.h:377

◆ push_back() [2/3]

void MultiMooseEnum::push_back ( const std::vector< std::string > &  names)
inherited

Definition at line 151 of file MultiMooseEnum.C.

152 {
153  assign(names.begin(), names.end(), true);
154 }
MultiMooseEnum & assign(InputIterator first, InputIterator last, bool append)
Helper method for all inserts and assignment operators.

◆ push_back() [3/3]

void MultiMooseEnum::push_back ( const std::set< std::string > &  names)
inherited

Definition at line 157 of file MultiMooseEnum.C.

158 {
159  assign(names.begin(), names.end(), true);
160 }
MultiMooseEnum & assign(InputIterator first, InputIterator last, bool append)
Helper method for all inserts and assignment operators.

◆ remove()

template<typename InputIterator >
void MultiMooseEnum::remove ( InputIterator  first,
InputIterator  last 
)
protectedinherited

Helper method for un-assigning enumeration values.

Definition at line 215 of file MultiMooseEnum.C.

216 {
217  // Create a new list of enumerations by striping out the supplied values
218  for (InputIterator it = first; it != last; ++it)
219  {
220  std::vector<MooseEnumItem>::iterator iter = std::find_if(
221  _current.begin(), _current.end(), [it](const MooseEnumItem & item) { return item == *it; });
222  if (iter != _current.end())
223  _current.erase(iter);
224  }
225 }
std::vector< MooseEnumItem > _current
The current id.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:22

◆ removeAvailableFlags() [1/2]

template<typename... Args>
void ExecFlagEnum::removeAvailableFlags ( const ExecFlagType flag,
Args...  flags 
)

Remove flags from being available.

Definition at line 93 of file ExecFlagEnum.h.

94 {
96  removeAvailableFlags(flags...);
97 }
void removeAvailableFlags(const ExecFlagType &flag, Args... flags)
Remove flags from being available.
Definition: ExecFlagEnum.h:93

◆ removeAvailableFlags() [2/2]

void ExecFlagEnum::removeAvailableFlags ( const ExecFlagType flag)

Definition at line 25 of file ExecFlagEnum.C.

26 {
27  if (find(flag) == _items.end())
28  mooseError("The supplied item '",
29  flag,
30  "' is not an available enum item for the "
31  "MultiMooseEnum object, thus it cannot be removed.");
32  else if (contains(flag))
33  mooseError("The supplied item '", flag, "' is a selected item, thus it can not be removed.");
34 
35  _items.erase(flag);
36 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
bool contains(const std::string &value) const
Contains methods for seeing if a value is in the MultiMooseEnum.
std::set< MooseEnumItem > _items
Storage for the assigned items.
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.

◆ setCurrentItems()

void MultiMooseEnum::setCurrentItems ( const std::vector< MooseEnumItem > &  current)
protectedinherited

Set the current items.

◆ size()

unsigned int MultiMooseEnum::size ( ) const
inherited

Return the number of items in the MultiMooseEnum.

Definition at line 234 of file MultiMooseEnum.C.

Referenced by InterfaceKernel::InterfaceKernel(), MultiMooseEnum::operator==(), PiecewiseMulticonstant::PiecewiseMulticonstant(), and FEProblemBase::setCoordSystem().

235 {
236  return _current.size();
237 }
std::vector< MooseEnumItem > _current
The current id.

Member Data Documentation

◆ _allow_out_of_range

bool MooseEnumBase::_allow_out_of_range
protectedinherited

Flag to enable enumeration items not previously defined.

Definition at line 139 of file MooseEnumBase.h.

Referenced by MultiMooseEnum::assign(), MooseEnumBase::isOutOfRangeAllowed(), MooseEnum::operator=(), and MooseEnum::operator==().

◆ _current

std::vector<MooseEnumItem> MultiMooseEnum::_current
protectedinherited

◆ _deprecated_items

std::map<MooseEnumItem, MooseEnumItem> MooseEnumBase::_deprecated_items
protectedinherited

The map of deprecated names and optional replacements.

Definition at line 136 of file MooseEnumBase.h.

Referenced by MooseEnumBase::checkDeprecated(), and MooseEnumBase::deprecate().

◆ _items

std::set<MooseEnumItem> MooseEnumBase::_items
protectedinherited

The documentation for this class was generated from the following files: