https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Private 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.
 
void setID (const int &id)
 Method to change the ID of the item, but only if it is an INVALID_ID.
 
const intid () const
 Return the numeric, name, or raw name.
 
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.
 
 operator std::string () const
 
bool operator== (const char *value) const
 Comparison operators.
 
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()
 

Private Attributes

std::string _raw_name
 The name as provided in constructor.
 
std::string _name
 Upper case name.
 
int _id
 The numeric value for item.
 

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 45 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

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; }

◆ operator std::string()

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

Definition at line 44 of file MooseEnumItem.h.

44{ return _name; }

◆ 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
std::string toUpper(std::string name)
Convert supplied string to upper case.

◆ operator!=() [2/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 int & id() const
Return the numeric, name, or raw name.

◆ operator!=() [3/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}

◆ operator!=() [4/5]

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

Definition at line 60 of file MooseEnumItem.h.

60{ return _id != value; }
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ operator!=() [5/5]

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

Definition at line 63 of file MooseEnumItem.h.

63{ return _id != value; }

◆ 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 }

◆ 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}

◆ operator==() [2/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}

◆ operator==() [3/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}

◆ operator==() [4/5]

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

Definition at line 59 of file MooseEnumItem.h.

59{ return _id == value; }

◆ operator==() [5/5]

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

Definition at line 62 of file MooseEnumItem.h.

62{ return _id == value; }

◆ rawName()

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

Definition at line 36 of file MooseEnumItem.h.

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

Referenced by MooseEnum::operator std::string().

◆ 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}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
static const int INVALID_ID

Member Data Documentation

◆ _id

int MooseEnumItem::_id
privateinherited

◆ _name

std::string MooseEnumItem::_name
privateinherited

◆ _raw_name

std::string MooseEnumItem::_raw_name
privateinherited

The name as provided in constructor.

Definition at line 93 of file MooseEnumItem.h.

Referenced by MooseEnumItem::operator=(), and MooseEnumItem::rawName().

◆ ID_COUNTER

int ReporterMode::ID_COUNTER = 0
staticprivate

Definition at line 52 of file ReporterMode.h.

◆ INVALID_ID

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

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