LCOV - code coverage report
Current view: top level - data/include/mcrl2/data/detail/rewrite - strategy_rule.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 27 27 100.0 %
Date: 2020-02-28 00:44:21 Functions: 15 15 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Author(s): Jan Friso Groote
       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 strategy_rule.h
      10             : 
      11             : #ifndef MCRL2_DATA_DETAIL_REWRITE_STRATEGY_RULE_H
      12             : #define MCRL2_DATA_DETAIL_REWRITE_STRATEGY_RULE_H
      13             : 
      14             : #include "mcrl2/data/data_equation.h"
      15             : 
      16             : namespace mcrl2
      17             : {
      18             : namespace data
      19             : {
      20             : namespace detail
      21             : {
      22             : 
      23             : /// \brief Is either a rewrite rule to be matched or an index that should be rewritten.
      24     4279535 : class strategy_rule : public atermpp::aterm
      25             : {
      26             :   public:
      27      316963 :     strategy_rule(const std::size_t n)
      28      316963 :       : aterm(atermpp::aterm_int(n))
      29      316963 :     {}
      30             : 
      31      529088 :     strategy_rule(const data_equation& eq)
      32      529088 :       : aterm(eq)
      33      529088 :     {}
      34             : 
      35     4974829 :     bool is_rewrite_index() const
      36             :     {
      37     4974829 :       return type_is_int();
      38             :     }
      39             : 
      40     2124477 :     bool is_equation() const
      41             :     {
      42     2124477 :       return !type_is_int();
      43             :     }
      44             : 
      45     2124477 :     const data_equation& equation() const
      46             :     {
      47     2124477 :       assert(is_equation());
      48     2124477 :       return atermpp::down_cast<data_equation>(*this);
      49             :     }
      50             : 
      51     1425095 :     std::size_t rewrite_index() const
      52             :     {
      53     1425095 :       assert(is_rewrite_index());
      54     1425095 :       return (atermpp::down_cast<atermpp::aterm_int>(static_cast<atermpp::aterm>(*this))).value();
      55             :     }
      56             : };
      57             : 
      58             : /// A strategy is a list of rules and the number of variables that occur in it.
      59     3158681 : class strategy
      60             : {
      61             : public:
      62      224004 :   strategy(size_t n, const atermpp::term_list<strategy_rule>& r)
      63      224004 :    : m_number_of_variables(n),
      64      224004 :      m_rules(r)
      65      224004 :   {}
      66             :  
      67      705565 :   strategy()
      68      705565 :    : m_number_of_variables(0)
      69      705565 :   {}
      70             : 
      71      907215 :   std::size_t number_of_variables() const { return m_number_of_variables; }
      72     3335927 :   const atermpp::term_list<strategy_rule>& rules() const { return m_rules; }
      73             : 
      74             : private:
      75             :   std::size_t m_number_of_variables;
      76             :   atermpp::term_list<strategy_rule> m_rules;
      77             : };
      78             : 
      79             : /// \brief Creates a strategy for given set of rewrite rules with head symbol f.
      80             : strategy create_strategy(data_equation_list rules);
      81             : 
      82             : } // namespace detail
      83             : } // namespace data
      84             : } // namespace mcrl2
      85             : 
      86             : #endif // MCRL2_DATA_DETAIL_REWRITE_STRATEGY_RULE_H
      87             : 

Generated by: LCOV version 1.13