summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/operation.h
blob: 044045720890992664a579e0e54ae6c6a9a47d09 (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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/***************************************************************************
 *                                                                         *
 *   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 OPERATION_H
#define OPERATION_H

#include "umlattributelist.h"
#include "classifierlistitem.h"

class UMLClassifier;

/**
 * This class represents an operation in the UML model.
 *
 * Bugs and comments to uml-devel@lists.sf.net or http://bugs.trinitydesktop.org
 */
class UMLOperation : public UMLClassifierListItem {
    Q_OBJECT
  
public:
    /**
     * Constructs an UMLOperation.
     * Not intended for general use: The operation is not tied in with
     * umbrello's TQt signalling for object creation.
     * If you want to create an Operation use the method in UMLDoc instead.
     *
     * @param parent    The parent to this operation.
     * @param name      The name of the operation.
     * @param id        The id of the operation.
     * @param s         The visibility of the operation.
     * @param rt        The return type of the operation.
     */
    UMLOperation(const UMLClassifier * parent, const TQString& name,
                 Uml::IDType id = Uml::id_None,
                 Uml::Visibility s = Uml::Visibility::Public,
                 UMLObject *rt = 0);

    /**
     * Constructs an UMLOperation.
     * Not intended for general use: The operation is not tied in with
     * umbrello's TQt signalling for object creation.
     * If you want to create an Operation use the method in UMLDoc instead.
     *
     * @param parent    The parent to this operation.
     */
    UMLOperation(const UMLClassifier * parent);
public:

    /**
     * destructor
     */
    virtual ~UMLOperation();

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

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

    /**
     * Make a clone of this object.
     */
    virtual UMLObject* clone() const;

    /**
     * Reimplement method from UMLClassifierListItem.
     *
     * @param type      Pointer to the type object.
     */
    void setType(UMLObject *type);

    /**
     * Move a parameter one position to the left.
     *
     * @param a         The parameter to move.
     */
    void moveParmLeft(UMLAttribute *a);

    /**
     *Move a parameter one position to the right.
     *
     * @param a         The parameter to move.
     */
    void moveParmRight(UMLAttribute *a);

    /**
     * Remove a parameter from the operation.
     *
     * @param a         The parameter to remove.
     * @param emitModifiedSignal  Whether to emit the "modified" signal
     *                  which creates an entry in the Undo stack for the
     *                  removal. Default: true.
     */
    void removeParm(UMLAttribute *a, bool emitModifiedSignal = true);

    /**
     * Returns a list of parameters.
     *
     * @return A list of the parameters in the operation.
     */
    UMLAttributeList getParmList() {
        return m_List;
    }

    /**
     * Finds a parameter of the operation.
     *
     * @param name      The parameter name to search for.
     * @return  The found parameter, 0 if not found.
     */
    UMLAttribute * findParm(const TQString &name);

    /**
     * Returns a string representation of the operation.
     *
     * @param sig       What type of operation string to show.
     * @return  The string representation of the operation.
     */
    TQString toString(Uml::Signature_Type sig = Uml::st_NoSig);

    /**
     * Add a parameter to the operation.
     *
     * @param parameter The parameter to add.
     * @param position  The position in the parameter list.
     *                  If position = -1 the parameter will be
     *                  appended to the list.
     */
    void addParm(UMLAttribute *parameter, int position = -1);

    /**
     * Calls resolveRef() on all parameters.
     * Needs to be called after all UML objects are loaded from file.
     *
     * @return  True for success.
     */
    bool resolveRef();

    /**
     * Returns an unused parameter name for a new parameter.
     */
    TQString getUniqueParameterName();

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

    /**
     * Returns whether this operation is a constructor.
     *
     * @return  True if this operation is a constructor.
     */
    bool isConstructorOperation();

    /**
     * Returns whether this operation is a destructor.
     *
     * @return  True if this operation is a destructor.
     */
    bool isDestructorOperation();

    /**
     * Shortcut for (isConstructorOperation() || isDestructorOperation())
     *
     * @return  True if this operation is a constructor or destructor.
     */
    bool isLifeOperation();

    /**
     * Sets whether this operation is a query (C++ "const".)
     */
    void setConst(bool b);

    /**
     * Returns whether this operation is a query (C++ "const".)
     */
    bool getConst() const;

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

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

private:
    Uml::IDType m_returnId;   ///< Holds the xmi.id of the <UML:Parameter kind="return">
    UMLAttributeList m_List;   /// Parameter list
    bool m_bConst;   ///< Holds the isQuery attribute of the <UML:Operation>
};

#endif