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

The Reporter system is comprised of objects that can contain any number of data values. More...

#include <ReporterName.h>

Inheritance diagram for ReporterName:
[legend]

Public Member Functions

 ReporterName (const std::string &object_name, const std::string &value_name)
 
 ReporterName (const std::string &object_and_value_name)
 
 ReporterName (const char *combined_name)
 
 ReporterName ()
 
const std::string & getObjectName () const
 Return the object name that produces the Reporter value. More...
 
const std::string & getValueName () const
 Return the data name for the Reporter value. More...
 
const std::string getCombinedName () const
 Return the name of the object and data as object_name/data_name. More...
 
std::string getRestartableName () const
 Return the name used for registration of this Reporter in the restartable data system. More...
 
 operator std::string () const
 std::string operator allows this object to behave as a std::sting object More...
 
bool operator== (const ReporterName &rhs) const
 Compare with another object or string. More...
 
bool operator== (const std::string &combined_name) const
 
bool operator< (const ReporterName &rhs) const
 Less than operator. More...
 
std::string specialTypeToName () const
 Converts the special type to a usable name for error reporting. More...
 
bool isPostprocessor () const
 
bool isVectorPostprocessor () const
 
void setIsPostprocessor ()
 Sets the special type to a Postprocessor. More...
 
void setIsVectorPostprocessor ()
 Sets the special type to a VectorPostprocessor. More...
 
bool empty () const
 Whether or not the ReporterName is empty, similar to std::string::empty() More...
 

Static Public Member Functions

static bool isValidName (const std::string &object_and_value_name)
 Determines if the inputted string is convertible to a ReporterName. More...
 

Static Public Attributes

static const std::string REPORTER_RESTARTABLE_DATA_PREFIX = "ReporterData"
 The prefix for reporter data in the restartable system. More...
 

Private Types

enum  SpecialType { SpecialType::ANY = 0, SpecialType::POSTPROCESSOR = 1, SpecialType::VECTORPOSTPROCESSOR = 2 }
 Enum for storing a "special" type for this Reporter. More...
 

Private Attributes

ReporterName::SpecialType _special_type = ReporterName::SpecialType::ANY
 The "special" type for this Reporter, used for identifying Postprocesors and VectorPostprocessors. More...
 
std::string _object_name
 The object name. More...
 
std::string _value_name
 The value name. More...
 

Detailed Description

The Reporter system is comprised of objects that can contain any number of data values.

This class is a wrapper that severs two main purposes.

  1. It provides a single "name" for accessing the data. When developing the Reporter system the original implementation required this object to serve as a key in a std::unordered_map. That is no longer the case, but those items remain in case that changes again in the future.
  2. Provide a means for defining special Parser syntax to allow for a single input parameter to define both the object and value name. This is the primary reason for this class, please refer to Parser.C for the specialization.

Examples: ReporterName("object", "data"); ReporterName("object/data");

Definition at line 30 of file ReporterName.h.

Member Enumeration Documentation

◆ SpecialType

enum ReporterName::SpecialType
strongprivate

Enum for storing a "special" type for this Reporter.

This is used to designate Reporters that represent Postprocessors and VectorPostprocessors in output and error handling.

Enumerator
ANY 
POSTPROCESSOR 
VECTORPOSTPROCESSOR 

Definition at line 124 of file ReporterName.h.

125  {
126  ANY = 0,
127  POSTPROCESSOR = 1,
128  VECTORPOSTPROCESSOR = 2
129  };

Constructor & Destructor Documentation

◆ ReporterName() [1/4]

ReporterName::ReporterName ( const std::string &  object_name,
const std::string &  value_name 
)

Definition at line 15 of file ReporterName.C.

16  : _object_name(object_name), _value_name(value_name)
17 {
18 }
std::string _value_name
The value name.
Definition: ReporterName.h:137
std::string _object_name
The object name.
Definition: ReporterName.h:135

◆ ReporterName() [2/4]

ReporterName::ReporterName ( const std::string &  object_and_value_name)

Definition at line 20 of file ReporterName.C.

21 {
22  std::size_t idx = combined_name.rfind("/");
23  if (idx != std::string::npos)
24  {
25  _object_name = combined_name.substr(0, idx);
26  _value_name = combined_name.substr(idx + 1);
27  }
28  else
29  mooseError("Invalid combined Reporter name: ", combined_name);
30 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:333
std::string _value_name
The value name.
Definition: ReporterName.h:137
std::string _object_name
The object name.
Definition: ReporterName.h:135
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)

◆ ReporterName() [3/4]

ReporterName::ReporterName ( const char *  combined_name)

Definition at line 32 of file ReporterName.C.

32 : ReporterName(std::string(combined_name)) {}

◆ ReporterName() [4/4]

ReporterName::ReporterName ( )
inline

Definition at line 36 of file ReporterName.h.

36 {}; // empty constructor for InputParameters

Member Function Documentation

◆ empty()

bool ReporterName::empty ( ) const
inline

Whether or not the ReporterName is empty, similar to std::string::empty()

Definition at line 116 of file ReporterName.h.

116 { return _object_name.empty() || _value_name.empty(); }
std::string _value_name
The value name.
Definition: ReporterName.h:137
std::string _object_name
The object name.
Definition: ReporterName.h:135

◆ getCombinedName()

const std::string ReporterName::getCombinedName ( ) const

Return the name of the object and data as object_name/data_name.

Definition at line 53 of file ReporterName.C.

Referenced by ReporterData::getAllRealReporterFullNames(), ReporterData::getAllRealReporterValues(), getRestartableName(), ReporterTransferInterface::hideVariableHelper(), operator<(), operator<<(), and operator==().

54 {
55  return _object_name + "/" + _value_name;
56 }
std::string _value_name
The value name.
Definition: ReporterName.h:137
std::string _object_name
The object name.
Definition: ReporterName.h:135

◆ getObjectName()

const std::string & ReporterName::getObjectName ( ) const

◆ getRestartableName()

std::string ReporterName::getRestartableName ( ) const

Return the name used for registration of this Reporter in the restartable data system.

Definition at line 59 of file ReporterName.C.

60 {
62 }
static const std::string REPORTER_RESTARTABLE_DATA_PREFIX
The prefix for reporter data in the restartable system.
Definition: ReporterName.h:63
const std::string getCombinedName() const
Return the name of the object and data as object_name/data_name.
Definition: ReporterName.C:53

◆ getValueName()

const std::string & ReporterName::getValueName ( ) const

Return the data name for the Reporter value.

Definition at line 47 of file ReporterName.C.

Referenced by AccumulateReporter::declareAccumulateHelper(), ReporterData::getReporterStateHelper(), and Exodus::outputReporters().

48 {
49  return _value_name;
50 }
std::string _value_name
The value name.
Definition: ReporterName.h:137

◆ isPostprocessor()

bool ReporterName::isPostprocessor ( ) const
inline
Returns
True if this ReporterName represents a Postprocessor

Definition at line 94 of file ReporterName.h.

Referenced by ReporterData::getReporterStateHelper(), and specialTypeToName().

ReporterName::SpecialType _special_type
The "special" type for this Reporter, used for identifying Postprocesors and VectorPostprocessors.
Definition: ReporterName.h:132

◆ isValidName()

bool ReporterName::isValidName ( const std::string &  object_and_value_name)
static

Determines if the inputted string is convertible to a ReporterName.

Parameters
object_and_value_nameThe string to determine convertibility
Returns
true Inputted string has a "/"
false Inputted string does not have a "/"

Definition at line 35 of file ReporterName.C.

Referenced by WebServerControl::startServer().

36 {
37  return combined_name.rfind("/") != std::string::npos;
38 }

◆ isVectorPostprocessor()

bool ReporterName::isVectorPostprocessor ( ) const
inline
Returns
True if this ReporterName represents a VectorPostprocessor

Definition at line 98 of file ReporterName.h.

Referenced by ReporterData::getReporterStateHelper(), and specialTypeToName().

ReporterName::SpecialType _special_type
The "special" type for this Reporter, used for identifying Postprocesors and VectorPostprocessors.
Definition: ReporterName.h:132

◆ operator std::string()

ReporterName::operator std::string ( ) const

std::string operator allows this object to behave as a std::sting object

Definition at line 64 of file ReporterName.C.

64 { return getCombinedName(); }
const std::string getCombinedName() const
Return the name of the object and data as object_name/data_name.
Definition: ReporterName.C:53

◆ operator<()

bool ReporterName::operator< ( const ReporterName rhs) const

Less than operator.

Definition at line 81 of file ReporterName.C.

82 {
83  // Note here that we do not sort by _special_type. This is because
84  // we want to store reporter names as a single name regardless of the type
85  return getCombinedName() < rhs.getCombinedName();
86 }
const std::string getCombinedName() const
Return the name of the object and data as object_name/data_name.
Definition: ReporterName.C:53

◆ operator==() [1/2]

bool ReporterName::operator== ( const ReporterName rhs) const

Compare with another object or string.

Definition at line 67 of file ReporterName.C.

68 {
69  // Note here that we do not check if _special_type is the same. This is because
70  // we want to store reporter names as a single name regardless of the type
71  return _object_name == rhs._object_name && _value_name == rhs._value_name;
72 }
std::string _value_name
The value name.
Definition: ReporterName.h:137
std::string _object_name
The object name.
Definition: ReporterName.h:135

◆ operator==() [2/2]

bool ReporterName::operator== ( const std::string &  combined_name) const

Definition at line 75 of file ReporterName.C.

76 {
77  return getCombinedName() == combined_name;
78 }
const std::string getCombinedName() const
Return the name of the object and data as object_name/data_name.
Definition: ReporterName.C:53

◆ setIsPostprocessor()

void ReporterName::setIsPostprocessor ( )
inline

Sets the special type to a Postprocessor.

See ReporterData::declareReporterValue.

Definition at line 105 of file ReporterName.h.

Referenced by PostprocessorReporterName::PostprocessorReporterName(), and ReporterStateBase::setIsPostprocessor().

ReporterName::SpecialType _special_type
The "special" type for this Reporter, used for identifying Postprocesors and VectorPostprocessors.
Definition: ReporterName.h:132

◆ setIsVectorPostprocessor()

void ReporterName::setIsVectorPostprocessor ( )
inline

Sets the special type to a VectorPostprocessor.

See ReporterData::declareReporterValue.

Definition at line 111 of file ReporterName.h.

Referenced by ReporterStateBase::setIsVectorPostprocessor(), and VectorPostprocessorReporterName::VectorPostprocessorReporterName().

ReporterName::SpecialType _special_type
The "special" type for this Reporter, used for identifying Postprocesors and VectorPostprocessors.
Definition: ReporterName.h:132

◆ specialTypeToName()

std::string ReporterName::specialTypeToName ( ) const

Converts the special type to a usable name for error reporting.

Definition at line 89 of file ReporterName.C.

Referenced by ReporterData::getReporterStateHelper().

90 {
91  if (isPostprocessor())
92  return "Postprocessor";
94  return "VectorPostprocessor";
95  return "Reporter";
96 }
bool isVectorPostprocessor() const
Definition: ReporterName.h:98
bool isPostprocessor() const
Definition: ReporterName.h:94

Member Data Documentation

◆ _object_name

std::string ReporterName::_object_name
private

The object name.

Definition at line 135 of file ReporterName.h.

Referenced by empty(), getCombinedName(), getObjectName(), operator==(), and ReporterName().

◆ _special_type

ReporterName::SpecialType ReporterName::_special_type = ReporterName::SpecialType::ANY
private

The "special" type for this Reporter, used for identifying Postprocesors and VectorPostprocessors.

Definition at line 132 of file ReporterName.h.

Referenced by isPostprocessor(), isVectorPostprocessor(), setIsPostprocessor(), and setIsVectorPostprocessor().

◆ _value_name

std::string ReporterName::_value_name
private

The value name.

Definition at line 137 of file ReporterName.h.

Referenced by empty(), getCombinedName(), getValueName(), operator==(), and ReporterName().

◆ REPORTER_RESTARTABLE_DATA_PREFIX

const std::string ReporterName::REPORTER_RESTARTABLE_DATA_PREFIX = "ReporterData"
static

The prefix for reporter data in the restartable system.

Definition at line 63 of file ReporterName.h.

Referenced by RestartableDataReporter::execute(), and getRestartableName().


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