umlcanvasobject.h 3.76 KB
Newer Older
Jonathan Riddell's avatar
Jonathan Riddell committed
1
2
3
4
5
6
/***************************************************************************
 *   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.                                   *
 *                                                                         *
Oliver Kellogg's avatar
Oliver Kellogg committed
7
 *   copyright (C) 2002-2020                                               *
Ralf Habacker's avatar
Ralf Habacker committed
8
 *   Umbrello UML Modeller Authors <umbrello-devel@kde.org>                *
Jonathan Riddell's avatar
Jonathan Riddell committed
9
10
11
12
13
14
 ***************************************************************************/

#ifndef CANVASOBJECT_H
#define CANVASOBJECT_H

#include "umlobject.h"
15
#include "umlobjectlist.h"
16
#include "umlclassifierlist.h"
17
#include "umlassociationlist.h"
Jonathan Riddell's avatar
Jonathan Riddell committed
18
19

/**
20
 * This class contains the non-graphical information required for UMLObjects
21
 * which appear as moveable widgets on the scene.
Jonathan Riddell's avatar
Jonathan Riddell committed
22
 *
23
24
25
26
 * This class inherits from @ref UMLObject which contains most of the
 * information.
 * It is not instantiated itself, it's just used as a super class for
 * actual model objects.
27
28
29
 * It adds a member of type UMLObjectList containing subordinate objects.
 * The subordinate objects could be associations, attributes, operations,
 * or other items depending on the inheriting class.
30
31
32
 *
 * @short Non-graphical information for a UMLCanvasObject.
 * @author Jonathan Riddell
33
 * @see UMLObject
34
 * Bugs and comments to umbrello-devel@kde.org or https://bugs.kde.org
Jonathan Riddell's avatar
Jonathan Riddell committed
35
 */
Andi Fischer's avatar
Andi Fischer committed
36
37
class UMLCanvasObject : public UMLObject
{
Oliver Kellogg's avatar
Oliver Kellogg committed
38
    Q_OBJECT
Andi Fischer's avatar
Andi Fischer committed
39

Andi Fischer's avatar
Andi Fischer committed
40
public:
Andi Fischer's avatar
Andi Fischer committed
41
    explicit UMLCanvasObject(const QString & name = QString(), Uml::ID::Type id = Uml::ID::None);
Oliver Kellogg's avatar
Oliver Kellogg committed
42
43
    virtual ~UMLCanvasObject();

Andi Fischer's avatar
Andi Fischer committed
44
    bool operator==(const UMLCanvasObject& rhs) const;
Oliver Kellogg's avatar
Oliver Kellogg committed
45

46
    virtual void copyInto(UMLObject *lhs) const;
Oliver Kellogg's avatar
Oliver Kellogg committed
47
48
49
50

    // The abstract method UMLObject::clone() is implemented
    // in the classes inheriting from UMLCanvasObject.

51
    bool addAssociationEnd(UMLAssociation* assoc);
Oliver Kellogg's avatar
Oliver Kellogg committed
52
53
54

    bool hasAssociation(UMLAssociation* assoc);

55
    int removeAssociationEnd(UMLAssociation *assoc);
Oliver Kellogg's avatar
Oliver Kellogg committed
56

57
    void removeAllAssociationEnds();
Oliver Kellogg's avatar
Oliver Kellogg committed
58
59
60

    int associations();

61
    UMLAssociationList getAssociations();
Oliver Kellogg's avatar
Oliver Kellogg committed
62

63
    UMLAssociationList getSpecificAssocs(Uml::AssociationType::Enum assocType);
Oliver Kellogg's avatar
Oliver Kellogg committed
64

65
    UMLClassifierList getSuperClasses(bool withRealizations = true);
Oliver Kellogg's avatar
Oliver Kellogg committed
66
67
68
69
70
71
72
73
    UMLClassifierList getSubClasses();

    virtual UMLAssociationList getRealizations();

    UMLAssociationList getAggregations();
    UMLAssociationList getCompositions();
    UMLAssociationList getRelationships();

74
    virtual UMLObject *findChildObject(const QString &n,
75
                                       UMLObject::ObjectType t = UMLObject::ot_UMLObject);
Andi Fischer's avatar
Andi Fischer committed
76
    virtual UMLObject *findChildObjectById(Uml::ID::Type id, bool considerAncestors = false);
Oliver Kellogg's avatar
Oliver Kellogg committed
77

78
    virtual QString uniqChildName(const UMLObject::ObjectType type,
79
                                  const QString &prefix = QString());
Oliver Kellogg's avatar
Oliver Kellogg committed
80

81
82
    virtual void removeAllChildObjects();

83
    UMLObjectList &subordinates() const {
84
        m_List.removeAll(0);
85
86
87
        return m_List;
    }

88
89
    virtual bool resolveRef();

Ralf Habacker's avatar
Ralf Habacker committed
90
    // The abstract method UMLObject::saveToXMI1() is implemented
Oliver Kellogg's avatar
Oliver Kellogg committed
91
    // in the classes inheriting from UMLCanvasObject.
92

93
private:
Jonathan Riddell's avatar
Jonathan Riddell committed
94

Oliver Kellogg's avatar
Oliver Kellogg committed
95
    /**
96
97
98
     * List of all the associations in this object.
     * Inheriting classes add more types of objects that are possible in this list;
     * for example, UMLClassifier adds operations, attributes, and templates.
99
     *
Yuri Chornoivan's avatar
Yuri Chornoivan committed
100
     * @todo Only a pointer to the appropriate association end object
101
     *       (UMLRole) should be saved here, not the entire UMLAssociation.
Oliver Kellogg's avatar
Oliver Kellogg committed
102
     */
103
    mutable UMLObjectList m_List;
Jonathan Riddell's avatar
Jonathan Riddell committed
104

105
signals:
106

107
108
    void sigAssociationEndAdded(UMLAssociation * assoc);
    void sigAssociationEndRemoved(UMLAssociation * assoc);
109

Jonathan Riddell's avatar
Jonathan Riddell committed
110
111
112
};

#endif