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::graphml::generator Class Reference

Include diagram JSON generator. More...

Detailed Description

Include diagram JSON generator.

Definition at line 50 of file include_diagram_generator.h.

#include <include_diagram_generator.h>

Public Member Functions

 generator (diagram_config &config, diagram_model &model)
 
std::vector< std::pair< std::string, common::generators::graphml::property_type > > node_property_names () const override
 
void generate (const source_file &e, graphml_node_t &parent) const
 Generate diagram element.
 
void generate_top_level_elements (graphml_node_t &parent) const override
 
- Public Member Functions inherited from clanguml::common::generators::graphml::generator< ConfigType, DiagramType >
 ~generator () override=default
 
virtual std::vector< std::pair< std::string, property_type > > graph_property_names () const
 
virtual std::vector< std::pair< std::string, property_type > > node_property_names () const
 
virtual std::vector< std::pair< std::string, property_type > > edge_property_names () const
 
void generate (std::ostream &ostr) const override
 Generate diagram.
 
void generate_diagram (graphml_node_t &parent) const
 Generate diagram model.
 
virtual void generate_top_level_elements (graphml_node_t &parent) const =0
 In a nested diagram, generate the top level elements.
 
template<typename T >
void generate_notes (const T &e, graphml_node_t &parent) const
 Generate any notes to be attached to diagram elements.
 
void generate_metadata (graphml_t &parent) const
 Generate metadata element with diagram metadata.
 
virtual void generate (const model::package &p, graphml_node_t &parent) const
 Generate diagram package.
 
virtual void generate_relationships (graphml_node_t &parent) const
 Generate all relationships in the diagram.
 
virtual void generate_relationships (const model::diagram_element &c, graphml_node_t &parent) const
 Generate all relationships originating at a diagram element.
 
template<typename T >
void generate_link (pugi::xml_node &node, const T &c) const
 
const property_keymap_tgraph_properties () const
 
const property_keymap_tnode_properties () const
 
const property_keymap_tedge_properties () const
 
pugi::xml_node make_node (graphml_node_t &parent, const std::string &id) const
 
pugi::xml_node make_graph (graphml_node_t &parent, const std::string &id) const
 
pugi::xml_node make_subgraph (graphml_node_t &parent, const std::string &id, const std::string &name="", const std::string &type="") const
 
void add_data (pugi::xml_node &node, const std::string &key, const std::string &value, bool cdata=false) const
 
void add_cdata (pugi::xml_node &node, const std::string &key, const std::string &value) const
 
- 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, graphml_node_t &parent) const
 
void generate_without_packages (const source_file &f, graphml_node_t &parent) const
 

Additional Inherited Members

- Protected Member Functions inherited from clanguml::common::generators::graphml::generator< ConfigType, DiagramType >
void generate_key (pugi::xml_node &parent, const std::string &attr_name, const std::string &for_value, const std::string &id_value, const std::string &attr_type="string") const
 
property_keymap_tgraph_properties ()
 
property_keymap_tnode_properties ()
 
property_keymap_tedge_properties ()
 
- Protected Attributes inherited from clanguml::common::generators::graphml::generator< ConfigType, DiagramType >
graphml_node_map_t graph_ids_ {"g"}
 
graphml_node_map_t node_ids_ {"n"}
 
graphml_node_map_t edge_ids_ {"e"}
 
- 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::graphml::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::graphml::generator::generate ( const source_file e,
graphml_node_t &  parent 
) const

Generate diagram element.

Parameters
eSource file diagram element
parentParent XML node

Definition at line 40 of file include_diagram_generator.cc.

41{
42 if (config().generate_packages && !config().generate_packages()) {
44 }
45 else {
46 generate_with_packages(f, parent);
47 }
48}

◆ generate_top_level_elements()

void clanguml::include_diagram::generators::graphml::generator::generate_top_level_elements ( graphml_node_t &  parent) const
override

Definition at line 125 of file include_diagram_generator.cc.

126{
127 // Generate files and folders
128 util::for_each(model(), [this, &parent](const auto &f) {
129 generate(dynamic_cast<source_file &>(*f), parent);
130 });
131}

◆ generate_with_packages()

void clanguml::include_diagram::generators::graphml::generator::generate_with_packages ( const source_file f,
graphml_node_t &  parent 
) const
private

Definition at line 50 of file include_diagram_generator.cc.

52{
53 auto display_name = f.full_name(false);
54#if defined(_MSC_VER)
55 util::replace_all(display_name, "\\", "/");
56#endif
57
59 LOG_DBG("Generating directory {}", f.name());
60
61 auto package_node =
62 make_subgraph(parent, f.alias(), f.name(), "folder");
63
64 generate_link(package_node, f);
65
66 auto graph_node = make_graph(package_node, f.alias());
67
68 util::for_each(f, [&, this](const auto &file) {
69 generate(dynamic_cast<const source_file &>(*file), graph_node);
70 });
71 }
72 else {
73 LOG_DBG("Generating file {}", f.name());
74
75 auto file_node = make_node(parent, node_ids_.add(f.alias()));
76 add_data(file_node, "type", "file");
77 add_cdata(file_node, "name", f.name());
78
80 add_data(file_node, "stereotype", "header");
81 if (f.is_system_header())
82 add_data(file_node, "is_system", "true");
83 }
84 else {
85 add_data(file_node, "stereotype", "source");
86 }
87
88 generate_link(file_node, f);
89 }
90}

◆ generate_without_packages()

void clanguml::include_diagram::generators::graphml::generator::generate_without_packages ( const source_file f,
graphml_node_t &  parent 
) const
private

Definition at line 92 of file include_diagram_generator.cc.

94{
95 auto display_name = f.full_name(false);
96#if defined(_MSC_VER)
97 util::replace_all(display_name, "\\", "/");
98#endif
99
101 util::for_each(f, [&, this](const auto &file) {
102 generate(dynamic_cast<const source_file &>(*file), parent);
103 });
104 }
105 else {
106 LOG_DBG("Generating file {}", f.file_relative());
107
108 auto file_node = make_node(parent, node_ids_.add(f.alias()));
109 add_data(file_node, "type", "file");
110 add_cdata(file_node, "name", f.file_relative());
111
113 add_data(file_node, "stereotype", "header");
114 if (f.is_system_header())
115 add_data(file_node, "is_system", "true");
116 }
117 else {
118 add_data(file_node, "stereotype", "source");
119 }
120
121 generate_link(file_node, f);
122 }
123}

◆ node_property_names()

std::vector< std::pair< std::string, common::generators::graphml::property_type > > clanguml::include_diagram::generators::graphml::generator::node_property_names ( ) const
overridevirtual

Reimplemented from clanguml::common::generators::graphml::generator< ConfigType, DiagramType >.

Definition at line 31 of file include_diagram_generator.cc.

32{
33 auto defaults =
35 defaults.emplace_back(
37 return defaults;
38}

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