0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
src
sequence_diagram
model
message.h
Go to the documentation of this file.
1
/**
2
* @file src/sequence_diagram/model/message.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
20
#include "
common/model/enums.h
"
21
#include "
participant.h
"
22
23
#include <string>
24
#include <vector>
25
26
namespace
clanguml::sequence_diagram::model
{
27
28
/**
29
* @brief Model of a sequence diagram message.
30
*/
31
class
message
:
public
common::model::diagram_element
{
32
public
:
33
message
() =
default
;
34
35
/**
36
* @brief Constructor
37
*
38
* @param type Message type
39
* @param from Id of originating sequence
40
*/
41
message
(
common::model::message_t
type
,
eid_t
from
);
42
43
/**
44
* @brief Equality operator
45
*
46
* @param other Compare this to other message
47
* @return True, if 2 messages are equal
48
*/
49
bool
operator==
(
const
message
&other)
const
noexcept
;
50
51
/**
52
* @brief Set message type
53
*
54
* @param t Message type
55
*/
56
void
set_type
(
common::model::message_t
t);
57
58
/**
59
* @brief Get message type
60
*
61
* @return Message type
62
*/
63
common::model::message_t
type
()
const
;
64
65
/**
66
* @brief Set the id of message source participant
67
*
68
* @param f Id of the participant from which message originates
69
*/
70
void
set_from
(
eid_t
f);
71
72
/**
73
* @brief Get the id of source of message
74
*
75
* @return
76
*/
77
eid_t
from
()
const
;
78
79
/**
80
* @brief Set the id of the message target
81
*
82
* @param t Id of the message target
83
*/
84
void
set_to
(
eid_t
t);
85
86
/**
87
* @brief Get the id of the message target
88
*
89
* @return Id of the message target
90
*/
91
eid_t
to
()
const
;
92
93
/**
94
* @brief Set the message label
95
*
96
* @param name Message label
97
*/
98
void
set_message_name
(std::string
name
);
99
100
/**
101
* @brief Get the message label
102
*
103
* @return Message label
104
*/
105
const
std::string &
message_name
()
const
;
106
107
/**
108
* @brief Set the return message type label
109
*
110
* @param t Message return type label
111
*/
112
void
set_return_type
(std::string t);
113
114
/**
115
* @brief Get the return message type label
116
*
117
* @return Message return type label
118
*/
119
const
std::string &
return_type
()
const
;
120
121
const
std::optional<common::model::comment_t> &
comment
()
const
;
122
123
void
set_comment
(
124
std::optional<std::pair<unsigned int, std::string>>
comment
);
125
126
void
set_comment
(
unsigned
int
id
, std::string
comment
);
127
128
void
set_comment
(
common::model::comment_t
c);
129
130
void
set_comment
(
const
std::optional<common::model::comment_t> &c);
131
132
/**
133
* @brief Set message scope
134
*
135
* Message scope currently means whether the message was called from
136
* regular statement, or a statement embedded in a statement block condition
137
*
138
* @param scope Message scope
139
*/
140
void
set_message_scope
(
common::model::message_scope_t
scope);
141
142
/**
143
* @brief Get message scope
144
*
145
* @return Message scope
146
*/
147
common::model::message_scope_t
message_scope
()
const
;
148
149
/**
150
* @brief Set condition text for block statements (e.g. if(<THIS TEXT>))
151
*
152
* @param condition_text Condition text
153
*/
154
void
condition_text
(
const
std::string &
condition_text
);
155
156
/**
157
* @brief Get condition text
158
*
159
* @return Block statement condition text
160
*/
161
std::optional<std::string>
condition_text
()
const
;
162
163
bool
in_static_declaration_context
()
const
;
164
165
void
in_static_declaration_context
(
bool
v);
166
167
private
:
168
common::model::message_t
type_
{
common::model::message_t::kNone
};
169
170
eid_t
from_
{};
171
172
eid_t
to_
{};
173
174
common::model::message_scope_t
scope_
{
175
common::model::message_scope_t::kNormal
};
176
177
// This is only for better verbose messages, we cannot rely on this
178
// always
179
std::string
message_name_
{};
180
181
std::string
return_type_
{};
182
183
std::optional<std::string>
condition_text_
;
184
185
std::optional<common::model::comment_t>
comment_
;
186
187
bool
in_static_declaration_context_
{
false
};
188
};
189
190
}
// namespace clanguml::sequence_diagram::model
Copyright © 2022-present
Bartek Kryza
Generated by
1.9.7