0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
class_method.h
Go to the documentation of this file.
1/**
2 * @file src/class_diagram/model/class_method.h
3 *
4 * Copyright (c) 2021-2024 Bartek Kryza <bkryza@gmail.com>
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18#pragma once
19
20#include "class_element.h"
23#include "method_parameter.h"
24
25#include <string>
26#include <vector>
27
29
31
32/**
33 * @brief Class method model.
34 */
36public:
37 /**
38 * @brief Constructor.
39 *
40 * @param access Methods access scope (e.g. public)
41 * @param name Methods name.
42 * @param type Methods return type as string.
43 */
45 const std::string &type);
46
47 ~class_method() override = default;
48
49 void update(const common::model::namespace_ &un);
50
51 /**
52 * @brief Method name including template parameters/arguments if any
53 *
54 * @return String representation of the methods display name
55 */
56 std::string display_name() const;
57
58 void set_display_name(const std::string &display_name);
59
60 /**
61 * @brief Whether the method is pure virtual.
62 *
63 * @return True, if the method is pure virtual
64 */
65 bool is_pure_virtual() const;
67
68 /**
69 * @brief Whether the method is virtual.
70 *
71 * @return True, if the method is virtual
72 */
73 bool is_virtual() const;
74
75 /**
76 * @brief Set whether the method is virtual.
77 *
78 * @param is_virtual True, if the method is virtual
79 */
80 void is_virtual(bool is_virtual);
81
82 /**
83 * @brief Whether the method is const.
84 *
85 * @return True, if the method is const
86 */
87 bool is_const() const;
88
89 /**
90 * @brief Set whether the method is const.
91 *
92 * @param is_const True, if the method is const
93 */
94 void is_const(bool is_const);
95
96 /**
97 * @brief Whether the method is defaulted.
98 *
99 * @return True, if the method is defaulted
100 */
101 bool is_defaulted() const;
102
103 /**
104 * @brief Set whether the method is defaulted.
105 *
106 * @param is_defaulted True, if the method is defaulted
107 */
108 void is_defaulted(bool is_defaulted);
109
110 /**
111 * @brief Whether the method is deleted.
112 *
113 * @return True, if the method is deleted
114 */
115 bool is_deleted() const;
116
117 /**
118 * @brief Set whether the method is deleted.
119 *
120 * @param is_deleted True, if the method is deleted
121 */
122 void is_deleted(bool is_deleted);
123
124 /**
125 * @brief Whether the method is static.
126 *
127 * @return True, if the method is static
128 */
129 bool is_static() const;
130
131 /**
132 * @brief Set whether the method is static.
133 *
134 * @param is_static True, if the method is static
135 */
136 void is_static(bool is_static);
137
138 /**
139 * @brief Whether the method is constexpr.
140 *
141 * @return True, if the method is constexpr
142 */
143 bool is_constexpr() const;
144
145 /**
146 * @brief Set whether the method is constexpr.
147 *
148 * @param is_constexpr True, if the method is constexpr
149 */
150 void is_constexpr(bool is_constexpr);
151
152 /**
153 * @brief Whether the method is consteval.
154 *
155 * @return True, if the method is consteval
156 */
157 bool is_consteval() const;
158
159 /**
160 * @brief Set whether the method is consteval.
161 *
162 * @param is_consteval True, if the method is consteval
163 */
164 void is_consteval(bool is_consteval);
165
166 /**
167 * @brief Whether the method is a C++20 coroutine.
168 *
169 * @return True, if the method is a coroutine
170 */
171 bool is_coroutine() const;
172
173 /**
174 * @brief Set whether the method is a C++20 coroutine.
175 *
176 * @param is_coroutine True, if the method is a coroutine
177 */
178 void is_coroutine(bool is_coroutine);
179
180 /**
181 * @brief Whether the method is noexcept.
182 *
183 * @return True, if the method is noexcept
184 */
185 bool is_noexcept() const;
186
187 /**
188 * @brief Set whether the method is noexcept.
189 *
190 * @param is_noexcept True, if the method is noexcept
191 */
192 void is_noexcept(bool is_noexcept);
193
194 /**
195 * @brief Whether the method is a constructor.
196 *
197 * @return True, if the method is a constructor
198 */
199 bool is_constructor() const;
200
201 /**
202 * @brief Set whether the method is a constructor.
203 *
204 * @param is_constructor True, if the method is a constructor
205 */
207
208 /**
209 * @brief Whether the method is a destructor.
210 *
211 * @return True, if the method is a destructor
212 */
213 bool is_destructor() const;
214
215 /**
216 * @brief Set whether the method is a destructor.
217 *
218 * @param is_destructor True, if the method is a destructor
219 */
220 void is_destructor(bool is_destructor);
221
222 /**
223 * @brief Whether the method is move assignment.
224 *
225 * @return True, if the method is move assignment
226 */
227 bool is_move_assignment() const;
228
229 /**
230 * @brief Set whether the method is a move assignment.
231 *
232 * @param is_move_assignment True, if the method is a move assignment
233 */
235
236 /**
237 * @brief Whether the method is copy assignment.
238 *
239 * @return True, if the method is copy assignment
240 */
241 bool is_copy_assignment() const;
242
243 /**
244 * @brief Set whether the method is a copy assignment.
245 *
246 * @param is_copy_assignment True, if the method is a copy assignment
247 */
249
250 /**
251 * @brief Whether the method is an operator.
252 *
253 * @return True, if the method is an operator
254 */
255 bool is_operator() const;
256
257 /**
258 * @brief Set whether the method is an operator.
259 *
260 * @param is_copy_assignment True, if the method is an operator
261 */
262 void is_operator(bool is_operator);
263
264 /**
265 * @brief Get the method parameters.
266 *
267 * @return List of methods parameters
268 */
269 const std::vector<method_parameter> &parameters() const;
270
271 /**
272 * @brief Add methods parameter.
273 *
274 * @param parameter Method parameter.
275 */
276 void add_parameter(method_parameter &&parameter);
277
278private:
279 std::vector<method_parameter> parameters_;
280
281 bool is_pure_virtual_{false};
282 bool is_virtual_{false};
283 bool is_const_{false};
284 bool is_defaulted_{false};
285 bool is_deleted_{false};
286 bool is_static_{false};
287 bool is_noexcept_{false};
288 bool is_constexpr_{false};
289 bool is_consteval_{false};
290 bool is_coroutine_{false};
291 bool is_constructor_{false};
292 bool is_destructor_{false};
295 bool is_operator_{false};
296
297 std::string display_name_;
298};
299} // namespace clanguml::class_diagram::model