umbrello: umbrello/codegenerators/d/dwriter.h Source File

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

dwriter.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) 2007 Jari-Matti Mäkelä <jmjm@iki.fi> *
8 * copyright (C) 2008-2020 *
9 * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
10 ***************************************************************************/
11
12 #ifndef DWRITER_H
13 #define DWRITER_H
14
15 #include "simplecodegenerator.h"
16 #include "umloperationlist.h"
17 #include "umlattributelist.h"
18 #include "umlassociationlist.h"
19
20 class UMLOperation;
21
32 class DWriter : public SimpleCodeGenerator
33 {
34 public:
35
36 DWriter();
37 virtual ~DWriter();
38
39 virtual void writeClass(UMLClassifier *c);
40
41 virtual Uml::ProgrammingLanguage::Enum language() const;
42
43 QStringList defaultDatatypes();
44
45 private:
46
50 void writeModuleDecl(UMLClassifier *c, QTextStream &d);
51
55 void writeModuleImports(UMLClassifier *c, QTextStream &d);
56
61 void writeClassDecl(UMLClassifier *c, QTextStream &d);
62
66 void writeConstructor(UMLClassifier *c, QTextStream &d);
67
73 static bool compareDMethod(UMLOperation *op1, UMLOperation *op2);
74
80 static bool dMethodInList(UMLOperation *umlOp, UMLOperationList &opl);
81
90 void getSuperImplementedOperations(UMLClassifier *c, UMLOperationList &yetImplementedOpList,
91 UMLOperationList &toBeImplementedOpList, bool noClassInPath = true);
92
98 void getInterfacesOperationsToBeImplemented(UMLClassifier *c, UMLOperationList &opl);
99
105 void writeOperations(UMLClassifier *c, QTextStream &j);
106
112 void writeOperations(UMLOperationList &list, QTextStream &j);
113
119 void writeAttributes(UMLClassifier *c, QTextStream &j);
120
126 void writeProtectionMod(Uml::Visibility::Enum visibility, QTextStream &d);
127
135 void writeAttributeDecl(Uml::Visibility::Enum visibility, UMLAttributeList &atlist, QTextStream &d);
136
144 void writeAttributeDecls(UMLAttributeList &atpub, UMLAttributeList &atprot,
145 UMLAttributeList &atpriv, QTextStream &d);
146
150 void writeAssociationDecls(UMLAssociationList associations, Uml::ID::Type id, QTextStream &d);
151
155 void writeAssociationRoleDecl(QString fieldClassName, QString roleName, QString multi,
156 QString doc, Uml::Visibility::Enum visib, QTextStream &d);
157
161 void writeAttributeMethods(UMLAttributeList &atpub, Uml::Visibility::Enum visibility, QTextStream &d);
162
166 void writeAssociationMethods(UMLAssociationList associations, UMLClassifier *thisClass,
167 QTextStream &d);
168
174 void writeAssociationRoleMethod(QString fieldClassName, QString roleName, QString multi,
175 QString description, Uml::Visibility::Enum visib, Uml::Changeability::Enum change,
176 QTextStream &d);
177
181 void writeSingleAttributeAccessorMethods(QString fieldClassName, QString fieldVarName,
182 QString fieldName, QString description,
183 Uml::Visibility::Enum visibility, Uml::Changeability::Enum change,
184 bool isFinal, QTextStream &d);
185
189 void writeVectorAttributeAccessorMethods(QString fieldClassName, QString fieldVarName,
190 QString fieldName, QString description,
191 Uml::Visibility::Enum visibility, Uml::Changeability::Enum change,
192 QTextStream &d);
193
197 void writeComment(const QString &text, const QString &indent, QTextStream &d, bool dDocStyle=false);
198
202 void writeDocumentation(QString header, QString body, QString end, QString indent, QTextStream &d);
203
207 QString getUMLObjectName(UMLObject *obj);
208
212 QString deCapitaliseFirstLetter(const QString& str);
213
217 QString pluralize(const QString& string);
218
222 QString unPluralize(const QString& str);
223
227 QString fixTypeName(const QString& string);
228
232 QString fixInitialStringDeclValue(const QString& val, const QString& type);
233
237 void writeBlankLine(QTextStream& d);
238
239 QString startline;
240 bool isInterface;
241
242 };
243
244 #endif // DWRITER_H
UMLObject::package
QString package(const QString &separator=QString(), bool includeRoot=false)
Definition: umlobject.cpp:577
UMLObject::id
virtual Uml::ID::Type id() const
Definition: umlobject.cpp:425
umlattributelist.h
template.h
DWriter::writeModuleDecl
void writeModuleDecl(UMLClassifier *c, QTextStream &d)
Definition: dwriter.cpp:57
DWriter::getInterfacesOperationsToBeImplemented
void getInterfacesOperationsToBeImplemented(UMLClassifier *c, UMLOperationList &opl)
Definition: dwriter.cpp:816
UMLClassifier::getOpList
UMLOperationList getOpList(bool includeInherited=false, UMLClassifierSet *alreadyTraversed=0)
Definition: classifier.cpp:939
UMLClassifier::getUniAssociationToBeImplemented
virtual UMLAssociationList getUniAssociationToBeImplemented()
Definition: classifier.cpp:1325
UMLAttributeListIt
QListIterator< UMLAttribute * > UMLAttributeListIt
Definition: umlattributelist.h:20
SimpleCodeGenerator::m_indentation
QString m_indentation
Definition: simplecodegenerator.h:76
Uml::ProgrammingLanguage::Enum
Enum
Definition: basictypes.h:271
UMLClassifier::isInterface
bool isInterface() const
Definition: classifier.cpp:118
DWriter::defaultDatatypes
QStringList defaultDatatypes()
Definition: dwriter.cpp:732
UMLAttributeList
Definition: umlattributelist.h:27
UMLObject::name
QString name() const
Definition: umlobject.cpp:211
umloperationlist.h
CodeGenerator::getHeadingFile
virtual QString getHeadingFile(const QString &file)
Definition: codegenerator.cpp:407
DWriter::getUMLObjectName
QString getUMLObjectName(UMLObject *obj)
Definition: dwriter.cpp:957
UMLOperation::getParmList
UMLAttributeList getParmList() const
Definition: operation.cpp:178
UMLTemplate::getTypeName
virtual QString getTypeName() const
Definition: template.cpp:80
CodeGenerator::cleanName
static QString cleanName(const QString &name)
Definition: codegenerator.cpp:549
Uml::Changeability::Changeable
@ Changeable
Definition: basictypes.h:205
DWriter::deCapitaliseFirstLetter
QString deCapitaliseFirstLetter(const QString &str)
Definition: dwriter.cpp:962
operation.h
UMLAttribute::getInitialValue
QString getInitialValue() const
Definition: attribute.cpp:99
UMLClassifierListItem::getTypeName
virtual QString getTypeName() const
Definition: classifierlistitem.cpp:112
UMLClassifier::INTERFACE
@ INTERFACE
Definition: classifier.h:47
Uml::RoleType::A
@ A
Definition: basictypes.h:239
CodeGenerator::findObjectsRelated
static void findObjectsRelated(UMLClassifier *c, UMLPackageList &cList)
Definition: codegenerator.cpp:622
DWriter::compareDMethod
static bool compareDMethod(UMLOperation *op1, UMLOperation *op2)
Definition: dwriter.cpp:763
DWriter::writeAttributeDecls
void writeAttributeDecls(UMLAttributeList &atpub, UMLAttributeList &atprot, UMLAttributeList &atpriv, QTextStream &d)
Definition: dwriter.cpp:416
DWriter
Definition: dwriter.h:33
association.h
UMLObject::isStatic
bool isStatic() const
Definition: umlobject.cpp:366
UMLClassifier::getTemplateList
UMLTemplateList getTemplateList() const
Definition: classifier.cpp:1148
Model_Utils::hasAssociations
bool hasAssociations(UMLObject::ObjectType type)
Definition: model_utils.cpp:2295
UMLClassifierList
QList< UMLClassifier * > UMLClassifierList
Definition: umlclassifierlist.h:17
DWriter::fixInitialStringDeclValue
QString fixInitialStringDeclValue(const QString &val, const QString &type)
Definition: dwriter.cpp:943
Uml::ID::Type
std::string Type
Definition: basictypes.h:351
DWriter::pluralize
QString pluralize(const QString &string)
Definition: dwriter.cpp:969
DWriter::writeDocumentation
void writeDocumentation(QString header, QString body, QString end, QString indent, QTextStream &d)
Definition: dwriter.cpp:472
DWriter::DWriter
DWriter()
Definition: dwriter.cpp:34
UMLObject
The base class for UML objects.
Definition: umlobject.h:74
SimpleCodeGenerator::indent
QString indent()
Definition: simplecodegenerator.cpp:76
UMLObject::isAbstract
bool isAbstract() const
Definition: umlobject.cpp:348
DWriter::writeAssociationRoleMethod
void writeAssociationRoleMethod(QString fieldClassName, QString roleName, QString multi, QString description, Uml::Visibility::Enum visib, Uml::Changeability::Enum change, QTextStream &d)
Definition: dwriter.cpp:596
DWriter::writeClassDecl
void writeClassDecl(UMLClassifier *c, QTextStream &d)
Definition: dwriter.cpp:283
CodeGenerator::forceDoc
bool forceDoc() const
Definition: codegenerator.cpp:765
CodeGenerator::formatSourceCode
static QString formatSourceCode(const QString &code, const QString &indentation)
Definition: codegenerator.cpp:743
Uml::Changeability::Enum
Enum
Definition: basictypes.h:204
Uml::Visibility::Public
@ Public
Definition: basictypes.h:60
DWriter::writeAttributeMethods
void writeAttributeMethods(UMLAttributeList &atpub, Uml::Visibility::Enum visibility, QTextStream &d)
Definition: dwriter.cpp:425
Uml::Changeability::Frozen
@ Frozen
Definition: basictypes.h:206
Codegen_Utils::capitalizeFirstLetter
QString capitalizeFirstLetter(const QString &string)
Definition: codegen_utils.cpp:430
DWriter::fixTypeName
QString fixTypeName(const QString &string)
Definition: dwriter.cpp:712
UMLObject::visibility
Uml::Visibility::Enum visibility() const
Definition: umlobject.cpp:466
UMLCanvasObject::getSpecificAssocs
UMLAssociationList getSpecificAssocs(Uml::AssociationType::Enum assocType)
Definition: umlcanvasobject.cpp:61
attribute.h
a
QString a
Definition: petalnode.cpp:18
SimpleCodeGenerator::m_endl
QString m_endl
Definition: simplecodegenerator.h:78
UMLClassifier::findSuperClassConcepts
UMLClassifierList findSuperClassConcepts(ClassifierType type=ALL)
Definition: classifier.cpp:609
Uml::Visibility::toString
QString toString(Enum item, bool mnemonic)
Definition: basictypes.cpp:107
DWriter::writeAssociationRoleDecl
void writeAssociationRoleDecl(QString fieldClassName, QString roleName, QString multi, QString doc, Uml::Visibility::Enum visib, QTextStream &d)
Definition: dwriter.cpp:524
DWriter::writeAttributes
void writeAttributes(UMLClassifier *c, QTextStream &j)
Uml::AssociationType::Association
@ Association
Definition: basictypes.h:110
Uml::ProgrammingLanguage::D
@ D
Definition: basictypes.h:276
DWriter::writeSingleAttributeAccessorMethods
void writeSingleAttributeAccessorMethods(QString fieldClassName, QString fieldVarName, QString fieldName, QString description, Uml::Visibility::Enum visibility, Uml::Changeability::Enum change, bool isFinal, QTextStream &d)
Definition: dwriter.cpp:663
DWriter::writeAssociationDecls
void writeAssociationDecls(UMLAssociationList associations, Uml::ID::Type id, QTextStream &d)
Definition: dwriter.cpp:489
CodeGenerator::formatDoc
static QString formatDoc(const QString &text, const QString &linePrefix=QLatin1String(" *"), int lineWidth=80)
Definition: codegenerator.cpp:712
DWriter::writeConstructor
void writeConstructor(UMLClassifier *c, QTextStream &d)
Definition: dwriter.cpp:693
DWriter::writeVectorAttributeAccessorMethods
void writeVectorAttributeAccessorMethods(QString fieldClassName, QString fieldVarName, QString fieldName, QString description, Uml::Visibility::Enum visibility, Uml::Changeability::Enum change, QTextStream &d)
Definition: dwriter.cpp:613
uDebug
#define uDebug()
Definition: debug_utils.h:122
SimpleCodeGenerator
Definition: simplecodegenerator.h:34
DWriter::~DWriter
virtual ~DWriter()
Definition: dwriter.cpp:43
Uml::RoleType::B
@ B
Definition: basictypes.h:240
DWriter::unPluralize
QString unPluralize(const QString &str)
Definition: dwriter.cpp:974
DWriter::writeModuleImports
void writeModuleImports(UMLClassifier *c, QTextStream &d)
Definition: dwriter.cpp:65
dwriter.h
DWriter::writeComment
void writeComment(const QString &text, const QString &indent, QTextStream &d, bool dDocStyle=false)
Definition: dwriter.cpp:439
UMLObject::doc
QString doc() const
Definition: umlobject.cpp:435
visibility
Definition: visibility.py:1
UMLAttribute
Sets up attribute information.
Definition: attribute.h:28
UMLClassifier::getAttributeList
UMLAttributeList getAttributeList() const
Definition: classifier.cpp:436
UMLPackageList
QList< UMLPackage * > UMLPackageList
Definition: umlpackagelist.h:17
DWriter::isInterface
bool isInterface
whether or not this concept is an interface
Definition: dwriter.h:240
UMLCanvasObject::getAggregations
UMLAssociationList getAggregations()
Definition: umlcanvasobject.cpp:412
DWriter::startline
QString startline
a , used at the end of each line
Definition: dwriter.h:239
Uml::Visibility::Enum
Enum
Definition: basictypes.h:59
CodeGenerator::codeGenerated
void codeGenerated(UMLClassifier *concept, bool generated)
classifier.h
UMLOperation
Definition: operation.h:25
DWriter::writeAssociationMethods
void writeAssociationMethods(UMLAssociationList associations, UMLClassifier *thisClass, QTextStream &d)
Definition: dwriter.cpp:562
UMLTemplateListIt
QListIterator< UMLTemplate * > UMLTemplateListIt
Definition: umltemplatelist.h:21
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
DWriter::writeOperations
void writeOperations(UMLClassifier *c, QTextStream &j)
Definition: dwriter.cpp:828
UMLObject::isUMLDatatype
bool isUMLDatatype()
Definition: umlobject.h:206
UMLCanvasObject::getCompositions
UMLAssociationList getCompositions()
Definition: umlcanvasobject.cpp:422
DWriter::dMethodInList
static bool dMethodInList(UMLOperation *umlOp, UMLOperationList &opl)
Definition: dwriter.cpp:785
UMLClassifier::CLASS
@ CLASS
Definition: classifier.h:47
UMLTemplateList
QList< UMLTemplate * > UMLTemplateList
Definition: umltemplatelist.h:18
UMLTemplate
Sets up template information.
Definition: template.h:27
simplecodegenerator.h
Uml::Visibility::Private
@ Private
Definition: basictypes.h:61
DWriter::writeClass
virtual void writeClass(UMLClassifier *c)
Definition: dwriter.cpp:101
CodeGenerator::forceSections
bool forceSections() const
Definition: codegenerator.cpp:775
Uml::Visibility::Protected
@ Protected
Definition: basictypes.h:62
UMLOperationList
QList< UMLOperation * > UMLOperationList
Definition: umloperationlist.h:18
umltemplatelist.h
UMLAssociationList
QList< UMLAssociation * > UMLAssociationList
Definition: umlassociationlist.h:18
SimpleCodeGenerator::findFileName
QString findFileName(UMLPackage *concept, const QString &ext)
Definition: simplecodegenerator.cpp:91
DWriter::getSuperImplementedOperations
void getSuperImplementedOperations(UMLClassifier *c, UMLOperationList &yetImplementedOpList, UMLOperationList &toBeImplementedOpList, bool noClassInPath=true)
Definition: dwriter.cpp:795
codegen_utils.h
DWriter::writeAttributeDecl
void writeAttributeDecl(Uml::Visibility::Enum visibility, UMLAttributeList &atlist, QTextStream &d)
Definition: dwriter.cpp:380
umldoc.h
DWriter::writeProtectionMod
void writeProtectionMod(Uml::Visibility::Enum visibility, QTextStream &d)
Definition: dwriter.cpp:375
DWriter::language
virtual Uml::ProgrammingLanguage::Enum language() const
Definition: dwriter.cpp:51
CodeGenerator::openFile
bool openFile(QFile &file, const QString &name)
Definition: codegenerator.cpp:523
UMLOperation::getSourceCode
QString getSourceCode() const
Definition: operation.cpp:507
DWriter::writeBlankLine
void writeBlankLine(QTextStream &d)
Definition: dwriter.cpp:989
UMLPackage
Non-graphical information for a Package.
Definition: package.h:33
description
static const char description[]
Definition: main.cpp:37