0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
clanguml::include_diagram::generators::plantuml::generator Class Reference

Include diagram PlantUML generator. More...

Detailed Description

Include diagram PlantUML generator.

Definition at line 52 of file include_diagram_generator.h.

#include <include_diagram_generator.h>

Public Member Functions

 generator (diagram_config &config, diagram_model &model)
 
void generate_diagram (std::ostream &ostr) const override
 Main generator method.
 
void generate_relationships (const source_file &p, std::ostream &ostr) const
 Generate relationships originating from source_file f
 
void generate (const source_file &f, std::ostream &ostr) const
 Generate diagram element.
 
- Public Member Functions inherited from clanguml::common::generators::plantuml::generator< ConfigType, DiagramType >
 generator (ConfigType &config, DiagramType &model)
 Constructor.
 
 ~generator () override=default
 
void generate (std::ostream &ostr) const override
 Generate diagram.
 
virtual void generate_diagram (std::ostream &ostr) const =0
 Generate diagram specific part.
 
void generate_config_layout_hints (std::ostream &ostr) const
 Generate diagram layout hints.
 
void generate_plantuml_directives (std::ostream &ostr, const std::vector< std::string > &directives) const
 Generate PlantUML directives from config file.
 
void generate_notes (std::ostream &ostr, const model::element &element) const
 Generate diagram notes.
 
void generate_style (std::ostream &ostr, const std::string &element_type, const model::stylable_element &el) const
 Generate diagram element PlantUML style.
 
void generate_metadata (std::ostream &ostr) const
 Generate comment with diagram metadata.
 
void generate_title (std::ostream &ostr) const
 Generate diagram title.
 
template<typename E >
void generate_link (std::ostream &ostr, const E &e) const
 Generate hyper link to element.
 
void generate_link (std::ostream &ostr, const relationship &e) const
 generate_link specialization for relationship
 
void print_debug (const common::model::source_location &e, std::ostream &ostr) const
 Print debug information in diagram comments.
 
- Public Member Functions inherited from clanguml::common::generators::generator< ConfigType, DiagramType >
 generator (ConfigType &config, DiagramType &model)
 Constructor.
 
virtual ~generator ()=default
 
virtual void generate (std::ostream &ostr) const =0
 Generate diagram.
 
const ConfigType & config () const
 Get reference to diagram config.
 
const DiagramType & model () const
 Get reference to diagram model.
 
std::optional< std::pair< std::string, std::string > > get_link_pattern (const common::model::source_location &sl) const
 
std::optional< std::pair< std::string, std::string > > get_tooltip_pattern (const common::model::source_location &sl) const
 
std::optional< std::string > render_link (const common::model::diagram_element &e) const
 
std::optional< std::string > render_link (const common::model::relationship &e) const
 
std::optional< std::string > render_tooltip (const common::model::diagram_element &e) const
 
std::optional< std::string > render_tooltip (const common::model::relationship &e) const
 
void init_context ()
 Initialize diagram Jinja context.
 
void update_context () const
 Update diagram Jinja context.
 
void init_env ()
 
const inja::json & context () const
 
inja::Environment & env () const
 

Private Member Functions

void generate_with_packages (const source_file &f, std::ostream &ostr) const
 
void generate_without_packages (const source_file &f, std::ostream &ostr) const
 

Additional Inherited Members

- Protected Attributes inherited from clanguml::common::generators::plantuml::generator< ConfigType, DiagramType >
std::set< std::string > m_generated_aliases
 
- Protected Attributes inherited from clanguml::common::generators::generator< ConfigType, DiagramType >
inja::json m_context
 
inja::Environment m_env
 

Constructor & Destructor Documentation

◆ generator()

clanguml::include_diagram::generators::plantuml::generator::generator ( diagram_config config,
diagram_model model 
)

Definition at line 25 of file include_diagram_generator.cc.

26 : common_generator<diagram_config, diagram_model>{config, model}
27{
28}

Member Function Documentation

◆ generate()

void clanguml::include_diagram::generators::plantuml::generator::generate ( const source_file f,
std::ostream &  ostr 
) const

Generate diagram element.

Parameters
fSource file diagram element
parentOutput stream

Definition at line 55 of file include_diagram_generator.cc.

56{
57 if (config().generate_packages && !config().generate_packages()) {
59 }
60 else {
62 }
63}

◆ generate_diagram()

void clanguml::include_diagram::generators::plantuml::generator::generate_diagram ( std::ostream &  ostr) const
overridevirtual

Main generator method.

This method is called first and coordinates the entire diagram generation.

Parameters
ostrOutput stream.

Implements clanguml::common::generators::plantuml::generator< ConfigType, DiagramType >.

Definition at line 123 of file include_diagram_generator.cc.

124{
125 // Generate files and folders
126 util::for_each(model(), [this, &ostr](const auto &f) {
127 generate(dynamic_cast<source_file &>(*f), ostr);
128 });
129
130 // Process file include relationships
131 util::for_each(model(), [this, &ostr](const auto &f) {
132 generate_relationships(dynamic_cast<source_file &>(*f), ostr);
133 });
134
136}

◆ generate_relationships()

void clanguml::include_diagram::generators::plantuml::generator::generate_relationships ( const source_file p,
std::ostream &  ostr 
) const

Generate relationships originating from source_file f

Parameters
pDiagram element
parentOutput stream

Definition at line 30 of file include_diagram_generator.cc.

32{
33 if (!util::contains(m_generated_aliases, f.alias()))
34 return;
35
36 LOG_DBG("Generating relationships for file {}", f.full_name(true));
37
38 namespace plantuml_common = clanguml::common::generators::plantuml;
39
41 util::for_each(f, [this, &ostr](const auto &file) {
43 dynamic_cast<const source_file &>(*file), ostr);
44 });
45 }
46 else {
47 for (const auto &r : f.relationships()) {
48 ostr << f.alias() << " "
49 << plantuml_common::to_plantuml(r, config()) << " "
50 << model().get(r.destination()).value().alias() << '\n';
51 }
52 }
53}

◆ generate_with_packages()

void clanguml::include_diagram::generators::plantuml::generator::generate_with_packages ( const source_file f,
std::ostream &  ostr 
) const
private

Definition at line 65 of file include_diagram_generator.cc.

67{
69 LOG_DBG("Generating directory {}", f.name());
70
71 ostr << "folder \"" << f.name();
72 ostr << "\" as " << f.alias();
73 ostr << " {\n";
74
75 util::for_each(f, [this, &ostr](const auto &file) {
76 generate(dynamic_cast<const source_file &>(*file), ostr);
77 });
78
79 ostr << "}" << '\n';
80
81 m_generated_aliases.emplace(f.alias());
82 }
83 else {
84 LOG_DBG("Generating file {}", f.name());
85
86 ostr << "file \"" << f.name() << "\" as " << f.alias();
87
88 if (config().generate_links) {
89 generate_link(ostr, f);
90 }
91
92 ostr << '\n';
93
94 m_generated_aliases.emplace(f.alias());
95 }
96}

◆ generate_without_packages()

void clanguml::include_diagram::generators::plantuml::generator::generate_without_packages ( const source_file f,
std::ostream &  ostr 
) const
private

Definition at line 98 of file include_diagram_generator.cc.

100{
101 LOG_DBG("Generating file {}", f.name());
102
104 util::for_each(f, [this, &ostr](const auto &file) {
105 generate(dynamic_cast<const source_file &>(*file), ostr);
106 });
107
108 m_generated_aliases.emplace(f.alias());
109 }
110 else {
111 ostr << "file \"" << f.file_relative() << "\" as " << f.alias();
112
113 if (config().generate_links) {
114 generate_link(ostr, f);
115 }
116
117 ostr << '\n';
118
119 m_generated_aliases.emplace(f.alias());
120 }
121}

The documentation for this class was generated from the following files: