LCOV - code coverage report
Current view: top level - src/reporters - ReporterName.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 41 44 93.2 %
Date: 2025-07-17 01:28:37 Functions: 14 15 93.3 %
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     1259302 : ReporterName::ReporterName(const std::string & object_name, const std::string & value_name)
      16     1259302 :   : _object_name(object_name), _value_name(value_name)
      17             : {
      18     1259302 : }
      19             : 
      20       36161 : ReporterName::ReporterName(const std::string & combined_name)
      21             : {
      22       36161 :   std::size_t idx = combined_name.rfind("/");
      23       36161 :   if (idx != std::string::npos)
      24             :   {
      25       36161 :     _object_name = combined_name.substr(0, idx);
      26       36161 :     _value_name = combined_name.substr(idx + 1);
      27             :   }
      28             :   else
      29           0 :     mooseError("Invalid combined Reporter name: ", combined_name);
      30       36161 : }
      31             : 
      32          16 : ReporterName::ReporterName(const char * combined_name) : ReporterName(std::string(combined_name)) {}
      33             : 
      34             : const std::string &
      35     1930534 : ReporterName::getObjectName() const
      36             : {
      37     1930534 :   return _object_name;
      38             : }
      39             : 
      40             : const std::string &
      41       54629 : ReporterName::getValueName() const
      42             : {
      43       54629 :   return _value_name;
      44             : }
      45             : 
      46             : const std::string
      47    79225021 : ReporterName::getCombinedName() const
      48             : {
      49   158450042 :   return _object_name + "/" + _value_name;
      50             : }
      51             : 
      52             : std::string
      53     1247515 : ReporterName::getRestartableName() const
      54             : {
      55     2495030 :   return REPORTER_RESTARTABLE_DATA_PREFIX + "/" + getCombinedName();
      56             : }
      57             : 
      58       26567 : ReporterName::operator std::string() const { return getCombinedName(); }
      59             : 
      60             : bool
      61         154 : ReporterName::operator==(const ReporterName & rhs) const
      62             : {
      63             :   // Note here that we do not check if _special_type is the same. This is because
      64             :   // we want to store reporter names as a single name regardless of the type
      65         154 :   return _object_name == rhs._object_name && _value_name == rhs._value_name;
      66             : }
      67             : 
      68             : bool
      69           0 : ReporterName::operator==(const std::string & combined_name) const
      70             : {
      71           0 :   return getCombinedName() == combined_name;
      72             : }
      73             : 
      74             : bool
      75    38954614 : ReporterName::operator<(const ReporterName & rhs) const
      76             : {
      77             :   // Note here that we do not sort by _special_type. This is because
      78             :   // we want to store reporter names as a single name regardless of the type
      79    38954614 :   return getCombinedName() < rhs.getCombinedName();
      80             : }
      81             : 
      82             : std::string
      83        2526 : ReporterName::specialTypeToName() const
      84             : {
      85        2526 :   if (isPostprocessor())
      86        2362 :     return "Postprocessor";
      87         164 :   if (isVectorPostprocessor())
      88          40 :     return "VectorPostprocessor";
      89         124 :   return "Reporter";
      90             : }
      91             : 
      92             : std::ostream &
      93         515 : operator<<(std::ostream & os, const ReporterName & state)
      94             : {
      95         515 :   os << state.getCombinedName();
      96         515 :   return os;
      97             : }
      98             : 
      99     1172050 : PostprocessorReporterName::PostprocessorReporterName(const PostprocessorName & name)
     100     1172050 :   : ReporterName(name, "value")
     101             : {
     102     1172050 :   setIsPostprocessor();
     103     1172050 : }
     104             : 
     105       21407 : VectorPostprocessorReporterName::VectorPostprocessorReporterName(
     106       21407 :     const VectorPostprocessorName & name, const std::string & vector_name)
     107       21407 :   : ReporterName(name, vector_name)
     108             : {
     109       21407 :   setIsVectorPostprocessor();
     110       21407 : }

Generated by: LCOV version 1.14