LCOV - code coverage report
Current view: top level - process/include/mcrl2/process - find.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 32 45 71.1 %
Date: 2024-04-19 03:43:27 Functions: 26 37 70.3 %
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/process/find.h
      10             : /// \brief add your file description here.
      11             : 
      12             : #ifndef MCRL2_PROCESS_FIND_H
      13             : #define MCRL2_PROCESS_FIND_H
      14             : 
      15             : #include "mcrl2/data/find.h"
      16             : #include "mcrl2/process/add_binding.h"
      17             : #include "mcrl2/process/traverser.h"
      18             : 
      19             : namespace mcrl2
      20             : {
      21             : 
      22             : namespace process
      23             : {
      24             : 
      25             : namespace detail
      26             : {
      27             : 
      28             : /// \cond INTERNAL_DOCS
      29             : template <template <class> class Traverser, class OutputIterator>
      30             : struct find_action_labels_traverser: public Traverser<find_action_labels_traverser<Traverser, OutputIterator> >
      31             : {
      32             :   typedef Traverser<find_action_labels_traverser<Traverser, OutputIterator> > super;
      33             :   using super::enter;
      34             :   using super::leave;
      35             :   using super::apply;
      36             : 
      37             :   OutputIterator out;
      38             : 
      39           0 :   find_action_labels_traverser(OutputIterator out_)
      40           0 :     : out(out_)
      41           0 :   {}
      42             : 
      43           0 :   void apply(const process::action_label& x)
      44             :   {
      45           0 :     *out = x;
      46           0 :   }
      47             : 
      48             : #if BOOST_MSVC
      49             : #include "mcrl2/core/detail/traverser_msvc.inc.h"
      50             : #endif
      51             : };
      52             : 
      53             : template <template <class> class Traverser, class OutputIterator>
      54             : find_action_labels_traverser<Traverser, OutputIterator>
      55           0 : make_find_action_labels_traverser(OutputIterator out)
      56             : {
      57           0 :   return find_action_labels_traverser<Traverser, OutputIterator>(out);
      58             : }
      59             : 
      60             : struct find_action_names_traverser: public process::action_label_traverser<find_action_names_traverser>
      61             : {
      62             :   typedef process::action_label_traverser<find_action_names_traverser> super;
      63             :   using super::enter;
      64             :   using super::leave;
      65             :   using super::apply;
      66             : 
      67             :   std::set<core::identifier_string> result;
      68             : 
      69             :   void apply(const process::action_label& x)
      70             :   {
      71             :     result.insert(x.name());
      72             :   }
      73             : 
      74             :   void apply(const process::block& x)
      75             :   {
      76             :     super::apply(x);
      77             :     const core::identifier_string_list& B = x.block_set();
      78             :     result.insert(B.begin(), B.end());
      79             :   }
      80             : 
      81             :   void apply(const process::hide& x)
      82             :   {
      83             :     super::apply(x);
      84             :     const core::identifier_string_list& I = x.hide_set();
      85             :     result.insert(I.begin(), I.end());
      86             :   }
      87             : 
      88             :   void apply(const process::rename& x)
      89             :   {
      90             :     super::apply(x);
      91             :     for (const rename_expression& r: x.rename_set())
      92             :     {
      93             :       result.insert(r.source());
      94             :       result.insert(r.target());
      95             :     }
      96             :   }
      97             : 
      98             :   void apply(const process::comm& x)
      99             :   {
     100             :     super::apply(x);
     101             :     for (const communication_expression& c: x.comm_set())
     102             :     {
     103             :       core::identifier_string_list names = c.action_name().names();
     104             :       result.insert(names.begin(), names.end());
     105             :       result.insert(c.name());
     106             :     }
     107             :   }
     108             : 
     109             :   void apply(const process::allow& x)
     110             :   {
     111             :     super::apply(x);
     112             :     for (const action_name_multiset& i: x.allow_set())
     113             :     {
     114             :       const core::identifier_string_list& names = i.names();
     115             :       result.insert(names.begin(), names.end());
     116             :     }
     117             :   }
     118             : };
     119             : /// \endcond
     120             : 
     121             : } // namespace detail
     122             : 
     123             : //--- start generated process find code ---//
     124             : /// \\brief Returns all variables that occur in an object
     125             : /// \\param[in] x an object containing variables
     126             : /// \\param[in,out] o an output iterator to which all variables occurring in x are written.
     127             : /// \\return All variables that occur in the term x
     128             : template <typename T, typename OutputIterator>
     129          23 : void find_all_variables(const T& x, OutputIterator o)
     130             : {
     131          23 :   data::detail::make_find_all_variables_traverser<process::variable_traverser>(o).apply(x);
     132          23 : }
     133             : 
     134             : /// \\brief Returns all variables that occur in an object
     135             : /// \\param[in] x an object containing variables
     136             : /// \\return All variables that occur in the object x
     137             : template <typename T>
     138          23 : std::set<data::variable> find_all_variables(const T& x)
     139             : {
     140          23 :   std::set<data::variable> result;
     141          23 :   process::find_all_variables(x, std::inserter(result, result.end()));
     142          23 :   return result;
     143           0 : }
     144             : 
     145             : /// \\brief Returns all variables that occur in an object
     146             : /// \\param[in] x an object containing variables
     147             : /// \\param[in,out] o an output iterator to which all variables occurring in x are added.
     148             : /// \\return All free variables that occur in the object x
     149             : template <typename T, typename OutputIterator>
     150        1788 : void find_free_variables(const T& x, OutputIterator o)
     151             : {
     152        1788 :   data::detail::make_find_free_variables_traverser<process::data_expression_traverser, process::add_data_variable_traverser_binding>(o).apply(x);
     153        1788 : }
     154             : 
     155             : /// \\brief Returns all variables that occur in an object
     156             : /// \\param[in] x an object containing variables
     157             : /// \\param[in,out] o an output iterator to which all variables occurring in x are written.
     158             : /// \\param[in] bound a container of variables
     159             : /// \\return All free variables that occur in the object x
     160             : template <typename T, typename OutputIterator, typename VariableContainer>
     161             : void find_free_variables_with_bound(const T& x, OutputIterator o, const VariableContainer& bound)
     162             : {
     163             :   data::detail::make_find_free_variables_traverser<process::data_expression_traverser, process::add_data_variable_traverser_binding>(o, bound).apply(x);
     164             : }
     165             : 
     166             : /// \\brief Returns all variables that occur in an object
     167             : /// \\param[in] x an object containing variables
     168             : /// \\return All free variables that occur in the object x
     169             : template <typename T>
     170        1788 : std::set<data::variable> find_free_variables(const T& x)
     171             : {
     172        1788 :   std::set<data::variable> result;
     173        1788 :   process::find_free_variables(x, std::inserter(result, result.end()));
     174        1788 :   return result;
     175           0 : }
     176             : 
     177             : /// \\brief Returns all variables that occur in an object
     178             : /// \\param[in] x an object containing variables
     179             : /// \\param[in] bound a bound a container of variables
     180             : /// \\return All free variables that occur in the object x
     181             : template <typename T, typename VariableContainer>
     182             : std::set<data::variable> find_free_variables_with_bound(const T& x, VariableContainer const& bound)
     183             : {
     184             :   std::set<data::variable> result;
     185             :   process::find_free_variables_with_bound(x, std::inserter(result, result.end()), bound);
     186             :   return result;
     187             : }
     188             : 
     189             : /// \\brief Returns all identifiers that occur in an object
     190             : /// \\param[in] x an object containing identifiers
     191             : /// \\param[in,out] o an output iterator to which all identifiers occurring in x are written.
     192             : /// \\return All identifiers that occur in the term x
     193             : template <typename T, typename OutputIterator>
     194         882 : void find_identifiers(const T& x, OutputIterator o)
     195             : {
     196         882 :   data::detail::make_find_identifiers_traverser<process::identifier_string_traverser>(o).apply(x);
     197         882 : }
     198             : 
     199             : /// \\brief Returns all identifiers that occur in an object
     200             : /// \\param[in] x an object containing identifiers
     201             : /// \\return All identifiers that occur in the object x
     202             : template <typename T>
     203         882 : std::set<core::identifier_string> find_identifiers(const T& x)
     204             : {
     205         882 :   std::set<core::identifier_string> result;
     206         882 :   process::find_identifiers(x, std::inserter(result, result.end()));
     207         882 :   return result;
     208           0 : }
     209             : 
     210             : /// \\brief Returns all sort expressions that occur in an object
     211             : /// \\param[in] x an object containing sort expressions
     212             : /// \\param[in,out] o an output iterator to which all sort expressions occurring in x are written.
     213             : /// \\return All sort expressions that occur in the term x
     214             : template <typename T, typename OutputIterator>
     215        2639 : void find_sort_expressions(const T& x, OutputIterator o)
     216             : {
     217        2639 :   data::detail::make_find_sort_expressions_traverser<process::sort_expression_traverser>(o).apply(x);
     218        2639 : }
     219             : 
     220             : /// \\brief Returns all sort expressions that occur in an object
     221             : /// \\param[in] x an object containing sort expressions
     222             : /// \\return All sort expressions that occur in the object x
     223             : template <typename T>
     224           1 : std::set<data::sort_expression> find_sort_expressions(const T& x)
     225             : {
     226           1 :   std::set<data::sort_expression> result;
     227           1 :   process::find_sort_expressions(x, std::inserter(result, result.end()));
     228           1 :   return result;
     229           0 : }
     230             : 
     231             : /// \\brief Returns all function symbols that occur in an object
     232             : /// \\param[in] x an object containing function symbols
     233             : /// \\param[in,out] o an output iterator to which all function symbols occurring in x are written.
     234             : /// \\return All function symbols that occur in the term x
     235             : template <typename T, typename OutputIterator>
     236             : void find_function_symbols(const T& x, OutputIterator o)
     237             : {
     238             :   data::detail::make_find_function_symbols_traverser<process::data_expression_traverser>(o).apply(x);
     239             : }
     240             : 
     241             : /// \\brief Returns all function symbols that occur in an object
     242             : /// \\param[in] x an object containing function symbols
     243             : /// \\return All function symbols that occur in the object x
     244             : template <typename T>
     245             : std::set<data::function_symbol> find_function_symbols(const T& x)
     246             : {
     247             :   std::set<data::function_symbol> result;
     248             :   process::find_function_symbols(x, std::inserter(result, result.end()));
     249             :   return result;
     250             : }
     251             : //--- end generated process find code ---//
     252             : 
     253             : /// \brief Returns all action labels that occur in an object
     254             : /// \param[in] x an object containing action labels
     255             : /// \param[in,out] o an output iterator to which all action labels occurring in x are written.
     256             : /// \return All action labels that occur in the term x
     257             : template <typename T, typename OutputIterator>
     258             : void find_action_labels(const T& x, OutputIterator o)
     259             : {
     260             :   process::detail::make_find_action_labels_traverser<process::action_label_traverser>(o)(x);
     261             : }
     262             : 
     263             : /// \brief Returns all action labels that occur in an object
     264             : /// \param[in] x an object containing action labels
     265             : /// \return All action labels that occur in the object x
     266             : template <typename T>
     267             : std::set<process::action_label> find_action_labels(const T& x)
     268             : {
     269             :   std::set<process::action_label> result;
     270             :   process::find_action_labels(x, std::inserter(result, result.end()));
     271             :   return result;
     272             : }
     273             : 
     274             : /// \brief Returns all action names that occur in an object
     275             : /// \param[in] x an object containing action names
     276             : /// \return All action names that occur in the object x
     277             : template <typename T>
     278             : std::set<core::identifier_string> find_action_names(const T& x)
     279             : {
     280             :   detail::find_action_names_traverser f;
     281             :   f.apply(x);
     282             :   return f.result;
     283             : }
     284             : 
     285             : /// \brief Finds an equation that corresponds to a process identifier
     286             : /// \param[in] equations a sequence of process equations
     287             : /// \param[in] id The identifier of the equation that is searched for.
     288             : /// \return The equation with the given process identifier. Throws an exception if no such equation was found.
     289             : inline
     290          15 : const process_equation& find_equation(const std::vector<process_equation>& equations, const process_identifier& id)
     291             : {
     292          23 :   for (const process_equation& equation: equations)
     293             :   {
     294          23 :     if (equation.identifier() == id)
     295             :     {
     296          15 :       return equation;
     297             :     }
     298             :   }
     299           0 :   throw mcrl2::runtime_error("unknown process identifier " + process::pp(id));
     300             : }
     301             : 
     302             : } // namespace process
     303             : 
     304             : } // namespace mcrl2
     305             : 
     306             : #endif // MCRL2_PROCESS_FIND_H

Generated by: LCOV version 1.14