0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
src
sequence_diagram
generators
plantuml
sequence_diagram_generator.h
Go to the documentation of this file.
1
/**
2
* @file src/sequence_diagram/generators/plantuml/sequence_diagram_generator.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 "
common/generators/plantuml/generator.h
"
21
#include "
config/config.h
"
22
#include "
sequence_diagram/model/diagram.h
"
23
#include "
sequence_diagram/visitor/translation_unit_visitor.h
"
24
#include "
util/util.h
"
25
26
#include <glob/glob.hpp>
27
28
#include <filesystem>
29
#include <fstream>
30
#include <iostream>
31
#include <sstream>
32
33
namespace
clanguml
{
34
namespace
sequence_diagram {
35
namespace
generators {
36
namespace
plantuml
{
37
38
using
clanguml::common::eid_t
;
39
40
using
diagram_config
=
clanguml::config::sequence_diagram
;
41
using
diagram_model
=
clanguml::sequence_diagram::model::diagram
;
42
43
template
<
typename
C,
typename
D>
44
using
common_generator
=
45
clanguml::common::generators::plantuml::generator<C, D>
;
46
47
/**
48
* @brief Sequence diagram PlantUML generator
49
*/
50
class
generator
:
public
common_generator
<diagram_config, diagram_model> {
51
public
:
52
generator
(
diagram_config
&
config
,
diagram_model
&
model
);
53
54
using
common_generator
<
diagram_config
,
diagram_model
>
::generate
;
55
56
/**
57
* @brief Main generator method.
58
*
59
* This method is called first and coordinates the entire diagram
60
* generation.
61
*
62
* @param ostr Output stream.
63
*/
64
void
generate_diagram
(std::ostream &ostr)
const override
;
65
66
/**
67
* @brief Generate sequence diagram message.
68
*
69
* @param m Message model
70
* @param ostr Output stream
71
*/
72
void
generate_call
(
const
clanguml::sequence_diagram::model::message
&m,
73
std::ostream &ostr)
const
;
74
75
/**
76
* @brief Generate sequence diagram return message
77
*
78
* @param m Message model
79
* @param ostr Output stream
80
*/
81
void
generate_return
(
const
clanguml::sequence_diagram::model::message
&m,
82
std::ostream &ostr)
const
;
83
84
/**
85
* @brief Generate sequence diagram participant
86
*
87
* @param ostr Output stream
88
* @param id Participant id
89
* @param force If true, generate the participant even if its not in
90
* the set of active participants
91
* @return Id of the generated participant
92
*/
93
void
generate_participant
(
94
std::ostream &ostr,
eid_t
id
,
bool
force =
false
)
const
;
95
96
/**
97
* @brief Generate sequence diagram participant by name
98
*
99
* This is convienience wrapper over `generate_participant()` by id.
100
*
101
* @param ostr Output stream
102
* @param name Full participant name
103
*/
104
void
generate_participant
(
105
std::ostream &ostr,
const
std::string &name)
const
;
106
107
/**
108
* @brief Generate sequence diagram activity.
109
*
110
* @param a Activity model
111
* @param ostr Output stream
112
* @param visited List of already visited participants, this is necessary
113
* for breaking infinite recursion on recursive calls
114
*/
115
void
generate_activity
(
const
clanguml::sequence_diagram::model::activity
&a,
116
std::ostream &ostr, std::vector<eid_t> &visited)
const
;
117
118
private
:
119
/**
120
* @brief Check if specified participant has already been generated.
121
*
122
* @param id Participant id.
123
* @return True, if participant has already been generated.
124
*/
125
bool
is_participant_generated
(
eid_t
id
)
const
;
126
127
/**
128
* @brief Generate PlantUML alias for participant
129
*
130
* @param participant Sequence diagram participant model
131
* @return Particpant alias
132
*/
133
std::string
generate_alias
(
const
model::participant
&participant)
const
;
134
135
/**
136
* @brief Escape the symbols in the name for PlantUML
137
*
138
* @param name Full participant name
139
* @return Escaped name
140
*/
141
std::string
render_name
(std::string name)
const
;
142
143
/**
144
* @brief Generate message call note
145
*
146
* @param ostr Output stream
147
* @param m Message
148
*/
149
void
generate_message_comment
(
150
std::ostream &ostr,
const
model::message
&m)
const
;
151
152
/**
153
* @brief Convert config to model message render mode.
154
*
155
* @return Method render mode.
156
*/
157
model::function::message_render_mode
158
select_method_arguments_render_mode
()
const
;
159
160
mutable
std::set<eid_t>
generated_participants_
;
161
mutable
std::set<unsigned int>
generated_comment_ids_
;
162
mutable
std::vector<model::message>
already_generated_in_static_context_
;
163
};
164
165
}
// namespace plantuml
166
}
// namespace generators
167
}
// namespace sequence_diagram
168
}
// namespace clanguml
Copyright © 2022-present
Bartek Kryza
Generated by
1.9.7