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 #pragma once 27 28 #include "mrelation.h" 29 #include "qmt/infrastructure/handle.h" 30 31 #include <QString> 32 33 namespace qmt { 34 35 class MClass; 36 37 class QMT_EXPORT MAssociationEnd 38 { 39 public: 40 enum Kind { 41 Association, 42 Aggregation, 43 Composition 44 }; 45 46 MAssociationEnd(); 47 MAssociationEnd(const MAssociationEnd &rhs); 48 ~MAssociationEnd(); 49 50 MAssociationEnd &operator=(const MAssociationEnd &rhs); 51 name()52 QString name() const { return m_name; } 53 void setName(const QString &name); cardinality()54 QString cardinality() const { return m_cardinality; } 55 void setCardinality(const QString &cardinality); kind()56 Kind kind() const { return m_kind; } 57 void setKind(Kind kind); isNavigable()58 bool isNavigable() const { return m_isNavigable; } 59 void setNavigable(bool navigable); 60 61 private: 62 QString m_name; 63 QString m_cardinality; 64 Kind m_kind = Association; 65 bool m_isNavigable = false; 66 }; 67 68 bool operator==(const MAssociationEnd &lhs, const MAssociationEnd &rhs); 69 inline bool operator!=(const MAssociationEnd &lhs, const MAssociationEnd &rhs) 70 { 71 return !(lhs == rhs); 72 } 73 74 class QMT_EXPORT MAssociation : public MRelation 75 { 76 public: 77 MAssociation(); 78 ~MAssociation() override; 79 endA()80 MAssociationEnd endA() const { return m_endA; } 81 void setEndA(const MAssociationEnd &end); endB()82 MAssociationEnd endB() const { return m_endB; } 83 void setEndB(const MAssociationEnd &end); assoicationClassUid()84 Uid assoicationClassUid() const { return m_associationClassUid; } 85 void setAssociationClassUid(const Uid &uid); 86 87 void accept(MVisitor *visitor) override; 88 void accept(MConstVisitor *visitor) const override; 89 90 private: 91 MAssociationEnd m_endA; 92 MAssociationEnd m_endB; 93 Uid m_associationClassUid; 94 }; 95 96 } // namespace qmt 97