0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
relationship.h
Go to the documentation of this file.
1/**
2 * @file src/common/model/relationship.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
22#include "common/types.h"
23
24#include <string>
25
27
29
30/**
31 * @brief Class representing any relationship other than inheritance
32 *
33 * This class represents all kinds of relationships between diagram elements,
34 * except for inheritance which are handled in a special way
35 * (See @ref clanguml::class_diagram::model::class_parent).
36 *
37 * @embed{relationship_context_class.svg}
38 */
41public:
42 /**
43 * Constructor.
44 *
45 * @param type Type of relationship
46 * @param destination Id of the relationship target
47 * @param access Access scope of the relationship
48 * @param label Relationship label
49 * @param multiplicity_source Multiplicity at the source
50 * @param multiplicity_destination Multiplicity at the destination
51 */
53 access_t access = access_t::kPublic, std::string label = "",
54 std::string multiplicity_source = "",
55 std::string multiplicity_destination = "");
56
57 ~relationship() override = default;
58
59 /**
60 * Set the type of relatinoship.
61 *
62 * @param type Type of relationship.
63 */
64 void set_type(relationship_t type) noexcept;
65
66 /**
67 * Get the type of relatinoship.
68 *
69 * @return Type of relationship.
70 */
71 relationship_t type() const noexcept;
72
73 /**
74 * Set id of the diagram element which is the target of this
75 * relationship.
76 *
77 * @param destination Target element id.
78 */
80
81 /**
82 * Get the id of the target element of this relationship.
83 *
84 * @return Target element id.
85 */
86 eid_t destination() const;
87
88 /**
89 * Set the relationship multiplicity at the source.
90 *
91 * @param multiplicity_source Source multiplicity.
92 */
94
95 /**
96 * Set the relationship multiplicity at the source.
97 *
98 * @return Source multiplicity.
99 */
100 std::string multiplicity_source() const;
101
102 /**
103 * Set the relationship multiplicity at the destination.
104 *
105 * @param multiplicity_destination Destination multiplicity.
106 */
108 const std::string &multiplicity_destination);
109
110 /**
111 * Set the relationship multiplicity at the destination.
112 *
113 * @return Destination multiplicity.
114 */
115 std::string multiplicity_destination() const;
116
117 /**
118 * Set relationship label.
119 *
120 * @param label Relationship label.
121 */
122 void set_label(const std::string &label);
123
124 /**
125 * Get the relationship label.
126 *
127 * @return Relationoship label.
128 */
129 std::string label() const;
130
131 /**
132 * Set the access scope for this relationship (e.g `public`)
133 *
134 * @param scope Access scope
135 */
136 void set_access(access_t scope) noexcept;
137
138 /**
139 * Get the relationship access scope (e.g. `public`).
140 *
141 * @return Access scope
142 */
143 access_t access() const noexcept;
144
145 friend bool operator==(const relationship &l, const relationship &r);
146
147private:
152 std::string label_;
154};
155} // namespace clanguml::common::model