LCOV - code coverage report
Current view: top level - src/reporters - ReporterInterface.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31405 (292dce) with base fef103 Lines: 24 30 80.0 %
Date: 2025-09-04 07:52:05 Functions: 6 7 85.7 %
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 "ReporterInterface.h"
      11             : 
      12             : #include "FEProblemBase.h"
      13             : 
      14             : InputParameters
      15    10104123 : ReporterInterface::validParams()
      16             : {
      17    10104123 :   return emptyInputParameters();
      18             : }
      19             : 
      20      440344 : ReporterInterface::ReporterInterface(const MooseObject * moose_object)
      21      880688 :   : _ri_params(moose_object->parameters()),
      22     1761376 :     _ri_fe_problem_base(*_ri_params.getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")),
      23      440344 :     _ri_reporter_data(_ri_fe_problem_base.getReporterData()),
      24      440344 :     _ri_moose_object(*moose_object)
      25             : {
      26      440344 : }
      27             : 
      28             : bool
      29           0 : ReporterInterface::hasReporterValue(const std::string & param_name) const
      30             : {
      31           0 :   if (!reportersAdded())
      32           0 :     _ri_moose_object.mooseError(
      33             :         "Cannot call hasReporterValue() until all Reporters have been constructed.");
      34             : 
      35           0 :   return hasReporterValueByName(getReporterName(param_name));
      36             : }
      37             : 
      38             : bool
      39         128 : ReporterInterface::hasReporterValueByName(const ReporterName & reporter_name) const
      40             : {
      41         128 :   if (!reportersAdded())
      42           0 :     _ri_moose_object.mooseError(
      43             :         "Cannot call hasReporterValueByName() until all Reporters have been constructed.");
      44             : 
      45         128 :   return _ri_reporter_data.hasReporterValue(reporter_name);
      46             : }
      47             : 
      48             : const ReporterContextBase &
      49         128 : ReporterInterface::getReporterContextBaseByName(const ReporterName & reporter_name) const
      50             : {
      51         128 :   if (!reportersAdded())
      52           0 :     _ri_moose_object.mooseError(
      53             :         "Cannot call getReporterContextBaseByName() until all Reporters have been constructed.");
      54             : 
      55         128 :   return _ri_reporter_data.getReporterContextBase(reporter_name);
      56             : }
      57             : 
      58             : const ReporterName &
      59        1107 : ReporterInterface::getReporterName(const std::string & param_name) const
      60             : {
      61        1107 :   if (!_ri_params.isParamValid(param_name))
      62           4 :     _ri_moose_object.mooseError(
      63             :         "When getting a Reporter, failed to get a parameter with the name \"",
      64             :         param_name,
      65             :         "\".",
      66             :         "\n\nKnown parameters:\n",
      67           4 :         _ri_moose_object.parameters());
      68             : 
      69        1103 :   if (_ri_params.isType<ReporterName>(param_name))
      70        1099 :     return _ri_params.get<ReporterName>(param_name);
      71             : 
      72           4 :   _ri_moose_object.mooseError("Supplied parameter with name \"",
      73             :                               param_name,
      74             :                               "\" of type \"",
      75           4 :                               _ri_params.type(param_name),
      76             :                               "\" is not an expected type for getting a Reporter.\n\n",
      77             :                               "The expected type is \"ReporterName\".");
      78             : }
      79             : 
      80             : bool
      81        4197 : ReporterInterface::reportersAdded() const
      82             : {
      83       12591 :   return _ri_fe_problem_base.getMooseApp().actionWarehouse().isTaskComplete("add_reporter");
      84             : }

Generated by: LCOV version 1.14