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

classifiercodedocument.h
Go to the documentation of this file.
1 /***************************************************************************
2 * This program is free software; you can redistribute it and/or modify *
3 * it under the terms of the GNU General Public License as published by *
4 * the Free Software Foundation; either version 2 of the License, or *
5 * (at your option) any later version. *
6 * *
7 * copyright (C) 2003 Brian Thomas <thomas@mail630.gsfc.nasa.gov> *
8 * copyright (C) 2004-2020 *
9 * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
10 ***************************************************************************/
11
12 #ifndef CLASSIFIERCODEDOCUMENT_H
13 #define CLASSIFIERCODEDOCUMENT_H
14
15 #include "classifier.h"
16 #include "codeaccessormethod.h"
17 #include "codedocument.h"
18 #include "codeoperation.h"
19 #include "codeclassfield.h"
20 #include "codeclassfieldlist.h"
21 #include "umlassociationlist.h"
22
23 #include <QMap>
24 #include <QList>
25 #include <QString>
26
27
32 class ClassifierCodeDocument : public CodeDocument
33 {
34 friend class HierarchicalCodeBlock;
35 Q_OBJECT
36 public:
37
38 // Constructors/Destructors
39
40 explicit ClassifierCodeDocument(UMLClassifier * parent);
41 virtual ~ClassifierCodeDocument();
42
43 bool addCodeClassField(CodeClassField * add_object);
44
45 bool removeCodeClassField(CodeClassField * remove_object);
46
47 CodeClassFieldList* getCodeClassFieldList();
48
49 // some Utility methods
50
51 bool parentIsInterface();
52 bool parentIsClass();
53
54 bool hasAssociationClassFields();
55 bool hasAttributeClassFields();
56 bool hasObjectVectorClassFields();
57 bool hasClassFields();
58
59 QList<CodeOperation*> getCodeOperations();
60
61 CodeClassFieldList getSpecificClassFields(CodeClassField::ClassFieldType cfType);
62 CodeClassFieldList getSpecificClassFields(CodeClassField::ClassFieldType cfType, bool isStatic);
63 CodeClassFieldList getSpecificClassFields(CodeClassField::ClassFieldType cfType, Uml::Visibility::Enum visibility);
64 CodeClassFieldList getSpecificClassFields(CodeClassField::ClassFieldType cfType, bool isStatic, Uml::Visibility::Enum visibility);
65
66 CodeClassField * findCodeClassFieldFromParentID (Uml::ID::Type id, int role_id = -1);
67
68 UMLClassifier * getParentClassifier();
69
70 void addCodeClassFieldMethods(CodeClassFieldList &list);
71
72 virtual void initCodeClassFields();
73
74 virtual void synchronize();
75
79 virtual bool addCodeOperation(CodeOperation *opBlock) = 0;
80
81 virtual void updateContent() = 0;
82
83 virtual void saveToXMI1(QDomDocument &doc, QDomElement &root);
84 virtual void loadFromXMI1(QDomElement &root);
85
86 protected:
87
88 void loadClassFieldsFromXMI(QDomElement &childElem);
89
90 virtual void setAttributesOnNode(QDomDocument &doc, QDomElement &blockElement);
91 virtual void setAttributesFromNode(QDomElement &element);
92
93 TextBlock * findCodeClassFieldTextBlockByTag(const QString &tag);
94
95 void declareClassFields(CodeClassFieldList &list, CodeGenObjectWithTextBlocks *parent);
96
97 void syncClassFields();
98 void syncNamesToParent();
99
100 private:
101
102 CodeClassFieldList m_classfieldVector;
103 UMLClassifier* m_parentclassifier;
104
105 void updateAssociationClassFields(UMLAssociationList &assocList);
106 void updateOperations();
107
112 QMap<UMLObject *, CodeClassField *> m_classFieldMap;
113
114 void init(UMLClassifier *classifier);
115
116 public slots:
117
118 void addAttributeClassField(UMLClassifierListItem *at, bool syncToParentIfAdded = true);
119 void addAssociationClassField(UMLAssociation *assoc, bool syncToParentIfAdded = true);
120 void removeAttributeClassField(UMLClassifierListItem *at);
121 void removeAssociationClassField(UMLAssociation *assoc);
122 void addOperation(UMLClassifierListItem *obj);
123 void removeOperation(UMLClassifierListItem *obj);
124 void syncToParent();
125
126 };
127
128 #endif // CLASSIFIERCODEDOCUMENT_H
UMLObject::id
virtual Uml::ID::Type id() const
Definition: umlobject.cpp:425
umlrole.h
codeclassfield.h
umlattributelist.h
ClassifierCodeDocument::parentIsInterface
bool parentIsInterface()
Definition: classifiercodedocument.cpp:418
ClassifierCodeDocument::saveToXMI1
virtual void saveToXMI1(QDomDocument &doc, QDomElement &root)
Definition: classifiercodedocument.cpp:713
codegenfactory.h
CodeClassFieldDeclarationBlock
Definition: codeclassfielddeclarationblock.h:30
UMLObject::asUMLOperation
UMLOperation * asUMLOperation()
Definition: umlobject.cpp:1324
UMLAttributeList
Definition: umlattributelist.h:27
ClassifierCodeDocument::findCodeClassFieldFromParentID
CodeClassField * findCodeClassFieldFromParentID(Uml::ID::Type id, int role_id=-1)
Definition: classifiercodedocument.cpp:649
CodeClassField::ClassFieldType
ClassFieldType
Definition: codeclassfield.h:34
umloperationlist.h
ClassifierCodeDocument::loadFromXMI1
virtual void loadFromXMI1(QDomElement &root)
Definition: classifiercodedocument.cpp:736
ClassifierCodeDocument::getCodeOperations
QList< CodeOperation * > getCodeOperations()
Definition: classifiercodedocument.cpp:284
codeclassfieldlist.h
CodeGenerator::cleanName
static QString cleanName(const QString &name)
Definition: codegenerator.cpp:549
CodeGenObjectWithTextBlocks::removeTextBlock
virtual bool removeTextBlock(TextBlock *remove_object)
Definition: codegenobjectwithtextblocks.cpp:92
UMLObject::ot_Class
@ ot_Class
Definition: umlobject.h:89
operation.h
CodeDocument::setFileName
void setFileName(const QString &new_var)
Definition: codedocument.cpp:53
Uml::RoleType::A
@ A
Definition: basictypes.h:239
CodeMethodBlock::syncToParent
virtual void syncToParent()
Definition: codemethodblock.cpp:169
ClassifierCodeDocument::syncNamesToParent
void syncNamesToParent()
Definition: classifiercodedocument.cpp:466
UMLObject::ot_Interface
@ ot_Interface
Definition: umlobject.h:86
CodeGenObjectWithTextBlocks::addTextBlock
virtual bool addTextBlock(TextBlock *add_object)
Definition: codegenobjectwithtextblocks.cpp:57
ClassifierCodeDocument::m_classfieldVector
CodeClassFieldList m_classfieldVector
Definition: classifiercodedocument.h:102
Uml::ID::toString
QString toString(const ID::Type &id)
Definition: basictypes.cpp:1263
association.h
ClassifierCodeDocument::declareClassFields
void declareClassFields(CodeClassFieldList &list, CodeGenObjectWithTextBlocks *parent)
Definition: classifiercodedocument.cpp:378
CodeAccessorMethod
Definition: codeaccessormethod.h:21
UMLObject::umlPackage
UMLPackage * umlPackage() const
Definition: umlobject.cpp:646
CodeClassField::Attribute
@ Attribute
Definition: codeclassfield.h:34
Uml::ID::Type
std::string Type
Definition: basictypes.h:351
ClassifierCodeDocument::hasAssociationClassFields
bool hasAssociationClassFields()
Definition: classifiercodedocument.cpp:161
CodeClassField
Definition: codeclassfield.h:30
CodeDocument
Definition: codedocument.h:33
ClassifierCodeDocument::removeAssociationClassField
void removeAssociationClassField(UMLAssociation *assoc)
Definition: classifiercodedocument.cpp:247
ClassifierCodeDocument::hasObjectVectorClassFields
bool hasObjectVectorClassFields()
Definition: classifiercodedocument.cpp:124
UMLObject
The base class for UML objects.
Definition: umlobject.h:74
Uml::RoleType::fromInt
Enum fromInt(int item)
Definition: basictypes.cpp:811
ClassifierCodeDocument::addCodeClassFieldMethods
void addCodeClassFieldMethods(CodeClassFieldList &list)
Definition: classifiercodedocument.cpp:353
UMLRole
Definition: umlrole.h:25
ClassifierCodeDocument::addAssociationClassField
void addAssociationClassField(UMLAssociation *assoc, bool syncToParentIfAdded=true)
Definition: classifiercodedocument.cpp:575
Uml::AssociationType::Association_Self
@ Association_Self
Definition: basictypes.h:111
CodeGenObjectWithTextBlocks::getTextBlockList
TextBlockList * getTextBlockList() const
Definition: codegenobjectwithtextblocks.cpp:46
UMLObject::baseType
ObjectType baseType() const
Definition: umlobject.cpp:397
codeoperation.h
ClassifierCodeDocument
Definition: classifiercodedocument.h:33
ClassifierCodeDocument::~ClassifierCodeDocument
virtual ~ClassifierCodeDocument()
Definition: classifiercodedocument.cpp:45
UMLAssociation::getUMLRole
UMLRole * getUMLRole(Uml::RoleType::Enum role) const
Definition: association.cpp:585
ClassifierCodeDocument::updateAssociationClassFields
void updateAssociationClassFields(UMLAssociationList &assocList)
Definition: classifiercodedocument.cpp:569
Uml::ID::fromString
ID::Type fromString(const QString &id)
Definition: basictypes.cpp:1268
ClassifierCodeDocument::removeCodeClassField
bool removeCodeClassField(CodeClassField *remove_object)
Definition: classifiercodedocument.cpp:224
CodeClassField::loadFromXMI1
virtual void loadFromXMI1(QDomElement &root)
Definition: codeclassfield.cpp:229
ClassifierCodeDocument::addCodeOperation
virtual bool addCodeOperation(CodeOperation *opBlock)=0
ClassifierCodeDocument::hasClassFields
bool hasClassFields()
Definition: classifiercodedocument.cpp:151
classifierlistitem.h
ClassifierCodeDocument::addAttributeClassField
void addAttributeClassField(UMLClassifierListItem *at, bool syncToParentIfAdded=true)
Definition: classifiercodedocument.cpp:199
CodeParameter::ID
QString ID()
Definition: codeparameter.cpp:148
CodeGenObjectWithTextBlocks
Definition: codegenobjectwithtextblocks.h:32
UMLCanvasObject::getSpecificAssocs
UMLAssociationList getSpecificAssocs(Uml::AssociationType::Enum assocType)
Definition: umlcanvasobject.cpp:61
ClassifierCodeDocument::findCodeClassFieldTextBlockByTag
TextBlock * findCodeClassFieldTextBlockByTag(const QString &tag)
Definition: classifiercodedocument.cpp:771
ClassifierCodeDocument::getSpecificClassFields
CodeClassFieldList getSpecificClassFields(CodeClassField::ClassFieldType cfType)
Definition: classifiercodedocument.cpp:54
attribute.h
a
QString a
Definition: petalnode.cpp:18
UMLObject::asUMLRole
UMLRole * asUMLRole()
Definition: umlobject.cpp:1327
CodeOperation::findTag
static QString findTag(UMLOperation *op)
Definition: codeoperation.cpp:91
ClassifierCodeDocument::init
void init(UMLClassifier *classifier)
Definition: classifiercodedocument.cpp:428
classifiercodedocument.h
Uml::AssociationType::Association
@ Association
Definition: basictypes.h:110
ClassifierCodeDocument::synchronize
virtual void synchronize()
Definition: classifiercodedocument.cpp:480
ClassifierCodeDocument::ClassifierCodeDocument
ClassifierCodeDocument(UMLClassifier *parent)
Definition: classifiercodedocument.cpp:37
CodeAccessorMethodList
QList< CodeAccessorMethod * > CodeAccessorMethodList
Definition: codeaccessormethodlist.h:17
ClassifierCodeDocument::initCodeClassFields
virtual void initCodeClassFields()
Definition: classifiercodedocument.cpp:540
ClassifierCodeDocument::hasAttributeClassFields
bool hasAttributeClassFields()
Definition: classifiercodedocument.cpp:170
Uml::RoleType::B
@ B
Definition: basictypes.h:240
MyProject\connect
connect()
Definition: namespaces-multiple.php:5
ClassifierCodeDocument::getCodeClassFieldList
CodeClassFieldList * getCodeClassFieldList()
Definition: classifiercodedocument.cpp:266
CodeDocument::setPackage
void setPackage(UMLPackage *new_var)
Definition: codedocument.cpp:91
ClassifierCodeDocument::loadClassFieldsFromXMI
void loadClassFieldsFromXMI(QDomElement &childElem)
Definition: classifiercodedocument.cpp:679
ClassifierCodeDocument::m_classFieldMap
QMap< UMLObject *, CodeClassField * > m_classFieldMap
Definition: classifiercodedocument.h:112
ClassifierCodeDocument::updateContent
virtual void updateContent()=0
UMLApp::app
static UMLApp * app()
Definition: uml.cpp:278
visibility
Definition: visibility.py:1
UMLAttribute
Sets up attribute information.
Definition: attribute.h:28
UMLClassifier::getAttributeList
UMLAttributeList getAttributeList() const
Definition: classifier.cpp:436
ClassifierCodeDocument::removeOperation
void removeOperation(UMLClassifierListItem *obj)
Definition: classifiercodedocument.cpp:331
ClassifierCodeDocument::m_parentclassifier
UMLClassifier * m_parentclassifier
Definition: classifiercodedocument.h:103
CodeParameter::getVisibility
Uml::Visibility::Enum getVisibility() const
Definition: codeparameter.cpp:89
codedocument.h
CodeDocument::updateHeader
void updateHeader()
Definition: codedocument.cpp:279
UMLCanvasObject::getAggregations
UMLAssociationList getAggregations()
Definition: umlcanvasobject.cpp:412
Uml::Visibility::Enum
Enum
Definition: basictypes.h:59
ClassifierCodeDocument::addCodeClassField
bool addCodeClassField(CodeClassField *add_object)
Definition: classifiercodedocument.cpp:182
CodeParameter::getStatic
bool getStatic()
Definition: codeparameter.cpp:57
ClassifierCodeDocument::getParentClassifier
UMLClassifier * getParentClassifier()
Definition: classifiercodedocument.cpp:275
ClassifierCodeDocument::setAttributesOnNode
virtual void setAttributesOnNode(QDomDocument &doc, QDomElement &blockElement)
Definition: classifiercodedocument.cpp:749
HierarchicalCodeBlock
Definition: hierarchicalcodeblock.h:23
classifier.h
uError
#define uError()
Definition: debug_utils.h:123
CodeDocument::setAttributesOnNode
virtual void setAttributesOnNode(QDomDocument &doc, QDomElement &blockElement)
Definition: codedocument.cpp:357
UMLOperation
Definition: operation.h:25
CodeOperation
Definition: codeoperation.h:24
ClassifierCodeDocument::syncToParent
void syncToParent()
Definition: classifiercodedocument.cpp:531
uml.h
ClassifierCodeDocument::removeAttributeClassField
void removeAttributeClassField(UMLClassifierListItem *at)
Definition: classifiercodedocument.cpp:240
UMLClassifier
Information for a non-graphical Concept/Class.
Definition: classifier.h:40
debug_utils.h
umlassociationlist.h
UMLAssociation
Sets up association information.
Definition: association.h:33
ClassifierCodeDocument::updateOperations
void updateOperations()
Definition: classifiercodedocument.cpp:504
ClassifierCodeDocument::addOperation
void addOperation(UMLClassifierListItem *obj)
Definition: classifiercodedocument.cpp:302
TextBlockList
QList< TextBlock * > TextBlockList
Definition: textblocklist.h:17
UMLCanvasObject::getCompositions
UMLAssociationList getCompositions()
Definition: umlcanvasobject.cpp:422
codeaccessormethod.h
ClassifierCodeDocument::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &element)
Definition: classifiercodedocument.cpp:620
CodeClassField::getMethodList
CodeAccessorMethodList getMethodList() const
Definition: codeclassfield.cpp:191
UMLRole::role
Uml::RoleType::Enum role() const
Definition: umlrole.cpp:169
ClassifierCodeDocument::syncClassFields
void syncClassFields()
Definition: classifiercodedocument.cpp:493
CodeClassFieldList
QList< CodeClassField * > CodeClassFieldList
Definition: codeclassfieldlist.h:17
TextBlock
Definition: textblock.h:25
codegenerator.h
CodeClassField::getDeclarationCodeBlock
CodeClassFieldDeclarationBlock * getDeclarationCodeBlock()
Definition: codeclassfield.cpp:221
ClassifierCodeDocument::parentIsClass
bool parentIsClass()
Definition: classifiercodedocument.cpp:410
CodeGenFactory::newCodeClassField
CodeClassField * newCodeClassField(ClassifierCodeDocument *ccd, UMLAttribute *at)
Definition: codegenfactory.cpp:265
UMLOperationList
QList< UMLOperation * > UMLOperationList
Definition: umloperationlist.h:18
CodeClassField::getClassFieldType
ClassFieldType getClassFieldType() const
Definition: codeclassfield.cpp:136
UMLRole::multiplicity
QString multiplicity() const
Definition: umlrole.cpp:113
UMLClassifierListItem
A base class for classifier list items (e.g. attributes)
Definition: classifierlistitem.h:30
CodeGenFactory::newCodeOperation
CodeOperation * newCodeOperation(ClassifierCodeDocument *ccd, UMLOperation *op)
Definition: codegenfactory.cpp:222
UMLAssociationList
QList< UMLAssociation * > UMLAssociationList
Definition: umlassociationlist.h:18
CodeParameter::getParentObject
UMLObject * getParentObject()
Definition: codeparameter.cpp:141
TextBlock::getTag
QString getTag() const
Definition: textblock.cpp:110
umldoc.h
CodeDocument::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &element)
Definition: codedocument.cpp:388
CodeDocument::findTextBlockByTag
TextBlock * findTextBlockByTag(const QString &tag, bool descendIntoChildren=false)
Definition: codedocument.cpp:503
Uml::RoleType::Enum
Enum
Definition: basictypes.h:238