LCOV - code coverage report
Current view: top level - include/interfaces - NamingInterface.h (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 25 26 96.2 %
Date: 2025-07-30 13:02:48 Functions: 4 4 100.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             : #include "ThermalHydraulicsApp.h"
      13             : 
      14             : class ThermalHydraulicsApp;
      15             : class NamingInterface;
      16             : 
      17             : /**
      18             :  * Interface for handling names
      19             :  */
      20             : class NamingInterface
      21             : {
      22             : public:
      23             :   NamingInterface() {}
      24             : 
      25             :   /**
      26             :    * Build a name from a prefix, number and possible suffix
      27             :    */
      28             :   std::string
      29       19293 :   genName(const std::string & prefix, unsigned int id, const std::string & suffix = "") const
      30             :   {
      31       19293 :     std::stringstream ss;
      32       19293 :     ss << prefix << ":" << id;
      33       19293 :     if (!suffix.empty())
      34       19293 :       ss << ":" << suffix;
      35       19293 :     return ss.str();
      36       19293 :   }
      37             : 
      38             :   /**
      39             :    * Build a name from a prefix, 2 numbers and possible suffix
      40             :    */
      41             :   std::string genName(const std::string & prefix,
      42             :                       unsigned int i,
      43             :                       unsigned int j,
      44             :                       const std::string & suffix = "") const
      45             :   {
      46             :     std::stringstream ss;
      47             :     ss << prefix << ":" << i << ":" << j;
      48             :     if (!suffix.empty())
      49             :       ss << ":" << suffix;
      50             :     return ss.str();
      51             :   }
      52             : 
      53             :   /**
      54             :    * Build a name from 2 strings and a number
      55             :    */
      56       10575 :   std::string genName(const std::string & prefix, const std::string & name, unsigned int i) const
      57             :   {
      58       10575 :     std::stringstream ss;
      59       21150 :     ss << prefix << ":" << name << ":" << i;
      60       10575 :     return ss.str();
      61       10575 :   }
      62             : 
      63             :   /**
      64             :    * Build a name from strings
      65             :    */
      66      244198 :   std::string genName(const std::string & prefix,
      67             :                       const std::string & middle,
      68             :                       const std::string & suffix = "") const
      69             :   {
      70      244198 :     std::stringstream ss;
      71      244198 :     ss << prefix << ":" << middle;
      72      244198 :     if (!suffix.empty())
      73       56689 :       ss << ":" << suffix;
      74      244198 :     return ss.str();
      75      244198 :   }
      76             : 
      77             :   /**
      78             :    * Build a name from strings that is safe to use in input files (i.e. can be exposed to users)
      79             :    */
      80          97 :   std::string genSafeName(const std::string & prefix,
      81             :                           const std::string & middle,
      82             :                           const std::string & suffix = "") const
      83             :   {
      84          97 :     std::stringstream ss;
      85          97 :     ss << prefix << "_" << middle;
      86          97 :     if (!suffix.empty())
      87           0 :       ss << "_" << suffix;
      88          97 :     return ss.str();
      89          97 :   }
      90             : };

Generated by: LCOV version 1.14