LCOV - code coverage report
Current view: top level - include/base - libmesh_singleton.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 2 2 100.0 %
Date: 2025-08-19 19:27:09 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // The libMesh Finite Element Library.
       2             : // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
       3             : 
       4             : // This library is free software; you can redistribute it and/or
       5             : // modify it under the terms of the GNU Lesser General Public
       6             : // License as published by the Free Software Foundation; either
       7             : // version 2.1 of the License, or (at your option) any later version.
       8             : 
       9             : // This library is distributed in the hope that it will be useful,
      10             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12             : // Lesser General Public License for more details.
      13             : 
      14             : // You should have received a copy of the GNU Lesser General Public
      15             : // License along with this library; if not, write to the Free Software
      16             : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      17             : 
      18             : 
      19             : 
      20             : #ifndef LIBMESH_LIBMESH_SINGLETON_H
      21             : #define LIBMESH_LIBMESH_SINGLETON_H
      22             : 
      23             : #include "libmesh/libmesh_common.h"
      24             : 
      25             : namespace libMesh
      26             : {
      27             : 
      28             : /**
      29             :  * Base class for all library singleton objects.
      30             :  *
      31             :  * \author Benjamin S. Kirk
      32             :  * \date 2013
      33             :  * \brief Base class for all library singleton objects.
      34             :  */
      35             : class Singleton
      36             : {
      37             : protected:
      38             : 
      39             :   /**
      40             :    * Constructor.  Adds the derived object to the singleton cache list.
      41             :    */
      42             :   Singleton();
      43             : 
      44             :   /**
      45             :    * Destructor.
      46             :    */
      47       16395 :   virtual ~Singleton() = default;
      48             : 
      49             : public:
      50             : 
      51             :   /**
      52             :    * Abstract base class for runtime singleton setup.
      53             :    * This will be called from the \p LibMeshInit constructor.
      54             :    */
      55             :   class Setup
      56             :   {
      57             :   protected:
      58             :     /**
      59             :      * Constructor.  Adds the derived object to the setup cache list.
      60             :      */
      61             :     Setup ();
      62             : 
      63             :   public:
      64             :     /**
      65             :      * Destructor.
      66             :      */
      67         924 :     virtual ~Setup() = default;
      68             : 
      69             :     /**
      70             :      * Setup method.  Importantly, this is called *after main()* from the
      71             :      * \p LibMeshInit constructor.
      72             :      */
      73             :     virtual void setup () = 0;
      74             :   };
      75             : 
      76             :   /**
      77             :    * Setup function.  Initializes any derived \p Singleton::Setup objects.
      78             :    * objects.
      79             :    */
      80             :   static void setup();
      81             : 
      82             :   /**
      83             :    * Cleanup function.  Removes all dynamically created \p Singleton
      84             :    * objects.
      85             :    */
      86             :   static void cleanup();
      87             : };
      88             : 
      89             : } // namespace libMesh
      90             : 
      91             : #endif // LIBMESH_LIBMESH_SINGLETON_H

Generated by: LCOV version 1.14