0.6.0
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
src
common
model
relationship.h
Go to the documentation of this file.
1
/**
2
* @file src/common/model/relationship.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/decorated_element.h
"
21
#include "
common/model/source_location.h
"
22
#include "
common/model/stylable_element.h
"
23
#include "
common/types.h
"
24
25
#include <string>
26
27
namespace
clanguml::common::model
{
28
29
using
clanguml::common::eid_t
;
30
31
/**
32
* @brief Class representing any relationship other than inheritance
33
*
34
* This class represents all kinds of relationships between diagram elements,
35
* except for inheritance which are handled in a special way
36
* (See @ref clanguml::class_diagram::model::class_parent).
37
*
38
* @embed{relationship_context_class.svg}
39
*/
40
class
relationship
:
public
common::model::decorated_element
,
41
public
common::model::stylable_element
,
42
public
common::model::source_location
{
43
public
:
44
/**
45
* Constructor.
46
*
47
* @param type Type of relationship
48
* @param destination Id of the relationship target
49
* @param access Access scope of the relationship
50
* @param label Relationship label
51
* @param multiplicity_source Multiplicity at the source
52
* @param multiplicity_destination Multiplicity at the destination
53
*/
54
relationship
(
relationship_t
type
,
eid_t
destination
,
55
access_t
access
=
access_t::kPublic
, std::string
label
=
""
,
56
std::string
multiplicity_source
=
""
,
57
std::string
multiplicity_destination
=
""
);
58
59
/**
60
* Convenience constructor for extension relationships.
61
*
62
* @param destination Id of relationship target.
63
* @param access Inheritance access (public, protected, private).
64
* @param is_virtual Whether the inheritance is virtual.
65
*/
66
relationship
(
eid_t
destination
,
access_t
access
=
access_t::kPublic
,
67
bool
is_virtual
=
false
);
68
69
~relationship
()
override
=
default
;
70
71
/**
72
* Set the type of relatinoship.
73
*
74
* @param type Type of relationship.
75
*/
76
void
set_type
(
relationship_t
type
)
noexcept
;
77
78
/**
79
* Get the type of relatinoship.
80
*
81
* @return Type of relationship.
82
*/
83
relationship_t
type
() const noexcept;
84
85
/**
86
* Set id of the diagram element which is the target of this
87
* relationship.
88
*
89
* @param destination Target element id.
90
*/
91
void
set_destination
(
eid_t
destination
);
92
93
/**
94
* Get the id of the target element of this relationship.
95
*
96
* @return Target element id.
97
*/
98
eid_t
destination
() const;
99
100
/**
101
* Set the relationship multiplicity at the source.
102
*
103
* @param multiplicity_source Source multiplicity.
104
*/
105
void
set_multiplicity_source
(const
std
::
string
&
multiplicity_source
);
106
107
/**
108
* Set the relationship multiplicity at the source.
109
*
110
* @return Source multiplicity.
111
*/
112
std
::
string
multiplicity_source
() const;
113
114
/**
115
* Set the relationship multiplicity at the destination.
116
*
117
* @param multiplicity_destination Destination multiplicity.
118
*/
119
void
set_multiplicity_destination
(
120
const
std
::
string
&
multiplicity_destination
);
121
122
/**
123
* Set the relationship multiplicity at the destination.
124
*
125
* @return Destination multiplicity.
126
*/
127
std
::
string
multiplicity_destination
() const;
128
129
/**
130
* Set relationship label.
131
*
132
* @param label Relationship label.
133
*/
134
void
set_label
(const
std
::
string
&
label
);
135
136
/**
137
* Get the relationship label.
138
*
139
* @return Relationoship label.
140
*/
141
std
::
string
label
() const;
142
143
/**
144
* Set the access scope for this relationship (e.g `public`)
145
*
146
* @param scope Access scope
147
*/
148
void
set_access
(
access_t
scope) noexcept;
149
150
/**
151
* Get the relationship access scope (e.g. `public`).
152
*
153
* @return Access scope
154
*/
155
access_t
access
() const noexcept;
156
157
/**
158
* Return true if an extension relationship is virtual.
159
*
160
* @return True if an extension relationship is virtual.
161
*/
162
bool
is_virtual
() const;
163
164
/**
165
* Sets whether an extension relationship is virtual.
166
*
167
* @param iv True, if an extension relationship is virtual.
168
*/
169
void
set_virtual
(
bool
iv);
170
171
friend
bool
operator==(const
relationship
&l, const
relationship
&r);
172
173
private:
174
relationship_t
type_
;
175
eid_t
destination_
;
176
std
::
string
multiplicity_source_
;
177
std
::
string
multiplicity_destination_
;
178
std
::
string
label_
;
179
access_t
access_
;
180
bool
is_virtual_
;
181
};
182
}
// namespace clanguml::common::model
Copyright © 2022-present
Bartek Kryza
Generated by
1.9.7