mCRL2
Loading...
Searching...
No Matches
find.h
Go to the documentation of this file.
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//
11
12#ifndef MCRL2_PROCESS_FIND_H
13#define MCRL2_PROCESS_FIND_H
14
15#include "mcrl2/data/find.h"
18
19namespace mcrl2
20{
21
22namespace process
23{
24
25namespace detail
26{
27
29template <template <class> class Traverser, class OutputIterator>
30struct 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 find_action_labels_traverser(OutputIterator out_)
40 : out(out_)
41 {}
42
43 void apply(const process::action_label& x)
44 {
45 *out = x;
46 }
47
48#if BOOST_MSVC
50#endif
51};
52
53template <template <class> class Traverser, class OutputIterator>
54find_action_labels_traverser<Traverser, OutputIterator>
55make_find_action_labels_traverser(OutputIterator out)
56{
57 return find_action_labels_traverser<Traverser, OutputIterator>(out);
58}
59
60struct 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};
120
121} // namespace detail
122
123//--- start generated process find code ---//
128template <typename T, typename OutputIterator>
129void find_all_variables(const T& x, OutputIterator o)
130{
131 data::detail::make_find_all_variables_traverser<process::variable_traverser>(o).apply(x);
132}
133
137template <typename T>
138std::set<data::variable> find_all_variables(const T& x)
139{
140 std::set<data::variable> result;
141 process::find_all_variables(x, std::inserter(result, result.end()));
142 return result;
143}
144
149template <typename T, typename OutputIterator>
150void find_free_variables(const T& x, OutputIterator o)
151{
152 data::detail::make_find_free_variables_traverser<process::data_expression_traverser, process::add_data_variable_traverser_binding>(o).apply(x);
153}
154
160template <typename T, typename OutputIterator, typename VariableContainer>
161void 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
169template <typename T>
170std::set<data::variable> find_free_variables(const T& x)
171{
172 std::set<data::variable> result;
173 process::find_free_variables(x, std::inserter(result, result.end()));
174 return result;
175}
176
181template <typename T, typename VariableContainer>
182std::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
193template <typename T, typename OutputIterator>
194void find_identifiers(const T& x, OutputIterator o)
195{
196 data::detail::make_find_identifiers_traverser<process::identifier_string_traverser>(o).apply(x);
197}
198
202template <typename T>
203std::set<core::identifier_string> find_identifiers(const T& x)
204{
205 std::set<core::identifier_string> result;
206 process::find_identifiers(x, std::inserter(result, result.end()));
207 return result;
208}
209
214template <typename T, typename OutputIterator>
215void find_sort_expressions(const T& x, OutputIterator o)
216{
217 data::detail::make_find_sort_expressions_traverser<process::sort_expression_traverser>(o).apply(x);
218}
219
223template <typename T>
224std::set<data::sort_expression> find_sort_expressions(const T& x)
225{
226 std::set<data::sort_expression> result;
227 process::find_sort_expressions(x, std::inserter(result, result.end()));
228 return result;
229}
230
235template <typename T, typename OutputIterator>
236void 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
244template <typename T>
245std::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
257template <typename T, typename OutputIterator>
258void 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
266template <typename T>
267std::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
277template <typename T>
278std::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
289inline
290const process_equation& find_equation(const std::vector<process_equation>& equations, const process_identifier& id)
291{
292 for (const process_equation& equation: equations)
293 {
294 if (equation.identifier() == id)
295 {
296 return equation;
297 }
298 }
299 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
const_iterator end() const
const_iterator begin() const
\brief A process equation
\brief A process identifier
Standard exception class for reporting runtime errors.
Definition exception.h:27
Search functions of the data library.
data_expression I(const data_expression &x)
void find_identifiers(const T &x, OutputIterator o)
Definition find.h:194
void find_action_labels(const T &x, OutputIterator o)
Returns all action labels that occur in an object.
Definition find.h:258
std::set< data::sort_expression > find_sort_expressions(const process::action_label_list &x)
Definition process.cpp:73
std::set< core::identifier_string > find_action_names(const T &x)
Returns all action names that occur in an object.
Definition find.h:278
void find_function_symbols(const T &x, OutputIterator o)
Definition find.h:236
std::string pp(const action_label &x)
Definition process.cpp:36
void find_free_variables(const T &x, OutputIterator o)
Definition find.h:150
void find_all_variables(const T &x, OutputIterator o)
Definition find.h:129
void find_free_variables_with_bound(const T &x, OutputIterator o, const VariableContainer &bound)
Definition find.h:161
const process_equation & find_equation(const std::vector< process_equation > &equations, const process_identifier &id)
Finds an equation that corresponds to a process identifier.
Definition find.h:290
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
add your file description here.
add your file description here.
add your file description here.