https://mooseframework.inl.gov
Public Member Functions | Static Public Attributes | Static Private Attributes | List of all members
ReporterMode Class Reference

MooseEnumItem that automatically creates the ID and doesn't allow the ID to be assigned. More...

#include <ReporterMode.h>

Inheritance diagram for ReporterMode:
[legend]

Public Member Functions

 ReporterMode (const std::string &key)
 
bool operator< (const MooseEnumItem &other) const
 Less than operator. More...
 
void setID (const int &id)
 Method to change the ID of the item, but only if it is an INVALID_ID. More...
 
const intid () const
 Return the numeric, name, or raw name. More...
 
const std::string & name () const
 
const std::string & rawName () const
 
 operator int () const
 Operator to allow this class to be used directly as a string for int. More...
 
 operator std::string () const
 
bool operator== (const char *value) const
 Comparison operators. More...
 
bool operator== (const std::string &value) const
 
bool operator== (int value) const
 
bool operator== (unsigned short value) const
 
bool operator== (const MooseEnumItem &) const
 
bool operator!= (const char *value) const
 
bool operator!= (const std::string &value) const
 
bool operator!= (int value) const
 
bool operator!= (unsigned short value) const
 
bool operator!= (const MooseEnumItem &) const
 

Static Public Attributes

static const int INVALID_ID = std::numeric_limits<int>::min()
 

Static Private Attributes

static int ID_COUNTER = 0
 

Detailed Description

MooseEnumItem that automatically creates the ID and doesn't allow the ID to be assigned.

This protects user from hitting an ID collision when creating custom modes.

Definition at line 44 of file ReporterMode.h.

Constructor & Destructor Documentation

◆ ReporterMode()

ReporterMode::ReporterMode ( const std::string &  key)

Definition at line 16 of file ReporterMode.C.

16 : MooseEnumItem(key, ID_COUNTER++) {}
static int ID_COUNTER
Definition: ReporterMode.h:51

Member Function Documentation

◆ id()

const int& MooseEnumItem::id ( ) const
inlineinherited

◆ name()

const std::string& MooseEnumItem::name ( ) const
inlineinherited

◆ operator int()

MooseEnumItem::operator int ( ) const
inlineinherited

Operator to allow this class to be used directly as a string for int.

Definition at line 43 of file MooseEnumItem.h.

43 { return _id; }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99

◆ operator std::string()

MooseEnumItem::operator std::string ( ) const
inlineinherited

Definition at line 44 of file MooseEnumItem.h.

44 { return _name; }
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96

◆ operator!=() [1/5]

bool MooseEnumItem::operator!= ( const char *  value) const
inherited

Definition at line 43 of file MooseEnumItem.C.

44 {
45  std::string name(MooseUtils::toUpper(value));
46  return _name != name;
47 }
const std::string & name() const
Definition: MooseEnumItem.h:35
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96

◆ operator!=() [2/5]

bool MooseEnumItem::operator!= ( const std::string &  value) const
inherited

Definition at line 57 of file MooseEnumItem.C.

58 {
59  std::string name(MooseUtils::toUpper(value));
60  return _name != name;
61 }
const std::string & name() const
Definition: MooseEnumItem.h:35
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96

◆ operator!=() [3/5]

bool MooseEnumItem::operator!= ( int  value) const
inlineinherited

Definition at line 60 of file MooseEnumItem.h.

60 { return _id != value; }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ operator!=() [4/5]

bool MooseEnumItem::operator!= ( unsigned short  value) const
inlineinherited

Definition at line 63 of file MooseEnumItem.h.

63 { return _id != value; }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ operator!=() [5/5]

bool MooseEnumItem::operator!= ( const MooseEnumItem item) const
inherited

Definition at line 70 of file MooseEnumItem.C.

71 {
72  return _id != item.id() && _name != MooseUtils::toUpper(item.name());
73 }
const std::string & name() const
Definition: MooseEnumItem.h:35
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96
const int & id() const
Return the numeric, name, or raw name.
Definition: MooseEnumItem.h:34

◆ operator<()

bool MooseEnumItem::operator< ( const MooseEnumItem other) const
inlineinherited

Less than operator.

This is required for this class to work in maps and sets.

Definition at line 72 of file MooseEnumItem.h.

73  {
74  return _id != other._id ? _id < other._id : _name < other._name;
75  }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96

◆ operator==() [1/5]

bool MooseEnumItem::operator== ( const char *  value) const
inherited

Comparison operators.

The comparison operators using the char * and string are case sensitive.

Definition at line 36 of file MooseEnumItem.C.

37 {
38  std::string name(MooseUtils::toUpper(value));
39  return _name == name;
40 }
const std::string & name() const
Definition: MooseEnumItem.h:35
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96

◆ operator==() [2/5]

bool MooseEnumItem::operator== ( const std::string &  value) const
inherited

Definition at line 50 of file MooseEnumItem.C.

51 {
52  std::string name(MooseUtils::toUpper(value));
53  return _name == name;
54 }
const std::string & name() const
Definition: MooseEnumItem.h:35
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96

◆ operator==() [3/5]

bool MooseEnumItem::operator== ( int  value) const
inlineinherited

Definition at line 59 of file MooseEnumItem.h.

59 { return _id == value; }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ operator==() [4/5]

bool MooseEnumItem::operator== ( unsigned short  value) const
inlineinherited

Definition at line 62 of file MooseEnumItem.h.

62 { return _id == value; }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ operator==() [5/5]

bool MooseEnumItem::operator== ( const MooseEnumItem item) const
inherited

Definition at line 64 of file MooseEnumItem.C.

65 {
66  return _id == item.id() && _name == MooseUtils::toUpper(item.name());
67 }
const std::string & name() const
Definition: MooseEnumItem.h:35
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96
const int & id() const
Return the numeric, name, or raw name.
Definition: MooseEnumItem.h:34

◆ rawName()

const std::string& MooseEnumItem::rawName ( ) const
inlineinherited

Definition at line 36 of file MooseEnumItem.h.

Referenced by MooseEnum::operator std::string(), and operator<<().

36 { return _raw_name; }
std::string _raw_name
The name as provided in constructor.
Definition: MooseEnumItem.h:93

◆ setID()

void MooseEnumItem::setID ( const int id)
inherited

Method to change the ID of the item, but only if it is an INVALID_ID.

An error is produced if the ID is valid and this method is called.

This is needed to allow ExecFlagType objects to be created without an ID being provided, the ID is assigned when ExecFlagEnum::addAvailableFlags is called.

Definition at line 83 of file MooseEnumItem.C.

84 {
85  if (_id != INVALID_ID)
86  mooseError("The ID of a MooseEnumItem can not be changed if it is valid, the item ",
87  _name,
88  " has a valid id of ",
89  _id,
90  ".");
91  _id = id;
92 }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96
static const int INVALID_ID
Definition: MooseEnumItem.h:21
const int & id() const
Return the numeric, name, or raw name.
Definition: MooseEnumItem.h:34

Member Data Documentation

◆ ID_COUNTER

int ReporterMode::ID_COUNTER = 0
staticprivate

Definition at line 51 of file ReporterMode.h.

◆ INVALID_ID

const int MooseEnumItem::INVALID_ID = std::numeric_limits<int>::min()
staticinherited

Definition at line 21 of file MooseEnumItem.h.

Referenced by MooseEnum::assign(), MooseEnum::isValid(), and MooseEnumItem::setID().


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