0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
message.cc
Go to the documentation of this file.
1/**
2 * @file src/sequence_diagram/model/message.cc
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
19#include "message.h"
20
22
24 : type_{type}
25 , from_{from}
26{
27}
28
29bool message::operator==(const message &other) const noexcept
30{
31 return from_ == other.from_ && to_ == other.to_ && type_ == other.type_ &&
32 scope_ == other.scope_ && message_name_ == other.message_name_ &&
33 return_type_ == other.return_type_ &&
34 condition_text_ == other.condition_text_ && comment_ == other.comment_;
35}
36
38
40
42
43eid_t message::from() const { return from_; }
44
45void message::set_to(eid_t t) { to_ = t; }
46
47eid_t message::to() const { return to_; }
48
49void message::set_message_name(std::string name)
50{
51 message_name_ = std::move(name);
52}
53
54const std::string &message::message_name() const { return message_name_; }
55
56void message::set_return_type(std::string t) { return_type_ = std::move(t); }
57
58const std::string &message::return_type() const { return return_type_; }
59
60const std::optional<common::model::comment_t> &message::comment() const
61{
62 return comment_;
63}
64
66 std::optional<std::pair<unsigned int, std::string>> comment)
67{
68 if (comment.has_value()) {
69 set_comment(comment.value().first, comment.value().second);
70 }
71}
72
73void message::set_comment(unsigned int id, std::string comment)
74{
75 if (comment.empty())
76 return;
77
79 c["id"] = id;
80 c["comment"] = comment;
81
82 set_comment(std::move(c));
83}
84
86{
87 if (!c.empty())
88 comment_ = std::move(c);
89}
90
91void message::set_comment(const std::optional<common::model::comment_t> &c)
92{
93 if (c)
94 set_comment(c.value());
95}
96
98{
99 scope_ = scope;
100}
101
103
104void message::condition_text(const std::string &condition_text)
105{
106 if (condition_text.empty())
107 condition_text_ = std::nullopt;
108 else
110}
111
112std::optional<std::string> message::condition_text() const
113{
114 return condition_text_;
115}
116
118{
120}
121
123{
125}
126
127} // namespace clanguml::sequence_diagram::model