mCRL2
Loading...
Searching...
No Matches
identifier_generator.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_DATA_IDENTIFIER_GENERATOR_H
13#define MCRL2_DATA_IDENTIFIER_GENERATOR_H
14
17
18namespace mcrl2
19{
20
21namespace data
22{
23
30template <typename Generator = utilities::number_postfix_generator>
32{
33 protected:
34 Generator m_generator;
35
36 public:
39
41 virtual ~identifier_generator() = default;
42
44 virtual void clear_context() = 0;
45
48 virtual void add_identifier(const core::identifier_string& s) = 0;
49
52 virtual void remove_identifier(const core::identifier_string& s) = 0;
53
55 void add_identifiers(const std::set<core::identifier_string>& ids)
56 {
57 for (const core::identifier_string& id: ids)
58 {
60 }
61 }
62
64 void remove_identifiers(const std::set<core::identifier_string>& ids)
65 {
66 for (const core::identifier_string& id: ids)
67 {
69 }
70 }
71
75 virtual bool has_identifier(const core::identifier_string& s) const = 0;
76
83 virtual core::identifier_string operator()(const std::string& hint, bool add_to_context = true)
84 {
85 core::identifier_string id(add_to_context?hint:m_generator(hint));
86 while (has_identifier(id))
87 {
89 }
90 if (add_to_context)
91 {
93 }
94 return id;
95 }
96};
97
98} // namespace data
99
100} // namespace mcrl2
101
102#endif // MCRL2_DATA_IDENTIFIER_GENERATOR_H
Term containing a string.
Abstract base class for identifier generators. Identifier generators generate fresh names that do not...
virtual core::identifier_string operator()(const std::string &hint, bool add_to_context=true)
Returns a fresh identifier, with the given hint as prefix. The returned identifier is added to the co...
virtual ~identifier_generator()=default
Destructor.
virtual void add_identifier(const core::identifier_string &s)=0
Adds the identifier s to the context.
virtual bool has_identifier(const core::identifier_string &s) const =0
Returns true if the identifier s appears in the context.
identifier_generator()=default
Constructor.
void remove_identifiers(const std::set< core::identifier_string > &ids)
Remove a set of identifiers from the context.
virtual void remove_identifier(const core::identifier_string &s)=0
Removes the identifier s from the context.
virtual void clear_context()=0
Clears the context.
void add_identifiers(const std::set< core::identifier_string > &ids)
Add a set of identifiers to the context.
aterm representations of identifier strings.
atermpp::aterm_string identifier_string
String type of the LPS library. Identifier strings are represented internally as ATerms.
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.