mCRL2
Loading...
Searching...
No Matches
aterm_core.h
Go to the documentation of this file.
1// Author(s): Jan Friso Groote, Maurice Laveaux, 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
10#ifndef MCRL2_ATERMPP_ATERM_H
11#define MCRL2_ATERMPP_ATERM_H
12
13#include <algorithm>
14#include <assert.h>
15#include <sstream>
18
20namespace atermpp
21{
22
23// Forward declaration
24namespace detail
25{
26 class thread_aterm_pool;
27}
28
32{
34
35protected:
37
38public:
39
42 : m_term(nullptr)
43 {}
44
48 : m_term(term)
49 {}
50
55 bool type_is_appl() const noexcept
56 {
57 return !type_is_int() && !type_is_list();
58 }
59
63 bool type_is_int() const noexcept
64 {
66 return f == detail::g_as_int;
67 }
68
72 bool type_is_list() const noexcept
73 {
76 }
77
84 {
85 return m_term == t.m_term;
86 }
87
93 {
94 return m_term!=t.m_term;
95 }
96
105 {
106 return m_term<t.m_term;
107 }
108
114 {
115 return m_term>t.m_term;
116 }
117
123 {
124 return m_term<=t.m_term;
125 }
126
132 {
133 return m_term>=t.m_term;
134 }
135
143 bool defined() const
144 {
145 return m_term != nullptr;
146 }
147
152 void swap(unprotected_aterm_core& t) noexcept
153 {
154 std::swap(m_term, t.m_term);
155 }
156
162 {
163 return m_term->function();
164 }
165};
166
180//
182{
183public:
184
186 aterm_core() noexcept;
187
189 ~aterm_core() noexcept;
190
196 explicit aterm_core(const detail::_aterm *t) noexcept;
197
201 aterm_core(const aterm_core& other) noexcept;
202
207 aterm_core(aterm_core&& other) noexcept;
208
212 aterm_core& operator=(const aterm_core& other) noexcept;
213
215 // \detail This can be used as an optimisation, because it avoids getting access to thread local variables,
216 // which is as it stands relatively expensive. The effect is equal to the assignment operator =.
218 aterm_core& assign(const aterm_core& other,
220
227 template <bool CHECK_BUSY_FLAG=true>
228 aterm_core& unprotected_assign(const aterm_core& other) noexcept;
229
233 aterm_core& operator=(aterm_core&& other) noexcept;
234};
235
236namespace detail
237{
240 {
241 return const_cast<_aterm*>(t.m_term);
242 }
243}
244
245} // namespace atermpp
246
247#endif // MCRL2_ATERMPP_ATERM_H
A class containing some type traits.
The aterm_core base class that provides protection of the underlying shared terms.
Definition aterm_core.h:182
~aterm_core() noexcept
Standard destructor.
aterm_core & operator=(const aterm_core &other) noexcept
Assignment operator.
aterm_core() noexcept
Default constructor.
aterm_core & assign(const aterm_core &other, detail::thread_aterm_pool &pool) noexcept
Assignment operator, to be used if busy and forbidden flags are explicitly available.
aterm_core & unprotected_assign(const aterm_core &other) noexcept
Assignment operator, to be used when the busy flags do not need to be set.
This is the class to which an aterm points.
Definition aterm_core.h:48
const function_symbol & function() const noexcept
Definition aterm_core.h:55
This is a thread's specific access to the global aterm pool which ensures that garbage collection and...
An unprotected term does not change the reference count of the shared term when it is copied or moved...
Definition aterm_core.h:32
bool operator<=(const unprotected_aterm_core &t) const
Comparison operator for two unprotected aterms.
Definition aterm_core.h:122
bool operator>=(const unprotected_aterm_core &t) const
Comparison operator for two unprotected aterms.
Definition aterm_core.h:131
bool type_is_list() const noexcept
Dynamic check whether the term is an aterm_list.
Definition aterm_core.h:72
void swap(unprotected_aterm_core &t) noexcept
Swaps this term with its argument.
Definition aterm_core.h:152
bool operator>(const unprotected_aterm_core &t) const
Comparison operator for two unprotected aterms.
Definition aterm_core.h:113
bool operator<(const unprotected_aterm_core &t) const
Comparison operator for two unprotected aterms.
Definition aterm_core.h:104
bool operator==(const unprotected_aterm_core &t) const
Comparison operator.
Definition aterm_core.h:83
unprotected_aterm_core() noexcept
Default constuctor.
Definition aterm_core.h:41
bool type_is_appl() const noexcept
Dynamic check whether the term is an aterm.
Definition aterm_core.h:55
bool defined() const
Returns true if this term is not equal to the term assigned by the default constructor of aterms,...
Definition aterm_core.h:143
const detail::_aterm * m_term
Definition aterm_core.h:36
bool operator!=(const unprotected_aterm_core &t) const
Inequality operator on two unprotected aterms.
Definition aterm_core.h:92
const function_symbol & function() const
Yields the function symbol in an aterm.
Definition aterm_core.h:161
bool type_is_int() const noexcept
Dynamic check whether the term is an aterm_int.
Definition aterm_core.h:63
unprotected_aterm_core(const detail::_aterm *term) noexcept
Constructor.
Definition aterm_core.h:47
a pool allocator class
_aterm * address(const unprotected_aterm_core &t)
Definition aterm_core.h:239
function_symbol g_as_empty_list
function_symbol g_as_list
function_symbol g_as_int
These function symbols are used to indicate integer, list and empty list terms.
The main namespace for the aterm++ library.
Definition algorithm.h:21
void swap(atermpp::unprotected_aterm_core &t1, atermpp::unprotected_aterm_core &t2) noexcept
Swaps two aterms.
Definition aterm.h:462