LCOV - code coverage report
Current view: top level - include/base - MooseObject.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 863ef6 Lines: 4 4 100.0 %
Date: 2025-10-15 18:16:15 Functions: 3 4 75.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             : // MOOSE includes
      13             : #include "MooseUtils.h"
      14             : #include "ParallelParamObject.h"
      15             : #include "InputParameters.h"
      16             : #include "ConsoleStreamInterface.h"
      17             : #include "Registry.h"
      18             : #include "MooseObjectParameterName.h"
      19             : 
      20             : #define usingMooseObjectMembers                                                                    \
      21             :   usingMooseBaseMembers;                                                                           \
      22             :   using MooseObject::enabled
      23             : 
      24             : /**
      25             :  * Every object that can be built by the factory should be derived from this class.
      26             :  */
      27             : class MooseObject : public ParallelParamObject, public std::enable_shared_from_this<MooseObject>
      28             : {
      29             : public:
      30             :   static InputParameters validParams();
      31             : 
      32             :   MooseObject(const InputParameters & parameters);
      33             : 
      34             : #ifdef MOOSE_KOKKOS_ENABLED
      35             :   /**
      36             :    * Special constructor used for Kokkos functor copy during parallel dispatch
      37             :    */
      38             :   MooseObject(const MooseObject & object, const Moose::Kokkos::FunctorCopy & key);
      39             : #endif
      40             : 
      41     2567508 :   virtual ~MooseObject() = default;
      42             : 
      43             :   /**
      44             :    * Return the enabled status of the object.
      45             :    */
      46   163836968 :   virtual bool enabled() const { return _enabled; }
      47             : 
      48             :   /**
      49             :    * Get another shared pointer to this object that has the same ownership group. Wrapper around
      50             :    * shared_from_this().
      51             :    */
      52             :   std::shared_ptr<MooseObject> getSharedPtr();
      53             :   std::shared_ptr<const MooseObject> getSharedPtr() const;
      54             : 
      55             : #ifdef MOOSE_KOKKOS_ENABLED
      56             :   class IsKokkosObjectKey
      57             :   {
      58             :     friend class BlockRestrictable;
      59             :     friend class BoundaryRestrictable;
      60             :     friend class MaterialPropertyInterface;
      61             :     IsKokkosObjectKey() = default;
      62             :     IsKokkosObjectKey(const IsKokkosObjectKey &) = delete;
      63             :     IsKokkosObjectKey(IsKokkosObjectKey &&) = delete;
      64             :   };
      65             : 
      66             :   /**
      67             :    * Get whether this object is a Kokkos functor
      68             :    * The parameter is set by the Kokkos base classes:
      69             :    * - Moose::Kokkos::ResidualObject in KokkosResidualObject.K
      70             :    * - Moose::Kokkos::MaterialBase in KokkosMaterialBase.K
      71             :    */
      72     1283757 :   bool isKokkosObject(IsKokkosObjectKey &&) const
      73             :   {
      74     1283757 :     return parameters().isParamValid(MooseBase::kokkos_object_param);
      75             :   }
      76             : #endif
      77             : 
      78             : protected:
      79             :   /// Reference to the "enable" InputParameters, used by Controls for toggling on/off MooseObjects
      80             :   const bool & _enabled;
      81             : 
      82             :   // Base classes have the same name for that attribute, pick one
      83             :   using MooseBase::_app;
      84             : };

Generated by: LCOV version 1.14