mCRL2
Loading...
Searching...
No Matches
traverser.h
Go to the documentation of this file.
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//
11
12#ifndef MCRL2_CORE_TRAVERSER_H
13#define MCRL2_CORE_TRAVERSER_H
14
16
17namespace mcrl2
18{
19
20namespace core
21{
22
30template <typename Derived>
32{
33 template <typename Expression>
34 void enter(Expression const&)
35 {}
36
37 template <typename Expression>
38 void leave(Expression const&)
39 {}
40
41 template <typename T>
42 void apply(const T& x, typename atermpp::disable_if_container<T>::type* = nullptr)
43 {
44 static_cast<Derived&>(*this).enter(x);
45 static_cast<Derived&>(*this).leave(x);
46 }
47
48 // traverse containers
49 template <typename Container>
50 void apply(Container const& container, typename atermpp::enable_if_container<Container>::type* = nullptr)
51 {
52 for (typename Container::const_iterator i = container.begin(); i != container.end(); ++i)
53 {
54 static_cast<Derived*>(this)->apply(*i);
55 }
56 }
57
58 // TODO: This dependency on identifier_string should be moved elsewhere...
60 {
61 static_cast<Derived&>(*this).enter(x);
62 static_cast<Derived&>(*this).leave(x);
63 }
64};
65
66// apply a builder without additional template arguments
67template <template <class> class Traverser>
68struct apply_traverser: public Traverser<apply_traverser<Traverser> >
69{
70 typedef Traverser<apply_traverser<Traverser> > super;
71
72 using super::enter;
73 using super::leave;
74 using super::apply;
75};
76
77template <template <class> class Traverser>
80{
82}
83
84} // namespace core
85
86} // namespace mcrl2
87
88#endif // MCRL2_CORE_TRAVERSER_H
Term containing a string.
aterm representations of identifier strings.
apply_traverser< Traverser > make_apply_traverser()
Definition traverser.h:79
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
Traverser< apply_traverser< Traverser > > super
Definition traverser.h:70
expression traverser that visits all sub expressions
Definition traverser.h:32
void apply(const core::identifier_string &x)
Definition traverser.h:59
void apply(Container const &container, typename atermpp::enable_if_container< Container >::type *=nullptr)
Definition traverser.h:50
void enter(Expression const &)
Definition traverser.h:34
void apply(const T &x, typename atermpp::disable_if_container< T >::type *=nullptr)
Definition traverser.h:42
void leave(Expression const &)
Definition traverser.h:38