https://mooseframework.inl.gov
ExecFlagEnum.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 "ExecFlagEnum.h"
11 #include "MooseError.h"
12 #include "Conversion.h"
13 #include "MooseUtils.h"
14 
18 
19 const ExecFlagType &
21 {
22  return addEnumerationItem(flag);
23 }
24 
25 void
27 {
28  if (find(flag) == _items.end())
29  mooseError("The supplied item '",
30  flag,
31  "' is not an available enum item for the "
32  "MultiMooseEnum object, thus it cannot be removed.");
33  else if (isValueSet(flag))
34  mooseError("The supplied item '", flag, "' is a selected item, thus it can not be removed.");
35 
36  _items.erase(flag);
37 }
38 
39 std::string
41 {
42  std::string doc("The list of flag(s) indicating when this object should be executed. For a "
43  "description of each flag, see ");
44  doc += MooseUtils::mooseDocsURL("source/interfaces/SetupInterface.html");
45  doc += ".";
46  return doc;
47 }
48 
50 ExecFlagEnum::operator=(const std::initializer_list<ExecFlagType> & flags)
51 {
53  *this += flags;
54  return *this;
55 }
56 
59 {
61  *this += flag;
62  return *this;
63 }
64 
66 ExecFlagEnum::operator+=(const std::initializer_list<ExecFlagType> & flags)
67 {
68  for (const ExecFlagType & flag : flags)
69  appendCurrent(flag);
71  return *this;
72 }
73 
76 {
77  appendCurrent(flag);
79  return *this;
80 }
81 
82 void
84 {
85  if (find(item) == _items.end())
86  mooseError("The supplied item '",
87  item,
88  "' is not an available item for the "
89  "ExecFlagEnum object, thus it cannot be set as current.");
90  _current_values.push_back(item);
91 }
virtual void checkDeprecated() const override
Check whether any of the current values are deprecated when called.
ExecFlagEnum & operator+=(const std::initializer_list< ExecFlagType > &flags)
Definition: ExecFlagEnum.C:66
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
void addAvailableFlags(const ExecFlagType &flag, Args... flags)
Add additional execute_on flags to the list of possible flags.
Definition: ExecFlagEnum.h:82
std::string mooseDocsURL(const std::string &path)
Returns the URL of a page located on the MOOSE documentation site.
Definition: MooseUtils.C:135
ExecFlagEnum & operator=(const ExecFlagEnum &other)=default
std::string getDocString() const
Generate a documentation string for the "execute_on" parameter.
Definition: ExecFlagEnum.C:40
const MooseEnumItem & addEnumerationItem(const MooseEnumItem &item)
bool isValueSet(const std::string &value) const
Methods for seeing if a value is set in the MultiMooseEnum.
std::set< MooseEnumItem > _items
Storage for the assigned items.
void appendCurrent(const ExecFlagType &item)
Append the list of current flags.
Definition: ExecFlagEnum.C:83
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
void removeAvailableFlags(const ExecFlagType &flag, Args... flags)
Remove flags from being available.
Definition: ExecFlagEnum.h:90
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type...
std::vector< MooseEnumItem > _current_values
The current value(s) of the MultiMooseEnum.
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.
void clearSetValues()
Clear the MultiMooseEnum.