https://mooseframework.inl.gov
MooseObjectParameterName.C
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 
10 // MOOSE includes
12 #include "MooseError.h"
13 
14 // STL includes
15 #include <iostream>
16 
18  const std::string & param)
19  : MooseObjectName(obj_name), _parameter(param)
20 {
22 }
23 
25  const std::string & name,
26  const std::string & param,
27  const std::string & separator)
28  : MooseObjectName(tag, name, separator), _parameter(param)
29 {
31 }
32 
34  : MooseObjectName(rhs._tag, rhs._name, rhs._separator), _parameter(rhs._parameter)
35 {
37 }
38 
40 {
41  // The tag precedes the :: (this is used in _moose_base::name and control_tag::name conventions)
42  std::size_t idx = name.find("::");
43  if (idx != std::string::npos)
44  {
45  _tag = name.substr(0, idx);
46  name.erase(0, idx + 2);
47  _separator = "::";
48  }
49 
50  // Locate the param name
51  idx = name.rfind("/");
52  if (idx != std::string::npos)
53  {
54  _parameter = name.substr(idx + 1);
55  name.erase(idx);
56  }
57  else // if a slash isn't located then the entire name must be the parameter
58  {
59  _parameter = name;
60  name.erase();
61  }
62 
63  // If there is a second slash, there is a syntax based tag: tag/object_name/param
64  idx = name.rfind("/");
65  if (idx != std::string::npos)
66  {
67  _name = name.substr(idx + 1);
68  name.erase(idx);
69  _tag = name;
70  }
71 
72  // If content still exists in "name", then this must be the object name
73  if (_name.empty() && !name.empty())
74  _name = name;
75 
76  // Set the combined name for sorting
78 }
79 
80 bool
82 {
83  if (MooseObjectName::operator==(rhs) &&
84  (_parameter == rhs._parameter || _parameter == "*" || rhs._parameter == "*"))
85  return true;
86  return false;
87 }
88 
89 bool
91 {
92  return MooseObjectName::operator==(rhs);
93 }
94 
95 bool
97 {
98  return !(*this == rhs);
99 }
100 
101 bool
103 {
104  return MooseObjectName::operator!=(rhs);
105 }
106 
107 bool
109 {
110  return (_combined < rhs._combined);
111 }
112 
113 std::ostream &
114 operator<<(std::ostream & stream, const MooseObjectParameterName & obj)
115 {
116  if (obj._tag.empty() && obj._name.empty())
117  return stream << obj._parameter;
118  else if (obj._tag.empty())
119  return stream << obj._name << "/" << obj._parameter;
120  else if (obj._name.empty())
121  return stream << obj._tag << obj._separator << obj._parameter;
122  else
123  return stream << obj._tag << obj._separator << obj._name << "/" << obj._parameter;
124 }
125 
126 void
128 {
130  if (_parameter.empty())
131  mooseError("The supplied parameter name cannot be empty, to allow for any parameter name to be "
132  "supplied use the '*' character.");
133 }
std::string name(const ElemQuality q)
const std::string & name() const
Return the name.
std::string _combined
std::ostream & operator<<(std::ostream &stream, const MooseObjectParameterName &obj)
std::string _tag
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
MooseObjectParameterName(std::string name)
Build an object given a raw parameter name (e.g., from an input file parameter)
std::string _parameter
The name of the input parameter.
std::string _name
virtual void check() final
Adds the parameter name to error checking.
virtual void check()
Check that the name and tag are supplied correctly.
bool operator!=(const MooseObjectName &rhs) const
bool operator==(const MooseObjectName &rhs) const
Comparison operators.
std::string _separator
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
bool operator==(const MooseObjectParameterName &rhs) const
Comparison operators.
A class for storing an input parameter name.
bool operator<(const MooseObjectParameterName &rhs) const
A class for storing the names of MooseObject by tag and object name.
bool operator!=(const MooseObjectParameterName &rhs) const
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)