1 /* 2 SPDX-License-Identifier: GPL-2.0-or-later 3 SPDX-FileCopyrightText: 2003-2020 Umbrello UML Modeller Authors <umbrello-devel@kde.org> 4 */ 5 6 #ifndef ASSOCIATION_H 7 #define ASSOCIATION_H 8 9 #include "basictypes.h" 10 #include "umlobject.h" 11 12 #include <QDomDocument> 13 #include <QDomElement> 14 #include <QXmlStreamWriter> 15 16 class UMLRole; 17 18 /** 19 * This class contains the non-graphic representation of an association. 20 * An association can be a generalization, realization, simple association, 21 * directed association, aggregation, or composition. 22 * 23 * @short Sets up association information. 24 * @author Oliver Kellogg <okellogg@users.sourceforge.net> 25 * @see UMLObject 26 * Bugs and comments to umbrello-devel@kde.org or https://bugs.kde.org 27 */ 28 class UMLAssociation : public UMLObject 29 { 30 Q_OBJECT 31 friend class AssociationWidget; 32 33 public: 34 UMLAssociation(Uml::AssociationType::Enum type, UMLObject *roleA, UMLObject *roleB); 35 explicit UMLAssociation(Uml::AssociationType::Enum type = Uml::AssociationType::Unknown); 36 37 virtual ~UMLAssociation(); 38 39 bool operator==(const UMLAssociation &rhs) const; 40 41 QString toString() const; 42 43 UMLRole * getUMLRole(Uml::RoleType::Enum role) const; 44 Uml::ID::Type getObjectId(Uml::RoleType::Enum role) const; 45 Uml::ID::Type getRoleId(Uml::RoleType::Enum role) const; 46 47 void setAssociationType(Uml::AssociationType::Enum assocType); 48 Uml::AssociationType::Enum getAssocType() const; 49 50 void setObject(UMLObject *obj, Uml::RoleType::Enum role); 51 UMLObject* getObject(Uml::RoleType::Enum role) const; 52 53 void setVisibility(Uml::Visibility::Enum value, Uml::RoleType::Enum role); 54 Uml::Visibility::Enum visibility(Uml::RoleType::Enum role) const; 55 56 void setChangeability(Uml::Changeability::Enum value, Uml::RoleType::Enum role); 57 Uml::Changeability::Enum changeability(Uml::RoleType::Enum role) const; 58 59 void setMultiplicity(const QString &multi, Uml::RoleType::Enum role); 60 QString getMultiplicity(Uml::RoleType::Enum role) const; 61 62 void setRoleName(const QString &roleName, Uml::RoleType::Enum role); 63 QString getRoleName(Uml::RoleType::Enum role) const; 64 65 void setRoleDoc(const QString &doc, Uml::RoleType::Enum role); 66 QString getRoleDoc(Uml::RoleType::Enum role) const; 67 68 void setOldLoadMode(bool value = true); 69 bool getOldLoadMode() const; 70 clone()71 virtual UMLObject* clone() const { return 0; } 72 73 virtual bool resolveRef(); 74 75 void saveToXMI1(QXmlStreamWriter& writer); 76 77 virtual bool showPropertiesDialog(QWidget *parent = 0); 78 79 protected: 80 81 bool load1(QDomElement& element); 82 83 // keep track of number of parent widgets 84 int nrof_parent_widgets; 85 86 void init(Uml::AssociationType::Enum type, UMLObject *roleAObj, UMLObject *roleBObj); 87 88 UMLRole * m_pRole[2]; 89 Uml::AssociationType::Enum m_AssocType; 90 QString m_Name; 91 bool m_bOldLoadMode; 92 93 private: 94 95 bool isRealization(UMLObject* objA, UMLObject* objB) const; 96 }; 97 98 #endif 99