0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
package_diagram_generator.cc
Go to the documentation of this file.
1/**
2 * @file src/package_diagram/generators/graphml/package_diagram_generator.cc
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
20
21#include "util/error.h"
22
24
27{
28}
29
30void generator::generate_top_level_elements(graphml_node_t &parent) const
31{
32 for (const auto &p : model()) {
33 auto &pkg = dynamic_cast<package &>(*p);
34 generate(pkg, parent);
35 }
36
39}
40
41void generator::generate(const package &p, graphml_node_t &parent) const
42{
44
45 LOG_DBG("Generating package {}", p.full_name(false));
46
47 const auto &uns = config().using_namespace();
48
49 if (!uns.starts_with({p.full_name(false)})) {
50 auto package_node = make_subgraph(parent, p.alias(),
51 display_name_adapter(p).with_packages().name(),
52 to_string(config().package_type()));
53
54 generate_link(package_node, p);
55
56 if (p.is_deprecated())
57 add_data(package_node, "stereotype", "deprecated");
58
59 auto graph_node = make_graph(package_node, p.alias());
60
61 for (const auto &subpackage : p) {
62 auto &pkg = dynamic_cast<package &>(*subpackage);
63 generate(pkg, graph_node);
64 }
65
66 generate_notes(p, graph_node);
67 }
68 else {
69 for (const auto &subpackage : p) {
70 auto &pkg = dynamic_cast<package &>(*subpackage);
71 generate(pkg, parent);
72 }
73
74 generate_notes(p, parent);
75 }
76}
77
78} // namespace clanguml::package_diagram::generators::graphml