LCOV - code coverage report
Current view: top level - include/utils - MooseObjectName.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 3 3 100.0 %
Date: 2025-07-17 01:28:37 Functions: 3 4 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #pragma once
      11             : 
      12             : // STL includes
      13             : #include <string>
      14             : 
      15             : /**
      16             :  * A class for storing the names of MooseObject by tag and object name.
      17             :  *
      18             :  * This class is used by the Control logic system, allowing for multiple tags
      19             :  * to be applied to many different MooseObjects.
      20             :  *
      21             :  * There are multiple ways to create an MooseObjectName object, the best being to input the
      22             :  * tag and object name as separate inputs. However, this is not always practically if the supplied
      23             :  * name is coming from an input file. Therefore, you can use the following single string methods.
      24             :  *
      25             :  * MooseObjectName(foo::bar)    -> tag="foo", name="bar"
      26             :  * MooseObjectName(foo/bar)     -> tag="foo", name="bar"
      27             :  * MooseObjectName(foo/foo/bar) -> tag="foo/foo", name="bar"
      28             :  *
      29             :  * This class also allows for glob style '*' to be used to allow for fuzzy comparisons to be
      30             :  * performed.
      31             :  *
      32             :  * MooseObjectName name1("*", "bar");
      33             :  * MooseObjectName name2("foo", "bar");
      34             :  * name1 == name2 (True)
      35             :  *
      36             :  * MooseObjectName name3("foo", "*");
      37             :  * MooseObjectName name4("foo", "bar");
      38             :  * name3 == name4 (True)
      39             :  */
      40             : class MooseObjectName
      41             : {
      42             : public:
      43             :   /**
      44             :    * Construct the name object.
      45             :    * @param tag The tag to apply the object
      46             :    * @param name The name of the object
      47             :    */
      48             :   MooseObjectName(const std::string & tag,
      49             :                   const std::string & name,
      50             :                   const std::string & separator = std::string("/"));
      51             : 
      52             :   /**
      53             :    * This class requires a virtual (but default) desctructor since it
      54             :    * has virtual functions.
      55             :    */
      56    29724822 :   virtual ~MooseObjectName() = default;
      57             : 
      58             :   /**
      59             :    * Build an object given a raw parameter name (e.g., from an input file parameter)
      60             :    */
      61             :   MooseObjectName(std::string name);
      62             : 
      63             :   /**
      64             :    * Copy constructor.
      65             :    */
      66             :   MooseObjectName(const MooseObjectName & rhs);
      67             : 
      68             :   /**
      69             :    * Return the name.
      70             :    */
      71          70 :   const std::string & name() const { return _name; }
      72             : 
      73             :   /**
      74             :    * Return the tag.
      75             :    */
      76          70 :   const std::string & tag() const { return _tag; }
      77             : 
      78             :   ///@{
      79             :   /**
      80             :    * Comparison operators.
      81             :    *
      82             :    * The less than operator is required so this container can work in std::map.
      83             :    *
      84             :    * @see InputParameterWarehouse
      85             :    */
      86             :   bool operator==(const MooseObjectName & rhs) const;
      87             :   bool operator!=(const MooseObjectName & rhs) const;
      88             :   bool operator<(const MooseObjectName & rhs) const;
      89             :   ///@}
      90             : 
      91             :   /// Allows this to be used with std:: cout
      92             :   friend std::ostream & operator<<(std::ostream & stream, const MooseObjectName & obj);
      93             : 
      94             : protected:
      95             :   /**
      96             :    * A constructor for use by MooseObjectParameterName
      97             :    */
      98             :   MooseObjectName();
      99             : 
     100             :   ///@{
     101             :   /// Storage for the various name components
     102             :   std::string _tag;
     103             :   std::string _name;
     104             :   std::string _combined;
     105             :   std::string _separator; // used for better error messages only
     106             :   ///@}
     107             : 
     108             :   /**
     109             :    * Check that the name and tag are supplied correctly.
     110             :    */
     111             :   virtual void check();
     112             : };

Generated by: LCOV version 1.14