LCOV - code coverage report
Current view: top level - include/base - MooseBase.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 4 4 100.0 %
Date: 2025-07-17 01:28:37 Functions: 4 5 80.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 <string>
      13             : 
      14             : class InputParameters;
      15             : class MooseApp;
      16             : 
      17             : #define usingMooseBaseMembers                                                                      \
      18             :   using MooseBase::getMooseApp;                                                                    \
      19             :   using MooseBase::type;                                                                           \
      20             :   using MooseBase::name;                                                                           \
      21             :   using MooseBase::typeAndName;                                                                    \
      22             :   using MooseBase::_type;                                                                          \
      23             :   using MooseBase::_app;                                                                           \
      24             :   using MooseBase::_name
      25             : 
      26             : /**
      27             :  * Base class for everything in MOOSE with a name and a type.
      28             :  * You will most likely want to inherit instead
      29             :  * - MooseObject for an object created within a system
      30             :  * - Action for a class performing a setup task, like creating objects
      31             :  */
      32             : class MooseBase
      33             : {
      34             : public:
      35             :   MooseBase(const std::string & type,
      36             :             const std::string & name,
      37             :             MooseApp & app,
      38             :             const InputParameters & params);
      39             : 
      40     4926185 :   virtual ~MooseBase() = default;
      41             : 
      42             :   /**
      43             :    * Get the MooseApp this class is associated with.
      44             :    */
      45    24139069 :   MooseApp & getMooseApp() const { return _app; }
      46             : 
      47             :   /**
      48             :    * Get the type of this class.
      49             :    * @return the name of the type of this class
      50             :    */
      51     6920683 :   const std::string & type() const { return _type; }
      52             : 
      53             :   /**
      54             :    * Get the name of the class
      55             :    * @return The name of the class
      56             :    */
      57    30405915 :   virtual const std::string & name() const { return _name; }
      58             : 
      59             :   /**
      60             :    * Get the class's combined type and name; useful in error handling.
      61             :    * @return The type and name of this class in the form '<type()> "<name()>"'.
      62             :    */
      63             :   std::string typeAndName() const;
      64             : 
      65             :   /**
      66             :    * @returns A prefix to be used in errors that contains the input
      67             :    * file location associated with this object (if any) and the
      68             :    * name and type of the object.
      69             :    */
      70             :   std::string errorPrefix(const std::string & error_type) const;
      71             : 
      72             :   /**
      73             :    * Calls moose error with the message \p msg.
      74             :    *
      75             :    * Will prefix the message with the subapp name if one exists.
      76             :    *
      77             :    * If \p with_prefix, then add the prefix from errorPrefix()
      78             :    * to the error.
      79             :    */
      80             :   [[noreturn]] void callMooseError(std::string msg, const bool with_prefix) const;
      81             : 
      82             : protected:
      83             :   /// The MOOSE application this is associated with
      84             :   MooseApp & _app;
      85             : 
      86             :   /// The type of this class
      87             :   const std::string _type;
      88             : 
      89             :   /// The name of this class
      90             :   const std::string _name;
      91             : 
      92             : private:
      93             :   /// The object's parameteres
      94             :   const InputParameters & _params;
      95             : };

Generated by: LCOV version 1.14