LCOV - code coverage report
Current view: top level - src/reporters - ReporterName.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 909fe5 Lines: 43 46 93.5 %
Date: 2025-08-29 20:01:24 Functions: 15 16 93.8 %
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             : #include "ReporterName.h"
      11             : #include "MooseError.h"
      12             : 
      13             : const std::string ReporterName::REPORTER_RESTARTABLE_DATA_PREFIX = "ReporterData";
      14             : 
      15     1790271 : ReporterName::ReporterName(const std::string & object_name, const std::string & value_name)
      16     1790271 :   : _object_name(object_name), _value_name(value_name)
      17             : {
      18     1790271 : }
      19             : 
      20       40726 : ReporterName::ReporterName(const std::string & combined_name)
      21             : {
      22       40726 :   std::size_t idx = combined_name.rfind("/");
      23       40726 :   if (idx != std::string::npos)
      24             :   {
      25       40726 :     _object_name = combined_name.substr(0, idx);
      26       40726 :     _value_name = combined_name.substr(idx + 1);
      27             :   }
      28             :   else
      29           0 :     mooseError("Invalid combined Reporter name: ", combined_name);
      30       40726 : }
      31             : 
      32          48 : ReporterName::ReporterName(const char * combined_name) : ReporterName(std::string(combined_name)) {}
      33             : 
      34             : bool
      35         128 : ReporterName::isValidName(const std::string & combined_name)
      36             : {
      37         128 :   return combined_name.rfind("/") != std::string::npos;
      38             : }
      39             : 
      40             : const std::string &
      41     2234961 : ReporterName::getObjectName() const
      42             : {
      43     2234961 :   return _object_name;
      44             : }
      45             : 
      46             : const std::string &
      47       61093 : ReporterName::getValueName() const
      48             : {
      49       61093 :   return _value_name;
      50             : }
      51             : 
      52             : const std::string
      53   107743483 : ReporterName::getCombinedName() const
      54             : {
      55   215486966 :   return _object_name + "/" + _value_name;
      56             : }
      57             : 
      58             : std::string
      59     1773530 : ReporterName::getRestartableName() const
      60             : {
      61     1773530 :   return REPORTER_RESTARTABLE_DATA_PREFIX + "/" + getCombinedName();
      62             : }
      63             : 
      64       29862 : ReporterName::operator std::string() const { return getCombinedName(); }
      65             : 
      66             : bool
      67         168 : ReporterName::operator==(const ReporterName & rhs) const
      68             : {
      69             :   // Note here that we do not check if _special_type is the same. This is because
      70             :   // we want to store reporter names as a single name regardless of the type
      71         168 :   return _object_name == rhs._object_name && _value_name == rhs._value_name;
      72             : }
      73             : 
      74             : bool
      75           0 : ReporterName::operator==(const std::string & combined_name) const
      76             : {
      77           0 :   return getCombinedName() == combined_name;
      78             : }
      79             : 
      80             : bool
      81    52947315 : ReporterName::operator<(const ReporterName & rhs) const
      82             : {
      83             :   // Note here that we do not sort by _special_type. This is because
      84             :   // we want to store reporter names as a single name regardless of the type
      85    52947315 :   return getCombinedName() < rhs.getCombinedName();
      86             : }
      87             : 
      88             : std::string
      89        2693 : ReporterName::specialTypeToName() const
      90             : {
      91        2693 :   if (isPostprocessor())
      92        4968 :     return "Postprocessor";
      93         209 :   if (isVectorPostprocessor())
      94         170 :     return "VectorPostprocessor";
      95         248 :   return "Reporter";
      96             : }
      97             : 
      98             : std::ostream &
      99         540 : operator<<(std::ostream & os, const ReporterName & state)
     100             : {
     101         540 :   os << state.getCombinedName();
     102         540 :   return os;
     103             : }
     104             : 
     105     1695173 : PostprocessorReporterName::PostprocessorReporterName(const PostprocessorName & name)
     106     3390346 :   : ReporterName(name, "value")
     107             : {
     108     1695173 :   setIsPostprocessor();
     109     1695173 : }
     110             : 
     111       23068 : VectorPostprocessorReporterName::VectorPostprocessorReporterName(
     112       23068 :     const VectorPostprocessorName & name, const std::string & vector_name)
     113       23068 :   : ReporterName(name, vector_name)
     114             : {
     115       23068 :   setIsVectorPostprocessor();
     116       23068 : }

Generated by: LCOV version 1.14