mCRL2
Loading...
Searching...
No Matches
add_binding.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_CORE_ADD_BINDING_H
13#define MCRL2_CORE_ADD_BINDING_H
14
16
17namespace mcrl2
18{
19
20namespace core
21{
22
24template <template <class> class TraverserOrBuilder, typename Derived, typename Variable>
25class add_binding : public TraverserOrBuilder<Derived>
26{
27 public:
28 typedef TraverserOrBuilder<Derived> super;
29 typedef Variable variable_type;
30
31 protected:
32 std::multiset<variable_type> m_bound_variables;
33
36 {
37 m_bound_variables.insert(var);
38 }
39
41 template <typename Container>
42 void increase_bind_count(const Container& variables, typename atermpp::enable_if_container<Container, variable_type>::type* = nullptr)
43 {
44 for (typename Container::const_iterator i = variables.begin(); i != variables.end(); ++i)
45 {
46 m_bound_variables.insert(*i);
47 }
48 }
49
52 {
53 m_bound_variables.erase(m_bound_variables.find(var));
54 }
55
57 template <typename Container>
58 void decrease_bind_count(const Container& variables, typename atermpp::enable_if_container<Container, variable_type>::type* = nullptr)
59 {
60 for (typename Container::const_iterator i = variables.begin(); i != variables.end(); ++i)
61 {
63 }
64 }
65
66 public:
68 bool is_bound(variable_type const& v) const
69 {
70 return m_bound_variables.find(v) != m_bound_variables.end();
71 }
72
74 const std::multiset<variable_type>& bound_variables() const
75 {
76 return m_bound_variables;
77 }
78
80 typename std::multiset<variable_type>::size_type bind_count(const variable_type& v)
81 {
82 return m_bound_variables.count(v);
83 }
84};
85
86} // namespace core
87
88} // namespace mcrl2
89
90#endif // MCRL2_CORE_ADD_BINDING_H
A class containing some type traits.
Traverser that defines functions for maintaining bound variables.
Definition add_binding.h:26
TraverserOrBuilder< Derived > super
Definition add_binding.h:28
std::multiset< variable_type >::size_type bind_count(const variable_type &v)
Returns the bind count of the variable v.
Definition add_binding.h:80
void decrease_bind_count(const Container &variables, typename atermpp::enable_if_container< Container, variable_type >::type *=nullptr)
Remove a sequence of variables from the multiset of bound variables.
Definition add_binding.h:58
void increase_bind_count(const Container &variables, typename atermpp::enable_if_container< Container, variable_type >::type *=nullptr)
Add a sequence of variables to the multiset of bound variables.
Definition add_binding.h:42
bool is_bound(variable_type const &v) const
Returns true if the variable v is bound.
Definition add_binding.h:68
const std::multiset< variable_type > & bound_variables() const
Returns the bound variables.
Definition add_binding.h:74
std::multiset< variable_type > m_bound_variables
Definition add_binding.h:32
void decrease_bind_count(const variable_type &var)
Remove a variable from the multiset of bound variables.
Definition add_binding.h:51
void increase_bind_count(const variable_type &var)
Add a variable to the multiset of bound variables.
Definition add_binding.h:35
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72