1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 Jochen Becher
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of Qt Creator.
7 **
8 ** Commercial License Usage
9 ** Licensees holding valid commercial Qt licenses may use this file in
10 ** accordance with the commercial license agreement provided with the
11 ** Software or, alternatively, in accordance with the terms contained in
12 ** a written agreement between you and The Qt Company. For licensing terms
13 ** and conditions see https://www.qt.io/terms-conditions. For further
14 ** information use the contact form at https://www.qt.io/contact-us.
15 **
16 ** GNU General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU
18 ** General Public License version 3 as published by the Free Software
19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
20 ** included in the packaging of this file. Please review the following
21 ** information to ensure the GNU General Public License requirements will
22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
23 **
24 ****************************************************************************/
25 
26 #include "massociation.h"
27 
28 #include "mvisitor.h"
29 #include "mconstvisitor.h"
30 
31 namespace qmt {
32 
MAssociationEnd()33 MAssociationEnd::MAssociationEnd()
34 {
35 }
36 
MAssociationEnd(const MAssociationEnd & rhs)37 MAssociationEnd::MAssociationEnd(const MAssociationEnd &rhs)
38     : m_name(rhs.m_name),
39       m_cardinality(rhs.m_cardinality),
40       m_kind(rhs.m_kind),
41       m_isNavigable(rhs.m_isNavigable)
42 {
43 }
44 
~MAssociationEnd()45 MAssociationEnd::~MAssociationEnd()
46 {
47 }
48 
operator =(const MAssociationEnd & rhs)49 MAssociationEnd &MAssociationEnd::operator =(const MAssociationEnd &rhs)
50 {
51     if (this != &rhs) {
52         m_name = rhs.m_name;
53         m_cardinality = rhs.m_cardinality;
54         m_kind = rhs.m_kind;
55         m_isNavigable = rhs.m_isNavigable;
56     }
57     return *this;
58 }
59 
setName(const QString & name)60 void MAssociationEnd::setName(const QString &name)
61 {
62     m_name = name;
63 }
64 
setCardinality(const QString & cardinality)65 void MAssociationEnd::setCardinality(const QString &cardinality)
66 {
67     m_cardinality = cardinality;
68 }
69 
setKind(MAssociationEnd::Kind kind)70 void MAssociationEnd::setKind(MAssociationEnd::Kind kind)
71 {
72     m_kind = kind;
73 }
74 
setNavigable(bool navigable)75 void MAssociationEnd::setNavigable(bool navigable)
76 {
77     m_isNavigable = navigable;
78 }
79 
operator ==(const MAssociationEnd & lhs,const MAssociationEnd & rhs)80 bool operator==(const MAssociationEnd &lhs, const MAssociationEnd &rhs)
81 {
82     return lhs.name() == rhs.name()
83             && lhs.cardinality() == rhs.cardinality()
84             && lhs.kind() == rhs.kind()
85             && lhs.isNavigable() == rhs.isNavigable();
86 }
87 
MAssociation()88 MAssociation::MAssociation()
89     : MRelation(),
90       m_associationClassUid(Uid::invalidUid())
91 {
92 }
93 
~MAssociation()94 MAssociation::~MAssociation()
95 {
96 }
97 
setEndA(const MAssociationEnd & end)98 void MAssociation::setEndA(const MAssociationEnd &end)
99 {
100     m_endA = end;
101 }
102 
setEndB(const MAssociationEnd & end)103 void MAssociation::setEndB(const MAssociationEnd &end)
104 {
105     m_endB = end;
106 }
107 
setAssociationClassUid(const Uid & uid)108 void MAssociation::setAssociationClassUid(const Uid &uid)
109 {
110     m_associationClassUid = uid;
111 }
112 
accept(MVisitor * visitor)113 void MAssociation::accept(MVisitor *visitor)
114 {
115     visitor->visitMAssociation(this);
116 }
117 
accept(MConstVisitor * visitor) const118 void MAssociation::accept(MConstVisitor *visitor) const
119 {
120     visitor->visitMAssociation(this);
121 }
122 
123 } // namespace qmt
124