LCOV - code coverage report
Current view: top level - bes/include/mcrl2/bes - replace.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 9 9 100.0 %
Date: 2020-10-20 00:45:57 Functions: 3 3 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/bes/replace.h
      10             : /// \brief add your file description here.
      11             : 
      12             : #ifndef MCRL2_BES_REPLACE_H
      13             : #define MCRL2_BES_REPLACE_H
      14             : 
      15             : #include "mcrl2/bes/builder.h"
      16             : 
      17             : namespace mcrl2 {
      18             : 
      19             : namespace bes {
      20             : 
      21             : struct boolean_variable_substitution
      22             : {
      23             :   const boolean_variable& v;
      24             :   const boolean_expression& phi;
      25             : 
      26             :   using argument_type = boolean_variable;
      27             : 
      28          20 :   boolean_variable_substitution(const boolean_variable& v_, const boolean_expression& phi_)
      29          20 :     : v(v_), phi(phi_)
      30          20 :   {}
      31             : 
      32          26 :   boolean_expression operator()(const boolean_variable& x) const
      33             :   {
      34          26 :     if (x != v)
      35             :     {
      36          12 :       return x;
      37             :     }
      38          14 :     return phi;
      39             :   }
      40             : };
      41             : 
      42             : /// \brief Applies the substitution \p X := \p phi to the boolean expression \p t.
      43             : /// \param x A boolean variable
      44             : /// \param sigma A substitution
      45             : /// \return The result of the substitution.
      46             : template <typename Substitution>
      47          20 : boolean_expression replace_boolean_variables(const boolean_expression& x, Substitution sigma)
      48             : {
      49          20 :   return core::make_update_apply_builder<boolean_expression_builder>(sigma).apply(x);
      50             : }
      51             : 
      52             : template <typename T, typename Substitution>
      53             : void replace_all_boolean_variables(T& x,
      54             :                                    Substitution sigma,
      55             :                                    typename std::enable_if< !std::is_base_of<atermpp::aterm, T>::value>::type* = 0
      56             :                                   )
      57             : {
      58             :   core::make_update_apply_builder<bes::boolean_variable_builder>(sigma).update(x);
      59             : }
      60             : 
      61             : template <typename T, typename Substitution>
      62             : T replace_all_boolean_variables(const T& x,
      63             :                                 Substitution sigma,
      64             :                                 typename std::enable_if<std::is_base_of<atermpp::aterm, T>::value>::type* = 0
      65             :                                )
      66             : {
      67             :   return core::make_update_apply_builder<bes::boolean_variable_builder>(sigma).apply(x);
      68             : }
      69             : 
      70             : } // namespace bes
      71             : 
      72             : } // namespace mcrl2
      73             : 
      74             : #endif // MCRL2_BES_REPLACE_H

Generated by: LCOV version 1.13