LCOV - code coverage report
Current view: top level - bes/include/mcrl2/bes - builder.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 39 51 76.5 %
Date: 2020-10-20 00:45:57 Functions: 8 11 72.7 %
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/builder.h
      10             : /// \brief add your file description here.
      11             : 
      12             : #ifndef MCRL2_BES_BUILDER_H
      13             : #define MCRL2_BES_BUILDER_H
      14             : 
      15             : #include "mcrl2/bes/boolean_equation_system.h"
      16             : #include "mcrl2/core/builder.h"
      17             : 
      18             : namespace mcrl2
      19             : {
      20             : 
      21             : namespace bes
      22             : {
      23             : 
      24             : //--- start generated add_boolean_expressions code ---//
      25             : template <template <class> class Builder, class Derived>
      26             : struct add_boolean_expressions: public Builder<Derived>
      27             : {
      28             :   typedef Builder<Derived> super;
      29             :   using super::enter;
      30             :   using super::leave;
      31             :   using super::update;
      32             :   using super::apply;
      33             : 
      34             :   void update(bes::boolean_equation& x)
      35             :   {
      36             :     static_cast<Derived&>(*this).enter(x);
      37             :     x.formula() = static_cast<Derived&>(*this).apply(x.formula());
      38             :     static_cast<Derived&>(*this).leave(x);
      39             :   }
      40             : 
      41             :   void update(bes::boolean_equation_system& x)
      42             :   {
      43             :     static_cast<Derived&>(*this).enter(x);
      44             :     static_cast<Derived&>(*this).update(x.equations());
      45             :     x.initial_state() = static_cast<Derived&>(*this).apply(x.initial_state());
      46             :     static_cast<Derived&>(*this).leave(x);
      47             :   }
      48             : 
      49           6 :   bes::true_ apply(const bes::true_& x)
      50             :   {
      51           6 :     static_cast<Derived&>(*this).enter(x);
      52             :     // skip
      53           6 :     static_cast<Derived&>(*this).leave(x);
      54           6 :     return x;
      55             :   }
      56             : 
      57           4 :   bes::false_ apply(const bes::false_& x)
      58             :   {
      59           4 :     static_cast<Derived&>(*this).enter(x);
      60             :     // skip
      61           4 :     static_cast<Derived&>(*this).leave(x);
      62           4 :     return x;
      63             :   }
      64             : 
      65           0 :   bes::not_ apply(const bes::not_& x)
      66             :   {
      67           0 :     static_cast<Derived&>(*this).enter(x);
      68           0 :     bes::not_ result = bes::not_(static_cast<Derived&>(*this).apply(x.operand()));
      69           0 :     static_cast<Derived&>(*this).leave(x);
      70           0 :     return result;
      71             :   }
      72             : 
      73           3 :   bes::and_ apply(const bes::and_& x)
      74             :   {
      75           3 :     static_cast<Derived&>(*this).enter(x);
      76           3 :     bes::and_ result = bes::and_(static_cast<Derived&>(*this).apply(x.left()), static_cast<Derived&>(*this).apply(x.right()));
      77           3 :     static_cast<Derived&>(*this).leave(x);
      78           3 :     return result;
      79             :   }
      80             : 
      81           4 :   bes::or_ apply(const bes::or_& x)
      82             :   {
      83           4 :     static_cast<Derived&>(*this).enter(x);
      84           4 :     bes::or_ result = bes::or_(static_cast<Derived&>(*this).apply(x.left()), static_cast<Derived&>(*this).apply(x.right()));
      85           4 :     static_cast<Derived&>(*this).leave(x);
      86           4 :     return result;
      87             :   }
      88             : 
      89           0 :   bes::imp apply(const bes::imp& x)
      90             :   {
      91           0 :     static_cast<Derived&>(*this).enter(x);
      92           0 :     bes::imp result = bes::imp(static_cast<Derived&>(*this).apply(x.left()), static_cast<Derived&>(*this).apply(x.right()));
      93           0 :     static_cast<Derived&>(*this).leave(x);
      94           0 :     return result;
      95             :   }
      96             : 
      97           8 :   bes::boolean_variable apply(const bes::boolean_variable& x)
      98             :   {
      99           8 :     static_cast<Derived&>(*this).enter(x);
     100             :     // skip
     101           8 :     static_cast<Derived&>(*this).leave(x);
     102           8 :     return x;
     103             :   }
     104             : 
     105          55 :   bes::boolean_expression apply(const bes::boolean_expression& x)
     106             :   {
     107          55 :     static_cast<Derived&>(*this).enter(x);
     108          55 :     bes::boolean_expression result;
     109          55 :     if (bes::is_true(x))
     110             :     {
     111           6 :       result = static_cast<Derived&>(*this).apply(atermpp::down_cast<bes::true_>(x));
     112             :     }
     113          49 :     else if (bes::is_false(x))
     114             :     {
     115           4 :       result = static_cast<Derived&>(*this).apply(atermpp::down_cast<bes::false_>(x));
     116             :     }
     117          45 :     else if (bes::is_not(x))
     118             :     {
     119           0 :       result = static_cast<Derived&>(*this).apply(atermpp::down_cast<bes::not_>(x));
     120             :     }
     121          45 :     else if (bes::is_and(x))
     122             :     {
     123           4 :       result = static_cast<Derived&>(*this).apply(atermpp::down_cast<bes::and_>(x));
     124             :     }
     125          41 :     else if (bes::is_or(x))
     126             :     {
     127           7 :       result = static_cast<Derived&>(*this).apply(atermpp::down_cast<bes::or_>(x));
     128             :     }
     129          34 :     else if (bes::is_imp(x))
     130             :     {
     131           0 :       result = static_cast<Derived&>(*this).apply(atermpp::down_cast<bes::imp>(x));
     132             :     }
     133          34 :     else if (bes::is_boolean_variable(x))
     134             :     {
     135          34 :       result = static_cast<Derived&>(*this).apply(atermpp::down_cast<bes::boolean_variable>(x));
     136             :     }
     137          55 :     static_cast<Derived&>(*this).leave(x);
     138          55 :     return result;
     139             :   }
     140             : 
     141             : };
     142             : 
     143             : /// \brief Builder class
     144             : template <typename Derived>
     145             : struct boolean_expression_builder: public add_boolean_expressions<core::builder, Derived>
     146             : {
     147             : };
     148             : //--- end generated add_boolean_expressions code ---//
     149             : 
     150             : //--- start generated add_boolean_variables code ---//
     151             : template <template <class> class Builder, class Derived>
     152             : struct add_boolean_variables: public Builder<Derived>
     153             : {
     154             :   typedef Builder<Derived> super;
     155             :   using super::enter;
     156             :   using super::leave;
     157             :   using super::update;
     158             :   using super::apply;
     159             : 
     160             :   void update(bes::boolean_equation& x)
     161             :   {
     162             :     static_cast<Derived&>(*this).enter(x);
     163             :     x.variable() = static_cast<Derived&>(*this).apply(x.variable());
     164             :     x.formula() = static_cast<Derived&>(*this).apply(x.formula());
     165             :     static_cast<Derived&>(*this).leave(x);
     166             :   }
     167             : 
     168             :   void update(bes::boolean_equation_system& x)
     169             :   {
     170             :     static_cast<Derived&>(*this).enter(x);
     171             :     static_cast<Derived&>(*this).update(x.equations());
     172             :     x.initial_state() = static_cast<Derived&>(*this).apply(x.initial_state());
     173             :     static_cast<Derived&>(*this).leave(x);
     174             :   }
     175             : 
     176             :   bes::true_ apply(const bes::true_& x)
     177             :   {
     178             :     static_cast<Derived&>(*this).enter(x);
     179             :     // skip
     180             :     static_cast<Derived&>(*this).leave(x);
     181             :     return x;
     182             :   }
     183             : 
     184             :   bes::false_ apply(const bes::false_& x)
     185             :   {
     186             :     static_cast<Derived&>(*this).enter(x);
     187             :     // skip
     188             :     static_cast<Derived&>(*this).leave(x);
     189             :     return x;
     190             :   }
     191             : 
     192             :   bes::not_ apply(const bes::not_& x)
     193             :   {
     194             :     static_cast<Derived&>(*this).enter(x);
     195             :     bes::not_ result = bes::not_(static_cast<Derived&>(*this).apply(x.operand()));
     196             :     static_cast<Derived&>(*this).leave(x);
     197             :     return result;
     198             :   }
     199             : 
     200             :   bes::and_ apply(const bes::and_& x)
     201             :   {
     202             :     static_cast<Derived&>(*this).enter(x);
     203             :     bes::and_ result = bes::and_(static_cast<Derived&>(*this).apply(x.left()), static_cast<Derived&>(*this).apply(x.right()));
     204             :     static_cast<Derived&>(*this).leave(x);
     205             :     return result;
     206             :   }
     207             : 
     208             :   bes::or_ apply(const bes::or_& x)
     209             :   {
     210             :     static_cast<Derived&>(*this).enter(x);
     211             :     bes::or_ result = bes::or_(static_cast<Derived&>(*this).apply(x.left()), static_cast<Derived&>(*this).apply(x.right()));
     212             :     static_cast<Derived&>(*this).leave(x);
     213             :     return result;
     214             :   }
     215             : 
     216             :   bes::imp apply(const bes::imp& x)
     217             :   {
     218             :     static_cast<Derived&>(*this).enter(x);
     219             :     bes::imp result = bes::imp(static_cast<Derived&>(*this).apply(x.left()), static_cast<Derived&>(*this).apply(x.right()));
     220             :     static_cast<Derived&>(*this).leave(x);
     221             :     return result;
     222             :   }
     223             : 
     224             :   bes::boolean_variable apply(const bes::boolean_variable& x)
     225             :   {
     226             :     static_cast<Derived&>(*this).enter(x);
     227             :     // skip
     228             :     static_cast<Derived&>(*this).leave(x);
     229             :     return x;
     230             :   }
     231             : 
     232             :   bes::boolean_expression apply(const bes::boolean_expression& x)
     233             :   {
     234             :     static_cast<Derived&>(*this).enter(x);
     235             :     bes::boolean_expression result;
     236             :     if (bes::is_true(x))
     237             :     {
     238             :       result = static_cast<Derived&>(*this).apply(atermpp::down_cast<bes::true_>(x));
     239             :     }
     240             :     else if (bes::is_false(x))
     241             :     {
     242             :       result = static_cast<Derived&>(*this).apply(atermpp::down_cast<bes::false_>(x));
     243             :     }
     244             :     else if (bes::is_not(x))
     245             :     {
     246             :       result = static_cast<Derived&>(*this).apply(atermpp::down_cast<bes::not_>(x));
     247             :     }
     248             :     else if (bes::is_and(x))
     249             :     {
     250             :       result = static_cast<Derived&>(*this).apply(atermpp::down_cast<bes::and_>(x));
     251             :     }
     252             :     else if (bes::is_or(x))
     253             :     {
     254             :       result = static_cast<Derived&>(*this).apply(atermpp::down_cast<bes::or_>(x));
     255             :     }
     256             :     else if (bes::is_imp(x))
     257             :     {
     258             :       result = static_cast<Derived&>(*this).apply(atermpp::down_cast<bes::imp>(x));
     259             :     }
     260             :     else if (bes::is_boolean_variable(x))
     261             :     {
     262             :       result = static_cast<Derived&>(*this).apply(atermpp::down_cast<bes::boolean_variable>(x));
     263             :     }
     264             :     static_cast<Derived&>(*this).leave(x);
     265             :     return result;
     266             :   }
     267             : 
     268             : };
     269             : 
     270             : /// \brief Builder class
     271             : template <typename Derived>
     272             : struct boolean_variable_builder: public add_boolean_variables<core::builder, Derived>
     273             : {
     274             : };
     275             : //--- end generated add_boolean_variables code ---//
     276             : 
     277             : } // namespace bes
     278             : 
     279             : } // namespace mcrl2
     280             : 
     281             : #endif // MCRL2_BES_BUILDER_H

Generated by: LCOV version 1.13