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 
45  static bool isValidName(const std::string & object_and_value_name);
46 
50  const std::string & getObjectName() const;
51 
55  const std::string & getValueName() const;
56 
60  const std::string getCombinedName() const;
61 
63  static const std::string REPORTER_RESTARTABLE_DATA_PREFIX;
64 
68  std::string getRestartableName() const;
69 
73  operator std::string() const;
74 
78  bool operator==(const ReporterName & rhs) const;
79  bool operator==(const std::string & combined_name) const;
80 
84  bool operator<(const ReporterName & rhs) const;
85 
89  std::string specialTypeToName() const;
90 
99 
112 
116  bool empty() const { return _object_name.empty() || _value_name.empty(); }
117 
118 private:
124  enum class SpecialType
125  {
126  ANY = 0,
127  POSTPROCESSOR = 1,
129  };
130 
133 
135  std::string _object_name;
137  std::string _value_name;
138 };
139 
144 {
145 public:
146  PostprocessorReporterName(const PostprocessorName & name);
147 };
148 
153 {
154 public:
155  VectorPostprocessorReporterName(const VectorPostprocessorName & name,
156  const std::string & vector_name);
157 };
158 
159 // This with the operator== allow this to be used as a key in a std::unordered_map
160 namespace std
161 {
162 template <>
163 struct hash<ReporterName>
164 {
165  size_t operator()(const ReporterName & other) const { return hash<string>{}(other); }
166 };
167 }
168 
169 // Support << output
170 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:124
bool isVectorPostprocessor() const
Definition: ReporterName.h:98
std::ostream & operator<<(std::ostream &os, const ReporterName &state)
Definition: ReporterName.C:99
PostprocessorReporterName(const PostprocessorName &name)
Definition: ReporterName.C:105
VectorPostprocessorReporterName(const VectorPostprocessorName &name, const std::string &vector_name)
Definition: ReporterName.C:111
static const std::string REPORTER_RESTARTABLE_DATA_PREFIX
The prefix for reporter data in the restartable system.
Definition: ReporterName.h:63
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:53
A ReporterName that represents a VectorPostprocessor.
Definition: ReporterName.h:152
ReporterName::SpecialType _special_type
The "special" type for this Reporter, used for identifying Postprocesors and VectorPostprocessors.
Definition: ReporterName.h:132
bool operator<(const ReporterName &rhs) const
Less than operator.
Definition: ReporterName.C:81
size_t operator()(const ReporterName &other) const
Definition: ReporterName.h:165
std::string specialTypeToName() const
Converts the special type to a usable name for error reporting.
Definition: ReporterName.C:89
bool operator==(const ReporterName &rhs) const
Compare with another object or string.
Definition: ReporterName.C:67
std::string _value_name
The value name.
Definition: ReporterName.h:137
std::string _object_name
The object name.
Definition: ReporterName.h:135
bool isPostprocessor() const
Definition: ReporterName.h:94
const std::string & getObjectName() const
Return the object name that produces the Reporter value.
Definition: ReporterName.C:41
A ReporterName that represents a Postprocessor.
Definition: ReporterName.h:143
static bool isValidName(const std::string &object_and_value_name)
Determines if the inputted string is convertible to a ReporterName.
Definition: ReporterName.C:35
void setIsPostprocessor()
Sets the special type to a Postprocessor.
Definition: ReporterName.h:105
void setIsVectorPostprocessor()
Sets the special type to a VectorPostprocessor.
Definition: ReporterName.h:111
std::string getRestartableName() const
Return the name used for registration of this Reporter in the restartable data system.
Definition: ReporterName.C:59
const std::string & getValueName() const
Return the data name for the Reporter value.
Definition: ReporterName.C:47
bool empty() const
Whether or not the ReporterName is empty, similar to std::string::empty()
Definition: ReporterName.h:116
The Reporter system is comprised of objects that can contain any number of data values.
Definition: ReporterName.h:30