www.mooseframework.org
MooseObjectParameterName.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 // MOOSE includes
17 #include "MooseError.h"
18 
19 // STL includes
20 #include <iostream>
21 
23  const std::string & param)
24  : MooseObjectName(obj_name), _parameter(param)
25 {
27 }
28 
30  const std::string & name,
31  const std::string & param,
32  const std::string & separator)
33  : MooseObjectName(tag, name, separator), _parameter(param)
34 {
36 }
37 
39 {
40  // The tag precedes the :: (this is used in _moose_base::name and control_tag::name conventions)
41  std::size_t idx = name.find("::");
42  if (idx != std::string::npos)
43  {
44  _tag = name.substr(0, idx);
45  name.erase(0, idx + 2);
46  _separator = "::";
47  }
48 
49  // Locate the param name
50  idx = name.rfind("/");
51  if (idx != std::string::npos)
52  {
53  _parameter = name.substr(idx + 1);
54  name.erase(idx);
55  }
56  else // if a slash isn't located then the entire name must be the parameter
57  {
58  _parameter = name;
59  name.erase();
60  }
61 
62  // If there is a second slash, there is a syntax based tag: tag/object_name/param
63  idx = name.rfind("/");
64  if (idx != std::string::npos)
65  {
66  _name = name.substr(idx + 1);
67  name.erase(idx);
68  _tag = name;
69  }
70 
71  // If content still exists in "name", then this must be the object name
72  if (_name.empty() && !name.empty())
73  _name = name;
74 
75  // Set the combined name for sorting
77 }
78 
79 bool
81 {
82  if (MooseObjectName::operator==(rhs) &&
83  (_parameter == rhs._parameter || _parameter == "*" || rhs._parameter == "*"))
84  return true;
85  return false;
86 }
87 
88 bool
90 {
91  return MooseObjectName::operator==(rhs);
92 }
93 
94 bool
96 {
97  return !(*this == rhs);
98 }
99 
100 bool
102 {
103  return MooseObjectName::operator!=(rhs);
104 }
105 
106 bool
108 {
109  return (_combined < rhs._combined);
110 }
111 
112 std::ostream &
113 operator<<(std::ostream & stream, const MooseObjectParameterName & obj)
114 {
115  if (obj._tag.empty() && obj._name.empty())
116  return stream << obj._parameter;
117  else if (obj._tag.empty())
118  return stream << obj._name << "/" << obj._parameter;
119  else if (obj._name.empty())
120  return stream << obj._tag << obj._separator << obj._parameter;
121  else
122  return stream << obj._tag << obj._separator << obj._name << "/" << obj._parameter;
123 }
124 
125 void
127 {
129  if (_parameter.empty())
130  mooseError("The supplied parameter name cannot be empty, to allow for any parameter name to be "
131  "supplied use the '*' character.");
132 }
bool operator!=(const MooseObjectParameterName &rhs) const
std::string _combined
std::string _tag
if(nl->nonlinearSolver() ->matvec &&nl->nonlinearSolver() ->residual_and_jacobian_object)
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
const std::string & name() const
Return the name.
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
const std::string & tag() const
Return the tag.
virtual void check() final
Adds the parameter name to error checking.
virtual void check()
Check that the name and tag are supplied correctly.
friend std::ostream & operator<<(std::ostream &stream, const MooseObjectParameterName &obj)
bool operator!=(const MooseObjectName &rhs) const
std::string _separator
bool operator<(const MooseObjectParameterName &rhs) const
A class for storing an input parameter name.
bool operator==(const MooseObjectParameterName &rhs) const
Comparison operators.
bool operator==(const MooseObjectName &rhs) const
Comparison operators.
A class for storing the names of MooseObject by tag and object name.