summaryrefslogtreecommitdiffstats
path: root/umbrello/umbrello/package.h
blob: 32495d872fb86e600301da65e11cac14823f93cf (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
/***************************************************************************
 *                                                                         *
 *   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 PACKAGE_H
#define PACKAGE_H

#include "umlcanvasobject.h"
#include "umlclassifierlist.h"

// forward declarations
class UMLAssociation;


/**
 * This class contains the non-graphical information required for a UML
 * Package.
 * This class inherits from @ref UMLCanvasObject which contains most of the
 * information.
 *
 * @short Non-graphical information for a Package.
 * @author Jonathan Riddell
 * @see UMLCanvasObject
 * Bugs and comments to uml-devel@lists.sf.net or http://bugs.kde.org
 */

class UMLPackage : public UMLCanvasObject {
    Q_OBJECT
  
public:
    /**
     * Sets up a Package.
     *
     * @param name              The name of the Concept.
     * @param id                The unique id of the Concept.
     */
    explicit UMLPackage(const TQString & name = "", Uml::IDType id = Uml::id_None);

    /**
     * Empty deconstructor.
     */
    virtual ~UMLPackage();

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

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

    /**
     * Initializes key variables of the class.
     */
    void init();

    /**
     * Adds an object in this package.
     *
     * @param pObject   Pointer to the UMLObject to add.
     * @return    True if the object was actually added.
     */
    bool addObject(UMLObject *pObject);

    /**
     * Removes an object from this package.
     * Does not physically delete the object.
     *
     * @param pObject   Pointer to the UMLObject to be removed.
     */
    void removeObject(UMLObject *pObject);

    /**
     * Removes all objects from this package.
     * Inner containers (e.g. nested packages) are removed recursively.
     */
    virtual void removeAllObjects();

    /**
     * Returns the list of objects contained in this package.
     */
    UMLObjectList containedObjects();

    /**
     * Adds an existing association to the matching concept in the list of concepts.
     * The selection of the matching concept depends on the association type:
     * For generalizations, the assoc is added to the concept that matches role A.
     * For aggregations and compositions , the assoc is added to the concept
     * that matches role B.
     *
     * @param assoc     The association to add
     */
    void addAssocToConcepts(UMLAssociation* assoc);

    /**
     * Remove the association from the participating concepts.
     */
    void removeAssocFromConcepts(UMLAssociation *assoc);

    /**
     * Find the object of the given name in the list of contained objects.
     *
     * @param name              The name to seek.
     * @return  Pointer to the UMLObject found or NULL if not found.
     */
    UMLObject * findObject(const TQString &name);

    /**
     * Find the object of the given ID in the list of contained objects.
     *
     * @param id                The ID to seek.
     * @return  Pointer to the UMLObject found or NULL if not found.
     */
    UMLObject * findObjectById(Uml::IDType id);

    /**
     * Append all classifiers from this package (and those from
     * nested packages) to the given UMLClassifierList.
     *
     * @param classifiers               The list to append to.
     * @param includeNested             Whether to include the classifiers from
     *                          nested packages (default: true.)
     */
    void appendClassifiers( UMLClassifierList& classifiers,
                            bool includeNested = true );

    /**
     * Append all classes from this package (and those from
     * nested packages) to the given UMLClassifierList.
     *
     * @param classes           The list to append to.
     * @param includeNested             Whether to include the classes from
     *                          nested packages (default: true.)
     */
    void appendClasses( UMLClassifierList& classes, bool includeNested = true );

    /**
     * Append all classes and interfaces from this package (and those
     * from nested packages) to the given UMLClassifierList.
     *
     * @param classifiers               The list to append to.
     * @param includeNested             Whether to include the classifiers from
     *                          nested packages (default: true.)
     */
    void appendClassesAndInterfaces(UMLClassifierList& classifiers,
                                    bool includeNested = true);

    /**
     * Append all interfaces from this package (and those from
     * nested packages) to the given UMLClassifierList.
     *
     * @param interfaces                The list to append to.
     * @param includeNested             Whether to include the interfaces from
     *                          nested packages (default: true.)
     */
    void appendInterfaces(UMLClassifierList& interfaces,
                          bool includeNested = true );

    /**
     * Resolve types. Required when dealing with foreign XMI files.
     * Needs to be called after all UML objects are loaded from file.
     * Overrides the method from UMLObject.
     * Calls resolveRef() on each contained object.
     *
     * @return  True for overall success.
     */
    virtual bool resolveRef();

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

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

    /**
     * References to the objects contained in this package.
     * The UMLPackage is the owner of the objects.
     */
    UMLObjectList m_objects;

};

#endif