www.mooseframework.org
MultiMooseEnum.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 MULTIMOOSEENUM_H
16 #define MULTIMOOSEENUM_H
17 
18 // MOOSE includes
19 #include "MooseEnumBase.h"
20 
21 // C++ includes
22 #include <vector>
23 
24 // Forward declarations
25 namespace libMesh
26 {
27 class Parameters;
28 }
29 
30 typedef std::vector<MooseEnumItem>::const_iterator MooseEnumIterator;
31 
43 {
44 public:
54  MultiMooseEnum(std::string names,
55  std::string default_names = "",
56  bool allow_out_of_range = false);
57 
62  MultiMooseEnum(const MultiMooseEnum & other_enum);
63 
65 
71  bool operator==(const MultiMooseEnum & value) const;
72  bool operator!=(const MultiMooseEnum & value) const;
74 
76 
80  bool contains(const std::string & value) const;
81  bool contains(int value) const;
82  bool contains(unsigned short value) const;
83  bool contains(const MultiMooseEnum & value) const;
84  bool contains(const MooseEnumItem & value) const;
86 
88 
93  MultiMooseEnum & operator=(const std::string & names);
94  MultiMooseEnum & operator=(const std::vector<std::string> & names);
95  MultiMooseEnum & operator=(const std::set<std::string> & names);
97 
99 
103  void erase(const std::string & names);
104  void erase(const std::vector<std::string> & names);
105  void erase(const std::set<std::string> & names);
107 
109 
115  void push_back(const std::string & names);
116  void push_back(const std::vector<std::string> & names);
117  void push_back(const std::set<std::string> & names);
119 
127  const std::string & operator[](unsigned int i) const;
128 
136  unsigned int get(unsigned int i) const;
137 
139 
143  MooseEnumIterator begin() const { return _current.begin(); }
144  MooseEnumIterator end() const { return _current.end(); }
146 
150  void clear();
151 
155  unsigned int size() const;
156 
161  virtual bool isValid() const override { return !_current.empty(); }
162 
163  // InputParameters and Output is allowed to create an empty enum but is responsible for
164  // filling it in after the fact
165  friend class libMesh::Parameters;
166 
168  friend std::ostream & operator<<(std::ostream & out, const MultiMooseEnum & obj);
169 
170 protected:
172  virtual void checkDeprecated() const override;
173 
174 private:
178  MultiMooseEnum();
179 
184  MultiMooseEnum(const MooseEnumBase & other_enum);
185 
189  template <typename InputIterator>
190  MultiMooseEnum & assign(InputIterator first, InputIterator last, bool append);
191 
195  template <typename InputIterator>
196  void remove(InputIterator first, InputIterator last);
197 
199  std::vector<MooseEnumItem> _current;
200 };
201 
202 #endif // MULTIMOOSEENUM_H
MooseEnumIterator end() const
std::vector< MooseEnumItem > _current
The current id.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
The base class for both the MooseEnum and MultiMooseEnum classes.
Definition: MooseEnumBase.h:30
std::ostream & operator<<(std::ostream &out, const MooseEnumItem &item)
Definition: MooseEnumItem.C:79
MooseEnumIterator begin() const
Returns a begin/end iterator to all of the items in the enum.
std::vector< MooseEnumItem >::const_iterator MooseEnumIterator
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:24
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
virtual bool isValid() const override
IsValid.