www.mooseframework.org
ExecFlagEnum.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
17 
18 void
20 {
21  addEnumerationItem(flag);
22 }
23 
24 void
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 }
37 
38 std::string
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 }
47 
49 ExecFlagEnum::operator=(const std::initializer_list<ExecFlagType> & flags)
50 {
51  clear();
52  *this += flags;
53  return *this;
54 }
55 
58 {
59  clear();
60  *this += flag;
61  return *this;
62 }
63 
65 ExecFlagEnum::operator+=(const std::initializer_list<ExecFlagType> & flags)
66 {
67  for (const ExecFlagType & flag : flags)
68  appendCurrent(flag);
70  return *this;
71 }
72 
75 {
76  appendCurrent(flag);
78  return *this;
79 }
80 
81 void
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 }
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:65
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:24
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:207
void addAvailableFlags(const ExecFlagType &flag, Args... flags)
Add additional execute_on flags to the list of possible flags.
Definition: ExecFlagEnum.h:84
bool contains(const std::string &value) const
Contains methods for seeing if a value is in the MultiMooseEnum.
std::string getDocString() const
Generate a documentation string for the "execute_on" parameter.
Definition: ExecFlagEnum.C:39
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:60
void clear()
Clear the MultiMooseEnum.
std::vector< std::string > getNames() const
Method for returning a vector of all valid enumeration names for this instance.
std::set< MooseEnumItem > _items
Storage for the assigned items.
void appendCurrent(const ExecFlagType &item)
Append the list of current flags.
Definition: ExecFlagEnum.C:82
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:21
ExecFlagEnum & operator=(const std::initializer_list< ExecFlagType > &flags)
Definition: ExecFlagEnum.C:49
void removeAvailableFlags(const ExecFlagType &flag, Args... flags)
Remove flags from being available.
Definition: ExecFlagEnum.h:92
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.