umbrello: umbrello/codegenerators/codegenerator.h Source File

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

codegenerator.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 CODEGENERATOR_H
13 #define CODEGENERATOR_H
14
15 #include "basictypes.h"
16 #include "codegenpolicyext.h"
17 #include "codegenerationpolicy.h"
18 #include "umlpackagelist.h"
19 #include "umlclassifierlist.h"
20 #include "codedocumentlist.h"
21 #include "codeviewerstate.h"
22
23 #include <QDir>
24 #include <QHash>
25 #include <QList>
26
27 class UMLDoc;
28 class UMLObject;
29 class ClassifierCodeDocument;
30 class CodeDocument;
31 class CodeViewerDialog;
32 class QDomDocument;
33 class QDomElement;
34 class QXmlStreamWriter;
35
57 class CodeGenerator : public QObject
58 {
59 Q_OBJECT
60 public:
61 typedef enum {Generated, Failed, Skipped } GenerationState;
62 CodeGenerator();
63 virtual ~CodeGenerator();
64
65 bool addCodeDocument(CodeDocument * add_object);
66 bool removeCodeDocument(CodeDocument * remove_object);
67
68 CodeDocumentList * getCodeDocumentList();
69
70 QString getUniqueID(CodeDocument * codeDoc);
71
72 virtual void saveToXMI1(QXmlStreamWriter& writer);
73
74 CodeDocument * findCodeDocumentByID(const QString &id);
75
76 virtual void writeCodeToFile();
77 virtual void writeCodeToFile(UMLClassifierList &list);
78
79 void setIncludeHeadings(bool i);
80 bool includeHeadings() const;
81
82 void setHeadingFileDir(const QString &);
83 QString headingFileDir() const;
84
85 void setForceDoc(bool f);
86 bool forceDoc() const;
87
88 void setForceSections(bool f);
89 bool forceSections() const;
90
91 virtual QString getHeadingFile(const QString &file);
92
93 QString findFileName(CodeDocument * codeDocument);
94
95 static QString cleanName(const QString &name);
96
97 static QString formatDoc(const QString& text, const QString& linePrefix = QLatin1String(" *"), int lineWidth = 80);
98
99 static QString formatSourceCode(const QString& code, const QString& indentation);
100
101 static void findObjectsRelated(UMLClassifier *c, UMLPackageList &cList);
102
107 virtual void loadFromXMI1(QDomElement & element);
108
112 virtual Uml::ProgrammingLanguage::Enum language() const = 0;
113
114 CodeDocument * findCodeDocumentByClassifier(UMLClassifier * classifier);
115
116 virtual QStringList defaultDatatypes();
117
118 virtual bool isReservedKeyword(const QString & keyword);
119
120 virtual QStringList reservedKeywords() const;
121
122 virtual void createDefaultStereotypes();
123
127 virtual void initFromParentDocument() = 0;
128
129 protected:
130 QString overwritableName(const QString& name, const QString &extension);
131
132 bool openFile(QFile& file, const QString &name);
133
134 void writeListedCodeDocsToFile(CodeDocumentList * docs);
135
136 virtual void finalizeRun();
137
138 // map of what code documents we currently have in this generator.
139 QHash<QString, CodeDocument*> m_codeDocumentDictionary;
140
145 bool m_applyToAllRemaining;
146
150 UMLDoc* m_document;
151
152 private:
153 CodeDocumentList m_codedocumentVector;
154 int m_lastIDIndex;
155
156 void loadCodeForOperation(const QString& id, const QDomElement& codeDocElement);
157
158 public slots:
159 virtual void syncCodeToDocument();
160
161 signals:
162 void codeGenerated(UMLClassifier* concept, bool generated);
163 void codeGenerated(UMLClassifier* concept, CodeGenerator::GenerationState result);
164 void showGeneratedFile(const QString& filename);
165 };
166
167 #endif // CODEGENERATOR_H
basictypes.h
ClassifierCodeDocument
Definition: classifiercodedocument.h:33
CodeDocument
Definition: codedocument.h:34
CodeGenerator
Definition: codegenerator.h:58
CodeGenerator::findCodeDocumentByID
CodeDocument * findCodeDocumentByID(const QString &id)
Definition: codegenerator.cpp:111
CodeGenerator::setForceSections
void setForceSections(bool f)
Definition: codegenerator.cpp:771
CodeGenerator::initFromParentDocument
virtual void initFromParentDocument()=0
CodeGenerator::codeGenerated
void codeGenerated(UMLClassifier *concept, CodeGenerator::GenerationState result)
CodeGenerator::codeGenerated
void codeGenerated(UMLClassifier *concept, bool generated)
CodeGenerator::GenerationState
GenerationState
Definition: codegenerator.h:61
CodeGenerator::Failed
@ Failed
Definition: codegenerator.h:61
CodeGenerator::Generated
@ Generated
Definition: codegenerator.h:61
CodeGenerator::Skipped
@ Skipped
Definition: codegenerator.h:61
CodeGenerator::syncCodeToDocument
virtual void syncCodeToDocument()
Definition: codegenerator.cpp:286
CodeGenerator::includeHeadings
bool includeHeadings() const
CodeGenerator::cleanName
static QString cleanName(const QString &name)
Definition: codegenerator.cpp:550
CodeGenerator::findCodeDocumentByClassifier
CodeDocument * findCodeDocumentByClassifier(UMLClassifier *classifier)
Definition: codegenerator.cpp:301
CodeGenerator::defaultDatatypes
virtual QStringList defaultDatatypes()
Definition: codegenerator.cpp:785
CodeGenerator::finalizeRun
virtual void finalizeRun()
Definition: codegenerator.cpp:386
CodeGenerator::removeCodeDocument
bool removeCodeDocument(CodeDocument *remove_object)
Definition: codegenerator.cpp:151
CodeGenerator::findFileName
QString findFileName(CodeDocument *codeDocument)
Definition: codegenerator.cpp:566
CodeGenerator::saveToXMI1
virtual void saveToXMI1(QXmlStreamWriter &writer)
Definition: codegenerator.cpp:246
CodeGenerator::forceSections
bool forceSections() const
Definition: codegenerator.cpp:776
CodeGenerator::loadCodeForOperation
void loadCodeForOperation(const QString &id, const QDomElement &codeDocElement)
Definition: codegenerator.cpp:221
CodeGenerator::m_applyToAllRemaining
bool m_applyToAllRemaining
Definition: codegenerator.h:145
CodeGenerator::getHeadingFile
virtual QString getHeadingFile(const QString &file)
Definition: codegenerator.cpp:408
CodeGenerator::writeCodeToFile
virtual void writeCodeToFile()
Definition: codegenerator.cpp:311
CodeGenerator::findObjectsRelated
static void findObjectsRelated(UMLClassifier *c, UMLPackageList &cList)
Definition: codegenerator.cpp:623
CodeGenerator::writeListedCodeDocsToFile
void writeListedCodeDocsToFile(CodeDocumentList *docs)
Definition: codegenerator.cpp:342
CodeGenerator::setHeadingFileDir
void setHeadingFileDir(const QString &)
CodeGenerator::getCodeDocumentList
CodeDocumentList * getCodeDocumentList()
Definition: codegenerator.cpp:170
CodeGenerator::m_lastIDIndex
int m_lastIDIndex
Definition: codegenerator.h:154
CodeGenerator::headingFileDir
QString headingFileDir() const
CodeGenerator::loadFromXMI1
virtual void loadFromXMI1(QDomElement &element)
Definition: codegenerator.cpp:179
CodeGenerator::openFile
bool openFile(QFile &file, const QString &name)
Definition: codegenerator.cpp:524
CodeGenerator::CodeGenerator
CodeGenerator()
Definition: codegenerator.cpp:53
CodeGenerator::language
virtual Uml::ProgrammingLanguage::Enum language() const =0
CodeGenerator::m_codeDocumentDictionary
QHash< QString, CodeDocument * > m_codeDocumentDictionary
Definition: codegenerator.h:139
CodeGenerator::isReservedKeyword
virtual bool isReservedKeyword(const QString &keyword)
Definition: codegenerator.cpp:798
CodeGenerator::m_codedocumentVector
CodeDocumentList m_codedocumentVector
Definition: codegenerator.h:153
CodeGenerator::setIncludeHeadings
void setIncludeHeadings(bool i)
CodeGenerator::overwritableName
QString overwritableName(const QString &name, const QString &extension)
Definition: codegenerator.cpp:428
CodeGenerator::formatDoc
static QString formatDoc(const QString &text, const QString &linePrefix=QLatin1String(" *"), int lineWidth=80)
Definition: codegenerator.cpp:713
CodeGenerator::forceDoc
bool forceDoc() const
Definition: codegenerator.cpp:766
CodeGenerator::~CodeGenerator
virtual ~CodeGenerator()
Definition: codegenerator.cpp:68
CodeGenerator::setForceDoc
void setForceDoc(bool f)
Definition: codegenerator.cpp:761
CodeGenerator::m_document
UMLDoc * m_document
Definition: codegenerator.h:150
CodeGenerator::formatSourceCode
static QString formatSourceCode(const QString &code, const QString &indentation)
Definition: codegenerator.cpp:744
CodeGenerator::createDefaultStereotypes
virtual void createDefaultStereotypes()
Definition: codegenerator.cpp:816
CodeGenerator::addCodeDocument
bool addCodeDocument(CodeDocument *add_object)
Definition: codegenerator.cpp:126
CodeGenerator::showGeneratedFile
void showGeneratedFile(const QString &filename)
CodeGenerator::getUniqueID
QString getUniqueID(CodeDocument *codeDoc)
Definition: codegenerator.cpp:79
CodeGenerator::reservedKeywords
virtual QStringList reservedKeywords() const
Definition: codegenerator.cpp:807
CodeViewerDialog
Definition: codeviewerdialog.h:28
UMLClassifier
Information for a non-graphical Concept/Class.
Definition: classifier.h:40
UMLDoc
Definition: umldoc.h:75
UMLObject
The base class for UML objects.
Definition: umlobject.h:75
codedocumentlist.h
CodeDocumentList
QList< CodeDocument * > CodeDocumentList
Definition: codedocumentlist.h:17
codegenerationpolicy.h
codegenpolicyext.h
codeviewerstate.h
Uml::ProgrammingLanguage::Enum
Enum
Definition: basictypes.h:305
umlclassifierlist.h
UMLClassifierList
QList< UMLClassifier * > UMLClassifierList
Definition: umlclassifierlist.h:17
umlpackagelist.h
UMLPackageList
QList< UMLPackage * > UMLPackageList
Definition: umlpackagelist.h:17