0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
message.h
Go to the documentation of this file.
1/**
2 * @file src/sequence_diagram/model/message.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/model/enums.h"
21#include "participant.h"
22
23#include <string>
24#include <vector>
25
27
28/**
29 * @brief Model of a sequence diagram message.
30 */
32public:
33 message() = default;
34
35 /**
36 * @brief Constructor
37 *
38 * @param type Message type
39 * @param from Id of originating sequence
40 */
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 */
57
58 /**
59 * @brief Get message type
60 *
61 * @return Message type
62 */
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
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 */
141
142 /**
143 * @brief Get message scope
144 *
145 * @return Message scope
146 */
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
164
166
167private:
169
171
173
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
188};
189
190} // namespace clanguml::sequence_diagram::model