https://mooseframework.inl.gov
ReporterName.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 #pragma once
10 
11 #include <iostream>
12 #include "MooseTypes.h"
13 
31 {
32 public:
33  ReporterName(const std::string & object_name, const std::string & value_name);
34  ReporterName(const std::string & object_and_value_name);
35  ReporterName(const char * combined_name);
36  ReporterName(){}; // empty constructor for InputParameters
37 
41  const std::string & getObjectName() const;
42 
46  const std::string & getValueName() const;
47 
51  const std::string getCombinedName() const;
52 
54  static const std::string REPORTER_RESTARTABLE_DATA_PREFIX;
55 
59  std::string getRestartableName() const;
60 
64  operator std::string() const;
65 
69  bool operator==(const ReporterName & rhs) const;
70  bool operator==(const std::string & combined_name) const;
71 
75  bool operator<(const ReporterName & rhs) const;
76 
80  std::string specialTypeToName() const;
81 
90 
103 
107  bool empty() const { return _object_name.empty() || _value_name.empty(); }
108 
109 private:
115  enum class SpecialType
116  {
117  ANY = 0,
118  POSTPROCESSOR = 1,
120  };
121 
124 
126  std::string _object_name;
128  std::string _value_name;
129 };
130 
135 {
136 public:
137  PostprocessorReporterName(const PostprocessorName & name);
138 };
139 
144 {
145 public:
146  VectorPostprocessorReporterName(const VectorPostprocessorName & name,
147  const std::string & vector_name);
148 };
149 
150 // This with the operator== allow this to be used as a key in a std::unordered_map
151 namespace std
152 {
153 template <>
154 struct hash<ReporterName>
155 {
156  size_t operator()(const ReporterName & other) const { return hash<string>{}(other); }
157 };
158 }
159 
160 // Support << output
161 std::ostream & operator<<(std::ostream & os, const ReporterName & state);
std::string name(const ElemQuality q)
SpecialType
Enum for storing a "special" type for this Reporter.
Definition: ReporterName.h:115
bool isVectorPostprocessor() const
Definition: ReporterName.h:89
std::ostream & operator<<(std::ostream &os, const ReporterName &state)
Definition: ReporterName.C:93
PostprocessorReporterName(const PostprocessorName &name)
Definition: ReporterName.C:99
VectorPostprocessorReporterName(const VectorPostprocessorName &name, const std::string &vector_name)
Definition: ReporterName.C:105
static const std::string REPORTER_RESTARTABLE_DATA_PREFIX
The prefix for reporter data in the restartable system.
Definition: ReporterName.h:54
std::basic_ostream< charT, traits > * os
Definition: InfixIterator.h:33
const std::string getCombinedName() const
Return the name of the object and data as object_name/data_name.
Definition: ReporterName.C:47
A ReporterName that represents a VectorPostprocessor.
Definition: ReporterName.h:143
ReporterName::SpecialType _special_type
The "special" type for this Reporter, used for identifying Postprocesors and VectorPostprocessors.
Definition: ReporterName.h:123
bool operator<(const ReporterName &rhs) const
Less than operator.
Definition: ReporterName.C:75
size_t operator()(const ReporterName &other) const
Definition: ReporterName.h:156
std::string specialTypeToName() const
Converts the special type to a usable name for error reporting.
Definition: ReporterName.C:83
bool operator==(const ReporterName &rhs) const
Compare with another object or string.
Definition: ReporterName.C:61
std::string _value_name
The value name.
Definition: ReporterName.h:128
std::string _object_name
The object name.
Definition: ReporterName.h:126
bool isPostprocessor() const
Definition: ReporterName.h:85
const std::string & getObjectName() const
Return the object name that produces the Reporter value.
Definition: ReporterName.C:35
A ReporterName that represents a Postprocessor.
Definition: ReporterName.h:134
void setIsPostprocessor()
Sets the special type to a Postprocessor.
Definition: ReporterName.h:96
void setIsVectorPostprocessor()
Sets the special type to a VectorPostprocessor.
Definition: ReporterName.h:102
std::string getRestartableName() const
Return the name used for registration of this Reporter in the restartable data system.
Definition: ReporterName.C:53
const std::string & getValueName() const
Return the data name for the Reporter value.
Definition: ReporterName.C:41
bool empty() const
Whether or not the ReporterName is empty, similar to std::string::empty()
Definition: ReporterName.h:107
The Reporter system is comprised of objects that can contain any number of data values.
Definition: ReporterName.h:30