LCOV - code coverage report
Current view: top level - pbes/include/mcrl2/pbes/detail - bes_equation_limit.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 3 4 75.0 %
Date: 2024-04-19 03:43:27 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Author(s): Wieger Wesselink
       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/pbes/detail/bes_equation_limit.h
      10             : /// \brief A global variable for counting the number of BES equations in pbesinst
      11             : /// and parity_game_generator. If the number of equations exceeds a limit, an
      12             : /// exception is thrown. A static template class variable is used, that can be
      13             : /// set from everywhere.
      14             : 
      15             : #ifndef MCRL2_PBES_DETAIL_BES_EQUATION_LIMIT_H
      16             : #define MCRL2_PBES_DETAIL_BES_EQUATION_LIMIT_H
      17             : 
      18             : #include <limits>
      19             : #include <stdexcept>
      20             : 
      21             : namespace mcrl2
      22             : {
      23             : 
      24             : namespace pbes_system
      25             : {
      26             : 
      27             : namespace detail
      28             : {
      29             : 
      30             : template <class T> // note, T is only a dummy
      31             : struct bes_equation_limit
      32             : {
      33             :   static std::size_t max_bes_equations;
      34             : };
      35             : 
      36             : template <class T>
      37             : std::size_t bes_equation_limit<T>::max_bes_equations = (std::numeric_limits<std::size_t>::max)();
      38             : 
      39             : inline
      40             : void set_bes_equation_limit(std::size_t size)
      41             : {
      42             :   bes_equation_limit<std::size_t>::max_bes_equations = size;
      43             : }
      44             : 
      45             : inline
      46        3883 : void check_bes_equation_limit(std::size_t size)
      47             : {
      48        3883 :   if (size >= bes_equation_limit<std::size_t>::max_bes_equations)
      49             :   {
      50           0 :     throw std::out_of_range("Error: number of BES equations has exceeded the limit");
      51             :   }
      52        3883 : }
      53             : 
      54             : } // namespace detail
      55             : 
      56             : } // namespace pbes_system
      57             : 
      58             : } // namespace mcrl2
      59             : 
      60             : #endif // MCRL2_PBES_DETAIL_BES_EQUATION_LIMIT_H

Generated by: LCOV version 1.14