summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/umlrole.h
blob: 4d750751b735e3b8f4da4cf2272a39821634620b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   copyright (C) 2003-2006                                               *
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
 ***************************************************************************/

#ifndef UMLROLE_H
#define UMLROLE_H

#include "umlobject.h"

class UMLAssociation;

/**
 * This class contains the non-graphic representation of an association role.
 *
 * @author Brian Thomas <brian.thomas@gsfc.nasa.gov>
 * @see UMLObject
 */

class UMLRole : public UMLObject {
    Q_OBJECT
  TQ_OBJECT
public:
    /**
     * Sets up an association.
     *
     * @param tqparent    The tqparent (association) of this UMLRole.
     * @param tqparentUMLObject The Parent UML Object of this UMLRole
     * @param role  The Uml::Role_Type of this UMLRole 
     */
    UMLRole (UMLAssociation * tqparent, UMLObject * tqparentUMLObject, Uml::Role_Type role);

    /**
     * Overloaded '==' operator
     */
    bool operator==(UMLRole & rhs);

    /**
     * Standard deconstructor.
     */
    virtual ~UMLRole();

    /**
     * Returns the UMLObject assigned to the role.
     * @return  Pointer to the UMLObject in role.
     */
    UMLObject* getObject();

    /**
     * Returns the Changeablity of the role.
     *
     * @return  Changeability_Type of role.
     */
    Uml::Changeability_Type getChangeability() const;

    /**
     * Returns the multiplicity assigned to the role.
     *
     * @return  The multiplicity assigned to the role.
     */
    TQString getMultiplicity() const;

    /**
     * Sets the UMLObject playing the role in the association.
     *
     * @param obj               Pointer to the UMLObject of role.
     */
    void setObject(UMLObject *obj);

    /**
     * Sets the changeability of the role.
     *
     * @param value     Changeability_Type of role changeability.
     */
    void setChangeability (Uml::Changeability_Type value);

    /**
     * Sets the multiplicity of the role.
     *
     * @param multi             The multiplicity of role.
     */
    void setMultiplicity ( const TQString &multi );

    UMLAssociation * getParentAssociation ();

    /** get the 'id' of the role (NOT the tqparent object). This could be
     * either Uml::A or Uml::B. Yes, it would be better if we
     * could get along without this, but we need it to distinguish saved
     * umlrole objects in the XMI for 'self' associations where both roles
     * will point to the same underlying UMLObject.
     */
    Uml::Role_Type getRole();

    /**
     * Make a clone of this object.
     * Not yet implemented.
     */
    UMLObject* clone() const { return NULL; }

    /**
     * Creates the <UML:AssociationEnd> XMI element.
     */
    void saveToXMI(TQDomDocument& qDoc, TQDomElement& qElement);

protected:
    /**
     * Loads the <UML:AssociationEnd> XMI element.
     * Auxiliary to UMLObject::loadFromXMI.
     */
    bool load(TQDomElement& element);

private:

    /** do some initialization at construction time */
    void init (UMLAssociation * tqparent, UMLObject * tqparentObj, Uml::Role_Type r);

    UMLAssociation * m_pAssoc;
    Uml::Role_Type m_role;
    TQString m_Multi;
    Uml::Changeability_Type m_Changeability;
};

#endif