umbrello: umbrello/umlmodel/classifier.h Source File

umbrello 25.04.0 Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology

classifier.h
Go to the documentation of this file.
1/*
2 SPDX-License-Identifier: GPL-2.0-or-later
3 SPDX-FileCopyrightText: 2002-2021 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
4*/
5#ifndef CLASSIFIER_H
6#define CLASSIFIER_H
7
8#include "package.h"
9#include "umlattributelist.h"
10#include "umloperationlist.h"
11#include "umlclassifierlistitemlist.h"
12#include "classifierlistitem.h"
13#include "umltemplatelist.h"
14#include "model_utils.h"
15
16// forward declarations
17class UMLAssociation;
18class IDChangeLog;
19class UMLClassifierSet;
20
34 class UMLClassifier : public UMLPackage
35{
36 Q_OBJECT
37public:
38
42 enum ClassifierType { ALL = 0, CLASS, INTERFACE, DATATYPE };
43
44 explicit UMLClassifier(const QString & name = QString(), Uml::ID::Type id = Uml::ID::None);
45 virtual ~UMLClassifier();
46
47 virtual void copyInto(UMLObject *lhs) const;
48
49 UMLObject* clone() const;
50
51 virtual void setNameCmd(const QString &strName);
52
53 virtual UMLAttribute* createAttribute(const QString &name = QString(),
54 UMLObject *type = nullptr,
55 Uml::Visibility::Enum vis = Uml::Visibility::Private,
56 const QString &init = QString());
57
58 UMLAttribute* addAttribute(const QString &name, Uml::ID::Type id = Uml::ID::None);
59 UMLAttribute* addAttribute(const QString &name, UMLObject *type, Uml::Visibility::Enum scope);
60
61 bool addAttribute(UMLAttribute *att, IDChangeLog *log = nullptr,
62 int position = -1);
63
64 int removeAttribute(UMLAttribute *att);
65
66 UMLAttributeList getAttributeList() const;
67 UMLAttributeList getAttributeList(Uml::Visibility::Enum scope) const;
68 UMLAttributeList getAttributeListStatic(Uml::Visibility::Enum scope) const;
69
70 UMLOperation* createOperation(const QString &name = QString(),
71 bool *isExistingOp = nullptr,
72 Model_Utils::NameAndType_List *params = nullptr);
73
74 bool addOperation(UMLOperation* op, int position = -1);
75 bool addOperation(UMLOperation* op, IDChangeLog* log);
76
77 UMLOperation * checkOperationSignature(const QString& name,
78 UMLAttributeList opParams,
79 UMLOperation *exemptOp = nullptr) const;
80
81 int removeOperation(UMLOperation *op);
82
83 int operations() const;
84
85 UMLOperationList getOpList(bool includeInherited = false, UMLClassifierSet *alreadyTraversed = nullptr) const;
86
87 UMLObject* createTemplate(const QString& name = QString());
88
89 UMLTemplate* addTemplate(const QString &name, Uml::ID::Type id = Uml::ID::None);
90
91 bool addTemplate(UMLTemplate *newTemplate, IDChangeLog *log = nullptr);
92 bool addTemplate(UMLTemplate* templt, int position);
93
94 int removeTemplate(UMLTemplate* umltemplate);
95
96 UMLTemplate *findTemplate(const QString& name) const;
97
98 int templates() const;
99
100 UMLTemplateList getTemplateList() const;
101
102 int takeItem(UMLClassifierListItem* item);
103
104 virtual UMLClassifierListItemList getFilteredList(UMLObject::ObjectType ot) const;
105
106 virtual bool resolveRef();
107
108 UMLOperationList findOperations(const QString &n) const;
109
110 virtual UMLObject* findChildObjectById(Uml::ID::Type id,
111 bool considerAncestors = false) const;
112
113 UMLOperation* findOperation(const QString& name,
114 Model_Utils::NameAndType_List params) const;
115
116 UMLClassifierList findSuperClassConcepts(ClassifierType type = ALL) const;
117
118 UMLClassifierList findSubClassConcepts(ClassifierType type = ALL) const;
119
120 virtual bool acceptAssociationType(Uml::AssociationType::Enum type) const;
121
122 void setBaseType(UMLObject::ObjectType ot);
123
124 bool isInterface() const;
125
126 bool hasAbstractOps() const;
127 bool hasAssociations() const;
128 bool hasAttributes() const;
129 bool hasStaticAttributes() const;
130 bool hasMethods() const;
131 bool hasAccessorMethods() const;
132 bool hasOperationMethods() const;
133 bool hasVectorFields() const;
134
140// UMLClassifierList getPlainAssocChildClassifierList();
141// UMLClassifierList getAggregateChildClassifierList();
142// UMLClassifierList getCompositionChildClassifierList();
143
144 virtual UMLClassifierListItem* makeChildObject(const QString& xmiTag);
145
146 void removeObject(UMLObject *pObject);
147
148 virtual UMLAssociationList getUniAssociationToBeImplemented() const;
149
150Q_SIGNALS:
151
152 void operationAdded(UMLClassifierListItem *);
153 void operationRemoved(UMLClassifierListItem *);
154
155 void templateAdded(UMLClassifierListItem*);
156 void templateRemoved(UMLClassifierListItem*);
157
158 // only applies when (m_Type == ot_Class)
159 void attributeAdded(UMLClassifierListItem*);
160 void attributeRemoved(UMLClassifierListItem*);
161
162private:
163
164 UMLAssociation *m_pClassAssoc;
165
172// UMLClassifierList findAssocClassifierObjsInRoles (UMLAssociationList * list);
173
174protected:
175
176 void saveToXMI(QXmlStreamWriter& writer);
177
178 virtual bool load1(QDomElement& element);
179
180};
181
182#endif // CLASSIFIER_H
IDChangeLog
Definition idchangelog.h:22
UMLAssociation
Sets up association information.
Definition association.h:29
UMLAttributeList
Definition umlattributelist.h:21
UMLAttribute
Sets up attribute information.
Definition attribute.h:23
UMLClassifierListItemList
Definition umlclassifierlistitemlist.h:22
UMLClassifierListItem
A base class for classifier list items (e.g. attributes)
Definition classifierlistitem.h:25
UMLClassifierSet
holds set of classifiers for recursive loop detection
Definition classifier.cpp:48
UMLClassifier::hasVectorFields
bool hasVectorFields() const
Definition classifier.cpp:1310
UMLClassifier::addAttribute
UMLAttribute * addAttribute(const QString &name, Uml::ID::Type id=Uml::ID::None)
Definition classifier.cpp:810
UMLClassifier::saveToXMI
void saveToXMI(QXmlStreamWriter &writer)
Definition classifier.cpp:1354
UMLClassifier::clone
UMLObject * clone() const
Definition classifier.cpp:657
UMLClassifier::removeObject
void removeObject(UMLObject *pObject)
Definition classifier.cpp:1488
UMLClassifier::takeItem
int takeItem(UMLClassifierListItem *item)
Definition classifier.cpp:1169
UMLClassifier::addTemplate
UMLTemplate * addTemplate(const QString &name, Uml::ID::Type id=Uml::ID::None)
Definition classifier.cpp:1025
UMLClassifier::resolveRef
virtual bool resolveRef()
Definition classifier.cpp:691
UMLClassifier::isInterface
bool isInterface() const
Definition classifier.cpp:116
UMLClassifier::operationRemoved
void operationRemoved(UMLClassifierListItem *)
UMLClassifier::load1
virtual bool load1(QDomElement &element)
Definition classifier.cpp:1513
UMLClassifier::hasAbstractOps
bool hasAbstractOps() const
Definition classifier.cpp:909
UMLClassifier::getAttributeList
UMLAttributeList getAttributeList() const
Definition classifier.cpp:435
UMLClassifier::hasAssociations
bool hasAssociations() const
Definition classifier.cpp:1248
UMLClassifier::hasMethods
bool hasMethods() const
Definition classifier.cpp:1298
UMLClassifier::templates
int templates() const
Definition classifier.cpp:1136
UMLClassifier::makeChildObject
virtual UMLClassifierListItem * makeChildObject(const QString &xmiTag)
Definition classifier.cpp:1461
UMLClassifier::getTemplateList
UMLTemplateList getTemplateList() const
Definition classifier.cpp:1149
UMLClassifier::addOperation
bool addOperation(UMLOperation *op, int position=-1)
Definition classifier.cpp:308
UMLClassifier::m_pClassAssoc
UMLAssociation * m_pClassAssoc
Definition classifier.h:164
UMLClassifier::setNameCmd
virtual void setNameCmd(const QString &strName)
Definition classifier.cpp:668
UMLClassifier::hasStaticAttributes
bool hasStaticAttributes() const
Definition classifier.cpp:1272
UMLClassifier::UMLClassifier
UMLClassifier(const QString &name=QString(), Uml::ID::Type id=Uml::ID::None)
Definition classifier.cpp:62
UMLClassifier::operationAdded
void operationAdded(UMLClassifierListItem *)
UMLClassifier::findChildObjectById
virtual UMLObject * findChildObjectById(Uml::ID::Type id, bool considerAncestors=false) const
Definition classifier.cpp:545
UMLClassifier::acceptAssociationType
virtual bool acceptAssociationType(Uml::AssociationType::Enum type) const
Definition classifier.cpp:726
UMLClassifier::createTemplate
UMLObject * createTemplate(const QString &name=QString())
Definition classifier.cpp:392
UMLClassifier::~UMLClassifier
virtual ~UMLClassifier()
Definition classifier.cpp:72
UMLClassifier::removeTemplate
int removeTemplate(UMLTemplate *umltemplate)
Definition classifier.cpp:1103
UMLClassifier::setBaseType
void setBaseType(UMLObject::ObjectType ot)
Definition classifier.cpp:81
UMLClassifier::findSubClassConcepts
UMLClassifierList findSubClassConcepts(ClassifierType type=ALL) const
Definition classifier.cpp:570
UMLClassifier::removeAttribute
int removeAttribute(UMLAttribute *att)
Definition classifier.cpp:893
UMLClassifier::hasOperationMethods
bool hasOperationMethods() const
Definition classifier.cpp:1290
UMLClassifier::findTemplate
UMLTemplate * findTemplate(const QString &name) const
Definition classifier.cpp:1120
UMLClassifier::hasAttributes
bool hasAttributes() const
Definition classifier.cpp:1259
UMLClassifier::copyInto
virtual void copyInto(UMLObject *lhs) const
Definition classifier.cpp:642
UMLClassifier::operations
int operations() const
Definition classifier.cpp:926
UMLClassifier::getAttributeListStatic
UMLAttributeList getAttributeListStatic(Uml::Visibility::Enum scope) const
Definition classifier.cpp:486
UMLClassifier::attributeAdded
void attributeAdded(UMLClassifierListItem *)
UMLClassifier::ClassifierType
ClassifierType
Definition classifier.h:42
UMLClassifier::ALL
@ ALL
Definition classifier.h:42
UMLClassifier::DATATYPE
@ DATATYPE
Definition classifier.h:42
UMLClassifier::INTERFACE
@ INTERFACE
Definition classifier.h:42
UMLClassifier::CLASS
@ CLASS
Definition classifier.h:42
UMLClassifier::getOpList
UMLOperationList getOpList(bool includeInherited=false, UMLClassifierSet *alreadyTraversed=nullptr) const
Definition classifier.cpp:939
UMLClassifier::getUniAssociationToBeImplemented
virtual UMLAssociationList getUniAssociationToBeImplemented() const
Definition classifier.cpp:1318
UMLClassifier::findOperation
UMLOperation * findOperation(const QString &name, Model_Utils::NameAndType_List params) const
Definition classifier.cpp:177
UMLClassifier::findOperations
UMLOperationList findOperations(const QString &n) const
Definition classifier.cpp:521
UMLClassifier::removeOperation
int removeOperation(UMLOperation *op)
Definition classifier.cpp:369
UMLClassifier::templateAdded
void templateAdded(UMLClassifierListItem *)
UMLClassifier::templateRemoved
void templateRemoved(UMLClassifierListItem *)
UMLClassifier::findSuperClassConcepts
UMLClassifierList findSuperClassConcepts(ClassifierType type=ALL) const
Definition classifier.cpp:609
UMLClassifier::createAttribute
virtual UMLAttribute * createAttribute(const QString &name=QString(), UMLObject *type=nullptr, Uml::Visibility::Enum vis=Uml::Visibility::Private, const QString &init=QString())
Definition classifier.cpp:756
UMLClassifier::attributeRemoved
void attributeRemoved(UMLClassifierListItem *)
UMLClassifier::hasAccessorMethods
bool hasAccessorMethods() const
Definition classifier.cpp:1282
UMLClassifier::checkOperationSignature
UMLOperation * checkOperationSignature(const QString &name, UMLAttributeList opParams, UMLOperation *exemptOp=nullptr) const
Definition classifier.cpp:132
UMLClassifier::getFilteredList
virtual UMLClassifierListItemList getFilteredList(UMLObject::ObjectType ot) const
Definition classifier.cpp:999
UMLClassifier::createOperation
UMLOperation * createOperation(const QString &name=QString(), bool *isExistingOp=nullptr, Model_Utils::NameAndType_List *params=nullptr)
Definition classifier.cpp:234
UMLObject
The base class for UML objects.
Definition umlobject.h:70
UMLObject::ObjectType
ObjectType
Definition umlobject.h:76
UMLObject::init
void init()
Definition umlobject.cpp:122
UMLObject::name
QString name() const
Definition umlobject.cpp:207
UMLOperation
Definition operation.h:20
UMLPackage::UMLPackage
UMLPackage(const QString &name=QString(), Uml::ID::Type id=Uml::ID::None)
Definition package.cpp:38
UMLTemplate
Sets up template information.
Definition template.h:22
classifierlistitem.h
model_utils.h
Model_Utils::NameAndType_List
QList< NameAndType > NameAndType_List
Auxiliary type for OpDescriptor.
Definition model_utils.h:124
Uml::AssociationType::Enum
Enum
Definition basictypes.h:92
Uml::ID::None
const Type None
special value for uninitialized ID
Definition basictypes.h:373
Uml::ID::Type
std::string Type
Definition basictypes.h:371
Uml::Visibility::Enum
Enum
Definition basictypes.h:45
Uml::Visibility::Private
@ Private
Definition basictypes.h:47
package.h
UMLAssociationList
QList< UMLAssociation * > UMLAssociationList
Definition umlassociationlist.h:14
umlattributelist.h
UMLClassifierList
QList< UMLClassifier * > UMLClassifierList
Definition umlclassifierlist.h:14
umlclassifierlistitemlist.h
umloperationlist.h
UMLOperationList
QList< UMLOperation * > UMLOperationList
Definition umloperationlist.h:14
umltemplatelist.h
UMLTemplateList
QList< UMLTemplate * > UMLTemplateList
Definition umltemplatelist.h:15