LCOV - code coverage report
Current view: top level - core/include/mcrl2/core/detail - construction_utility.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 3 3 100.0 %
Date: 2024-04-26 03:18:02 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Author(s): Jeroen  van der Wulp
       2             : // Copyright: see the accompanying file COPYING or copy at
       3             : // https://github.com/mCRL2org/mCRL2/blob/master/COPYING
       4             : //
       5             : // Distributed under the Boost Software License, Version 1.0.
       6             : // (See accompanying file LICENSE_1_0.txt or copy at
       7             : // http://www.boost.org/LICENSE_1_0.txt)
       8             : //
       9             : /// \file mcrl2/core/construction_utility.h
      10             : /// \brief construction utility
      11             : 
      12             : #ifndef MCRL2_CORE_DETAIL_CONSTRUCTION_UTILITY_H
      13             : #define MCRL2_CORE_DETAIL_CONSTRUCTION_UTILITY_H
      14             : 
      15             : #include "mcrl2/core/identifier_string.h"
      16             : 
      17             : namespace mcrl2
      18             : {
      19             : namespace core
      20             : {
      21             : namespace detail
      22             : {
      23             : 
      24             : // Component that helps applying the Singleton design pattern
      25             : template < typename Derived, typename Expression = atermpp::aterm_appl >
      26             : class singleton_expression 
      27             : {
      28             :   public:
      29     3546216 :     static const Expression& instance()
      30             :     {
      31     3546216 :       static Expression single_instance = Expression(Derived::initialise());
      32     3546216 :       return single_instance;
      33             :     }
      34             : 
      35             :     singleton_expression(const singleton_expression&) = delete;
      36             :     singleton_expression& operator=(const singleton_expression &) = delete;
      37             :     singleton_expression(singleton_expression &&) = delete;
      38             :     singleton_expression & operator=(singleton_expression &&) = delete;
      39             : 
      40             :   protected:
      41             :     singleton_expression() {}
      42             : };
      43             : 
      44             : template < typename Derived >
      45             : struct singleton_identifier : public singleton_expression< Derived, core::identifier_string >
      46             :   {};
      47             : 
      48             : } // namespace detail
      49             : } // namespace core
      50             : } // namespace mcrl2
      51             : 
      52             : 
      53             : #endif
      54             : 

Generated by: LCOV version 1.14