LCOV - code coverage report
Current view: top level - data/include/mcrl2/data/detail - data_functional.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 7 9 77.8 %
Date: 2024-04-17 03:40:49 Functions: 3 4 75.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/data/detail/data_functional.h
      10             : /// \brief Add your file description here.
      11             : 
      12             : #ifndef MCRL2_DATA_DETAIL_DATA_FUNCTIONAL_H
      13             : #define MCRL2_DATA_DETAIL_DATA_FUNCTIONAL_H
      14             : 
      15             : #include "mcrl2/data/basic_sort.h"
      16             : #include "mcrl2/data/function_symbol.h"
      17             : 
      18             : namespace mcrl2
      19             : {
      20             : 
      21             : namespace data
      22             : {
      23             : 
      24             : namespace detail
      25             : {
      26             : 
      27             : template <typename Term>
      28             : struct compare_term
      29             : {
      30             :   const Term& term;
      31             : 
      32             :   compare_term(const Term& t)
      33             :     : term(t)
      34             :   {}
      35             : 
      36             :   /// \brief Function call operator
      37             :   /// \param t A term
      38             :   /// \return The function result
      39             :   template <typename Term2>
      40             :   bool operator()(Term2 t) const
      41             :   {
      42             :     return term == t;
      43             :   }
      44             : };
      45             : 
      46             : /// Tests if a term is a sort, and if it is equal to s
      47             : struct compare_sort
      48             : {
      49             :   sort_expression s;
      50             : 
      51             :   compare_sort(sort_expression s_)
      52             :     : s(s_)
      53             :   {}
      54             : 
      55             :   bool operator()(const atermpp::aterm_appl& t) const
      56             :   {
      57             :     return is_sort_expression(t) && s == t;
      58             :   }
      59             : };
      60             : 
      61             : /// \brief Function object that determines if a term is equal to a given data variable.
      62             : struct compare_variable: public compare_term<variable>
      63             : {
      64             :   compare_variable(const variable& v)
      65             :     : compare_term<variable>(v)
      66             :   {}
      67             : };
      68             : 
      69             : /// \brief Function object that returns the name of a data variable
      70             : struct variable_name
      71             : {
      72             :   /// \brief Function call operator
      73             :   /// \param v A data variable
      74             :   /// \return The function result
      75           0 :   core::identifier_string operator()(const variable& v) const
      76             :   {
      77           0 :     return v.name();
      78             :   }
      79             : };
      80             : 
      81             : /// \brief Function object that returns the sort of a data expression
      82             : template < typename Expression >
      83             : struct sort_of_expression
      84             : {
      85             :   /// \brief Function call operator
      86             :   /// \param v A data variable
      87             :   /// \return The function result
      88        8889 :   sort_expression operator()(const Expression& e) const
      89             :   {
      90        8889 :     return e.sort();
      91             :   }
      92             : };
      93             : 
      94             : /// \brief Function object that returns the sort of a data variable
      95             : typedef sort_of_expression<variable> sort_of_variable;
      96             : 
      97             : struct sort_has_name
      98             : {
      99             :   std::string m_name;
     100             : 
     101             :   sort_has_name(std::string const& name)
     102             :     : m_name(name)
     103             :   {}
     104             : 
     105             :   /// \brief Function call operator
     106             :   /// \param s A sort expression
     107             :   /// \return The function result
     108             :   bool operator()(const sort_expression& s) const
     109             :   {
     110             :     return is_basic_sort(s) && std::string(basic_sort(s).name()) == m_name;
     111             :   }
     112             : };
     113             : 
     114             : struct function_symbol_has_name
     115             : {
     116             :   std::string m_name;
     117             : 
     118          10 :   function_symbol_has_name(std::string const& name)
     119          10 :     : m_name(name)
     120          10 :   {}
     121             : 
     122             :   /// \brief Function call operator
     123             :   /// \param c A data operation
     124             :   /// \return The function result
     125         875 :   bool operator()(const function_symbol& c) const
     126             :   {
     127         875 :     return std::string(c.name()) == m_name;
     128             :   }
     129             : };
     130             : 
     131             : } // namespace detail
     132             : 
     133             : } // namespace data
     134             : 
     135             : } // namespace mcrl2
     136             : 
     137             : #endif // MCRL2_DATA_DETAIL_DATA_FUNCTIONAL_H

Generated by: LCOV version 1.14