summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/attribute.h
blob: a9195dd6d200cbbb557f4411dd45138f43eeacd9 (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/***************************************************************************
 *                                                                         *
 *   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) 2002-2006                                               *
 *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
 ***************************************************************************/

#ifndef ATTRIBUTE_H
#define ATTRIBUTE_H

#include "classifierlistitem.h"
#include "umlnamespace.h"
#include "umlclassifierlist.h"

/**
 * This class is used to set up information for an attribute.  This is like
 * a programming attribute.  It has a type, name, visibility and initial value.
 *
 * @short Sets up attribute information.
 * @author Paul Hensgen <phensgen@techie.com>
 * @see UMLObject
 * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
 */
class UMLAttribute : public UMLClassifierListItem {
    Q_OBJECT
  
public:
    /**
     * Sets up an attribute.
     *
     * @param parent    The parent of this UMLAttribute.
     * @param name      The name of this UMLAttribute.
     * @param id        The unique id given to this UMLAttribute.
     * @param s         The visibility of the UMLAttribute.
     * @param type      The type of this UMLAttribute.
     * @param iv        The initial value of the attribute.
     */
    UMLAttribute(const UMLObject *parent, const TQString& name,
                 Uml::IDType id = Uml::id_None,
                 Uml::Visibility s = Uml::Visibility::Private,
                 UMLObject *type = 0, const TQString& iv = 0);

    /**
     * Sets up an attribute.
     *
     * @param parent    The parent of this UMLAttribute.
     */
    UMLAttribute(const UMLObject *parent);

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

    /**
     * destructor.
     */
    virtual ~UMLAttribute();

    /**
     * Copy the internal presentation of this object into the UMLAttribute
     * object.
     */
    virtual void copyInto(UMLAttribute *rhs) const;

    /**
     * Reimplementation of method from UMLObject is required as
     * an extra signal, attributeChanged(), is emitted.
     */
    void setName(const TQString &name);

    /**
     * Reimplementation of method from UMLObject is required as
     * an extra signal, attributeChanged(), is emitted.
     */
    void setVisibility(Uml::Visibility s);

    /**
     * Make a clone of the UMLAttribute.
     */
    virtual UMLObject* clone() const;

    /**
     * Returns The initial value of the UMLAttribute.
     *
     * @return  The initial value of the Atrtibute.
     */
    TQString getInitialValue();

    /**
     * Sets the initial value of the UMLAttribute.
     *
     * @param iv                The initial value of the UMLAttribute.
     */
    void setInitialValue( const TQString &iv );

    /**
     * Returns a string representation of the UMLAttribute.
     *
     * @param sig               If true will show the attribute type and
     *                  initial value.
     * @return  Returns a string representation of the UMLAttribute.
     */
    TQString toString(Uml::Signature_Type sig = Uml::st_NoSig);

    /**
     * Reimplement method from UMLObject.
     */
    TQString getFullyQualifiedName(const TQString& separator = TQString(),
                                  bool includeRoot = false) const;

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

    /**
     * Display the properties configuration dialog for the attribute.
     */
    virtual bool showPropertiesDialog(TQWidget* parent);

    void setParmKind (Uml::Parameter_Direction pk);
    Uml::Parameter_Direction getParmKind () const;

    /**
     * Returns all the template params (if any) that are in the type of this attribute
     */
    virtual UMLClassifierList getTemplateParams();

signals:
    /**
     * Required for informing AssociationWidgets representing this attribute
     * that the attribute name or visibility has changed.
     */
    void attributeChanged();

protected:
    /**
     * Loads the <UML:Attribute> XMI element.
     */
    bool load( TQDomElement & element );

    TQString m_InitialValue; ///< text for the attribute's initial value.
    Uml::Parameter_Direction m_ParmKind;

private:
    /**
    * Puts in the param templateParamList all the template params that are in templateParam
    */
    void setTemplateParams(const TQString& templateParam, UMLClassifierList &templateParamList);

};

#endif