https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Friends | List of all members
MooseObjectName Class Reference

A class for storing the names of MooseObject by tag and object name. More...

#include <MooseObjectName.h>

Inheritance diagram for MooseObjectName:
[legend]

Public Member Functions

 MooseObjectName (const std::string &tag, const std::string &name, const std::string &separator=std::string("/"))
 Construct the name object.
 
virtual ~MooseObjectName ()=default
 This class requires a virtual (but default) desctructor since it has virtual functions.
 
 MooseObjectName (std::string name)
 Build an object given a raw parameter name (e.g., from an input file parameter)
 
 MooseObjectName (const MooseObjectName &rhs)
 Copy constructor.
 
const std::string & name () const
 Return the name.
 
const std::string & tag () const
 Return the tag.
 
bool operator== (const MooseObjectName &rhs) const
 Comparison operators.
 
bool operator!= (const MooseObjectName &rhs) const
 
bool operator< (const MooseObjectName &rhs) const
 

Protected Member Functions

 MooseObjectName ()
 A constructor for use by MooseObjectParameterName.
 
virtual void check ()
 Check that the name and tag are supplied correctly.
 

Protected Attributes

std::string _tag
 
std::string _name
 
std::string _combined
 
std::string _separator
 

Friends

std::ostream & operator<< (std::ostream &stream, const MooseObjectName &obj)
 Allows this to be used with std:: cout.
 

Detailed Description

A class for storing the names of MooseObject by tag and object name.

This class is used by the Control logic system, allowing for multiple tags to be applied to many different MooseObjects.

There are multiple ways to create an MooseObjectName object, the best being to input the tag and object name as separate inputs. However, this is not always practically if the supplied name is coming from an input file. Therefore, you can use the following single string methods.

MooseObjectName(foo::bar) -> tag="foo", name="bar" MooseObjectName(foo/bar) -> tag="foo", name="bar" MooseObjectName(foo/foo/bar) -> tag="foo/foo", name="bar"

This class also allows for glob style '*' to be used to allow for fuzzy comparisons to be performed.

MooseObjectName name1("*", "bar"); MooseObjectName name2("foo", "bar"); name1 == name2 (True)

MooseObjectName name3("foo", "*"); MooseObjectName name4("foo", "bar"); name3 == name4 (True)

Definition at line 40 of file MooseObjectName.h.

Constructor & Destructor Documentation

◆ MooseObjectName() [1/4]

MooseObjectName::MooseObjectName ( const std::string &  tag,
const std::string &  name,
const std::string &  separator = std::string("/") 
)

Construct the name object.

Parameters
tagThe tag to apply the object
nameThe name of the object

Definition at line 17 of file MooseObjectName.C.

20 : _tag(tag), _name(name), _combined(tag + name), _separator(separator)
21{
22 check();
23}
std::string _separator
const std::string & name() const
Return the name.
std::string _combined
const std::string & tag() const
Return the tag.
virtual void check()
Check that the name and tag are supplied correctly.

◆ ~MooseObjectName()

virtual MooseObjectName::~MooseObjectName ( )
virtualdefault

This class requires a virtual (but default) desctructor since it has virtual functions.

◆ MooseObjectName() [2/4]

MooseObjectName::MooseObjectName ( std::string  name)

Build an object given a raw parameter name (e.g., from an input file parameter)

Definition at line 25 of file MooseObjectName.C.

25 : _separator("::")
26{
27 // Tags may be separated by a :: or the last /
28 std::size_t idx0 = name.find("::");
29 std::size_t idx1 = name.rfind("/");
30
31 // Case when :: is found
32 if (idx0 != std::string::npos)
33 {
34 _tag = name.substr(0, idx0);
35 _name = name.erase(0, idx0 + 2);
36 }
37
38 // Case when a / is found
39 else if (idx1 != std::string::npos)
40 {
41 _tag = name.substr(0, idx1);
42 _name = name.erase(0, idx1 + 1);
43 _separator = "/";
44 }
45
46 // If you get here, just use the supplied name without a tag (this will produce an error in check)
47 else
48 _name = name;
49
50 check();
52}

◆ MooseObjectName() [3/4]

MooseObjectName::MooseObjectName ( const MooseObjectName rhs)

Copy constructor.

Definition at line 56 of file MooseObjectName.C.

58{
59}

◆ MooseObjectName() [4/4]

MooseObjectName::MooseObjectName ( )
protected

A constructor for use by MooseObjectParameterName.

Definition at line 54 of file MooseObjectName.C.

54: _separator("/") {}

Member Function Documentation

◆ check()

void MooseObjectName::check ( )
protectedvirtual

Check that the name and tag are supplied correctly.

Reimplemented in MooseObjectParameterName.

Definition at line 94 of file MooseObjectName.C.

95{
96 if (_name.empty())
97 mooseError("The supplied name cannot be empty, to allow for any name to be supplied use the "
98 "'*' character.");
99 if (_tag.empty())
100 mooseError("The supplied tag cannot be empty, to allow for any tag to be supplied use the '*' "
101 "character.");
102}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311

Referenced by MooseObjectParameterName::check(), MooseObjectName(), and MooseObjectName().

◆ name()

const std::string & MooseObjectName::name ( ) const
inline

◆ operator!=()

bool MooseObjectName::operator!= ( const MooseObjectName rhs) const

Definition at line 73 of file MooseObjectName.C.

74{
75 return !(*this == rhs);
76}

Referenced by MooseObjectParameterName::operator!=().

◆ operator<()

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

Definition at line 78 of file MooseObjectName.C.

80{
81 return (_combined < rhs._combined);
82}

◆ operator==()

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

Comparison operators.

The less than operator is required so this container can work in std::map.

See also
InputParameterWarehouse

Definition at line 62 of file MooseObjectName.C.

63{
64 if ((_name == rhs._name || _name == "*" || rhs._name == "*") &&
65 (_tag == rhs._tag || _tag == "*" || rhs._tag == "*"))
66 {
67 return true;
68 }
69 return false;
70}

Referenced by MooseObjectParameterName::operator==().

◆ tag()

const std::string & MooseObjectName::tag ( ) const
inline

Return the tag.

Definition at line 76 of file MooseObjectName.h.

76{ return _tag; }

Referenced by InputParameterWarehouse::addInputParameters().

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  stream,
const MooseObjectName obj 
)
friend

Allows this to be used with std:: cout.

Definition at line 84 of file MooseObjectName.C.

86{
87 if (obj._tag.empty())
88 return stream << obj._name;
89 else
90 return stream << obj._tag << obj._separator << obj._name;
91}

Member Data Documentation

◆ _combined

std::string MooseObjectName::_combined
protected

◆ _name

std::string MooseObjectName::_name
protected

◆ _separator

std::string MooseObjectName::_separator
protected

◆ _tag

std::string MooseObjectName::_tag
protected

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