0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
class_diagram_generator.h
Go to the documentation of this file.
1/**
2 * @file src/class_diagram/generators/plantuml/class_diagram_generator.h
3 *
4 * Copyright (c) 2021-2025 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
30#include "config/config.h"
31#include "util/util.h"
32
33#include <glob/glob.hpp>
34
35#include <filesystem>
36#include <fstream>
37#include <iostream>
38#include <sstream>
39
40namespace clanguml {
41namespace class_diagram {
42namespace generators {
43namespace plantuml {
44
47template <typename C, typename D>
50
65using namespace clanguml::util;
66
67/**
68 * @brief Class diagram PlantUML generator
69 */
71 : public common_generator<diagram_config, diagram_model>,
73
74public:
76
78
79 /**
80 * @brief Main generator method.
81 *
82 * This method is called first and coordinates the entire diagram
83 * generation.
84 *
85 * @param ostr Output stream.
86 */
87 void generate_diagram(std::ostream &ostr) const override;
88
89 /**
90 * @brief Generate a hyperlink for a class element.
91 *
92 * @param ostr Output stream
93 * @param e Class element (e.g. a method)
94 */
95 void generate_link(std::ostream &ostr, const class_element &e) const;
96
97 /**
98 * @brief Generate PlantUML alias for a class element.
99 *
100 * @param c Class element
101 * @param ostr Output stream
102 */
103 void generate_alias(const class_ &c, std::ostream &ostr) const;
104
105 /**
106 * @brief Generate PlantUML alias for a enum element.
107 *
108 * @param e Enum element
109 * @param ostr Output stream
110 */
111 void generate_alias(const enum_ &e, std::ostream &ostr) const;
112
113 /**
114 * @brief Generate PlantUML alias for a concept element.
115 *
116 * @param c Concept element
117 * @param ostr Output stream
118 */
119 void generate_alias(const concept_ &c, std::ostream &ostr) const;
120
121 /**
122 * @brief Render class element to PlantUML
123 *
124 * @param c Class element
125 * @param ostr Output stream
126 */
127 void generate(const class_ &c, std::ostream &ostr) const;
128
129 void generate(const objc_interface &c, std::ostream &ostr) const;
130
131 void generate_alias(const objc_interface &c, std::ostream &ostr) const;
132
133 /**
134 * @brief Render class methods to PlantUML
135 *
136 * @param methods List of class methods
137 * @param ostr Output stream
138 */
139 void generate_methods(
140 const std::vector<class_method> &methods, std::ostream &ostr) const;
141
142 void start_method_group(std::ostream &ostr) const;
143
144 /**
145 * @brief Render class method to PlantUML
146 *
147 * @param m Class method
148 * @param ostr Output stream
149 */
150 void generate_method(const class_method &m, std::ostream &ostr) const;
151
152 /**
153 * @brief Render class member to PlantUML
154 *
155 * @param m Class member
156 * @param ostr Output stream
157 */
158 void generate_member(const class_member &m, std::ostream &ostr) const;
159
160 /**
161 * @brief Render all relationships originating from class element.
162 *
163 * @param c Class element
164 * @param ostr Output stream
165 */
166 void generate_relationships(const class_ &c, std::ostream &ostr) const;
167
168 /**
169 * @brief Render a specific relationship to PlantUML.
170 *
171 * @param r Relationship model
172 * @param rendered_relations Set of already rendered relationships, to
173 * ensure that there are no duplicate
174 * relationships
175 */
177 const relationship &r, std::set<std::string> &rendered_relations) const;
178
179 /**
180 * @brief Render enum element to PlantUML
181 *
182 * @param e Enum element
183 * @param ostr Output stream
184 */
185 void generate(const enum_ &e, std::ostream &ostr) const;
186
187 /**
188 * @brief Render all relationships originating from enum element.
189 *
190 * @param c Enum element
191 * @param ostr Output stream
192 */
193 void generate_relationships(const enum_ &c, std::ostream &ostr) const;
194
195 /**
196 * @brief Render concept element to PlantUML
197 *
198 * @param c Concept element
199 * @param ostr Output stream
200 */
201 void generate(const concept_ &c, std::ostream &ostr) const;
202
203 /**
204 * @brief Render all relationships originating from concept element.
205 *
206 * @param c Concept element
207 * @param ostr Output stream
208 */
209 void generate_relationships(const concept_ &c, std::ostream &ostr) const;
210
211 /**
212 * @brief Render package element to PlantUML
213 *
214 * @param p Package element
215 * @param ostr Output stream
216 */
217 void generate(const package &p, std::ostream &ostr) const;
218
221
222 /**
223 * @brief Generate any notes attached specifically to some class element.
224 *
225 * @param ostream Output stream
226 * @param member Class element (member or method)
227 * @param alias PlantUML class alias
228 */
229 void generate_member_notes(std::ostream &ostream,
230 const class_element &member, const std::string &alias) const;
231
232 void generate_member(const objc_member &m, std::ostream &ostr) const;
233
234 void generate_method(const objc_method &m, std::ostream &ostr) const;
235
236 void generate_methods(
237 const std::vector<objc_method> &methods, std::ostream &ostr) const;
238
240 const objc_interface &c, std::ostream &ostr) const;
241
243 const std::string &group_name, std::ostream &ostr) const;
244
246 const std::string &group_name, std::ostream &ostr) const;
247
248 void start_package(const package &p, std::ostream &ostr) const;
249
250 void end_package(const package &p, std::ostream &ostr) const;
251};
252
253} // namespace plantuml
254} // namespace generators
255} // namespace class_diagram
256} // namespace clanguml