LCOV - code coverage report
Current view: top level - bes/include/mcrl2/bes - find.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 18 18 100.0 %
Date: 2020-10-20 00:45:57 Functions: 13 13 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Author(s): Jeroen van der Wulp, 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/find.h
      10             : /// \brief add your file description here.
      11             : 
      12             : #ifndef MCRL2_BES_FIND_H
      13             : #define MCRL2_BES_FIND_H
      14             : 
      15             : #include "mcrl2/bes/traverser.h"
      16             : 
      17             : namespace mcrl2
      18             : {
      19             : 
      20             : namespace bes
      21             : {
      22             : 
      23             : namespace detail
      24             : {
      25             : 
      26             : template <template <class> class Traverser, class OutputIterator>
      27             : struct find_boolean_variables_traverser: public Traverser<find_boolean_variables_traverser<Traverser, OutputIterator> >
      28             : {
      29             :   typedef Traverser<find_boolean_variables_traverser<Traverser, OutputIterator> > super;
      30             :   using super::enter;
      31             :   using super::leave;
      32             :   using super::apply;
      33             : 
      34             :   OutputIterator out;
      35             : 
      36          37 :   find_boolean_variables_traverser(OutputIterator out_)
      37          37 :     : out(out_)
      38          37 :   {}
      39             : 
      40          82 :   void apply(const boolean_variable& v)
      41             :   {
      42          82 :     *out = v;
      43          82 :   }
      44             : };
      45             : 
      46             : template <template <class> class Traverser, class OutputIterator>
      47             : find_boolean_variables_traverser<Traverser, OutputIterator>
      48          37 : make_find_boolean_variables_traverser(OutputIterator out)
      49             : {
      50          37 :   return find_boolean_variables_traverser<Traverser, OutputIterator>(out);
      51             : }
      52             : 
      53             : } // namespace detail
      54             : 
      55             : /// \brief Returns all boolean variables that occur in a range of expressions
      56             : /// \param[in] container a container with expressions
      57             : /// \param[in,out] o an output iterator to which all variables occurring in t
      58             : ///             are added.
      59             : /// \return All variables that occur in the term t
      60             : template <typename Container, typename OutputIterator>
      61          34 : void find_boolean_variables(Container const& container, OutputIterator o)
      62             : {
      63          34 :   bes::detail::make_find_boolean_variables_traverser<bes::boolean_expression_traverser>(o).apply(container);
      64          34 : }
      65             : 
      66             : /// \brief Returns all variables that occur in a range of expressions
      67             : /// \param[in] container a container with expressions
      68             : /// \return All variables that occur in the term t
      69             : template <typename Container>
      70          19 : std::set<boolean_variable> find_boolean_variables(Container const& container)
      71             : {
      72          19 :   std::set<boolean_variable> result;
      73          19 :   bes::find_boolean_variables(container, std::inserter(result, result.end()));
      74          19 :   return result;
      75             : }
      76             : 
      77             : /// \brief Returns true if the term has a given boolean variable as subterm.
      78             : /// \param[in] container an expression or container with expressions
      79             : /// \param[in] v a boolean variable
      80             : /// \return True if the term has a given boolean variable as subterm.
      81             : template <typename Container>
      82           9 : bool search_boolean_variable(Container const& container, const boolean_variable& v)
      83             : {
      84             :         using utilities::detail::contains;
      85          18 :   std::set<boolean_variable> boolean_variables = bes::find_boolean_variables(container);
      86          18 :   return contains(boolean_variables, v);
      87             : }
      88             : 
      89             : } // namespace bes
      90             : 
      91             : } // namespace mcrl2
      92             : 
      93             : #endif // MCRL2_BES_FIND_H

Generated by: LCOV version 1.13