www.mooseframework.org
MooseEnumBase.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #ifndef MOOSEENUMBASE_H
16 #define MOOSEENUMBASE_H
17 
18 // C++ includes
19 #include <string>
20 #include <set>
21 #include <vector>
22 #include <map>
23 
24 // MOOSE includes
25 #include "MooseEnumItem.h"
26 
31 {
32 public:
41  MooseEnumBase(std::string names, bool allow_out_of_range = false);
42 
47  MooseEnumBase(const MooseEnumBase & other_enum);
48 
52  virtual ~MooseEnumBase() = default;
53 
59  void deprecate(const std::string & name, const std::string & new_name = "");
60 
65  std::vector<std::string> getNames() const;
66 
71  std::string getRawNames() const;
72 
77  virtual bool isValid() const = 0;
78 
83  bool isOutOfRangeAllowed() const { return _out_of_range_index; }
84 
85 protected:
86  MooseEnumBase();
87 
92  void fillNames(std::string names, std::string option_delim = " ");
93 
94  // The method that must be implemented to check derived class values against the _deprecated_names
95  // list
96  virtual void checkDeprecated() const = 0;
97 
101  void checkDeprecatedBase(const std::string & name_upper) const;
102 
104 
107  std::set<MooseEnumItem>::const_iterator find(const MooseEnumItem & other) const;
108  std::set<MooseEnumItem>::const_iterator find(const std::string & name) const;
109  std::set<MooseEnumItem>::const_iterator find(int id) const;
111 
113  std::set<MooseEnumItem> _items;
114 
116  std::map<std::string, std::string> _deprecated_names;
117 
123 
125  const static int INVALID_ID;
126 };
127 
128 #endif // MOOSEENUMBASE_H
std::vector< std::string > getNames() const
Method for returning a vector of all valid enumeration names for this instance.
void checkDeprecatedBase(const std::string &name_upper) const
Check and warn deprecated values.
Definition: MooseEnumBase.C:99
void fillNames(std::string names, std::string option_delim=" ")
Populates the _names vector.
Definition: MooseEnumBase.C:66
bool isOutOfRangeAllowed() const
isOutOfRangeAllowed
Definition: MooseEnumBase.h:83
MooseEnumBase()
Private constuctor for use by libmesh::Parameters.
Definition: MooseEnumBase.C:54
std::map< std::string, std::string > _deprecated_names
The map of deprecated names and optional replacements.
int _out_of_range_index
The index of values assigned that are NOT values in this enum.
The base class for both the MooseEnum and MultiMooseEnum classes.
Definition: MooseEnumBase.h:30
virtual ~MooseEnumBase()=default
This class must have a virtual destructor since it has derived classes.
static const int INVALID_ID
Constants.
virtual bool isValid() const =0
IsValid.
std::set< MooseEnumItem > _items
Storage for the assigned items.
std::string getRawNames() const
Method for returning the raw name strings for this instance.
virtual void checkDeprecated() const =0
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:24
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.
void deprecate(const std::string &name, const std::string &new_name="")
Deprecates various options in the MOOSE enum.
Definition: MooseEnumBase.C:57