umbrello: umbrello/codegenerators/codegenerator.h Source File

umbrello 2.32.3 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 SPDX-License-Identifier: GPL-2.0-or-later
3
4 SPDX-FileCopyrightText: 2003 Brian Thomas <thomas@mail630.gsfc.nasa.gov>
5 SPDX-FileCopyrightText: 2004-2021 Umbrello UML Modeller Authors <umbrello-devel@kde.org>
6*/
7
8#ifndef CODEGENERATOR_H
9#define CODEGENERATOR_H
10
11#include "basictypes.h"
12#include "codegenpolicyext.h"
13#include "codegenerationpolicy.h"
14#include "umlpackagelist.h"
15#include "umlclassifierlist.h"
16#include "codedocumentlist.h"
17#include "codeviewerstate.h"
18
19#include <QDir>
20#include <QHash>
21#include <QList>
22
23class UMLDoc;
24class UMLObject;
25class ClassifierCodeDocument;
26class CodeDocument;
27class CodeViewerDialog;
28class QDomDocument;
29class QDomElement;
30class QXmlStreamWriter;
31
53 class CodeGenerator : public QObject
54{
55 Q_OBJECT
56public:
57 typedef enum {Generated, Failed, Skipped } GenerationState;
58 CodeGenerator();
59 virtual ~CodeGenerator();
60
61 bool addCodeDocument(CodeDocument * add_object);
62 bool removeCodeDocument(CodeDocument * remove_object);
63
64 CodeDocumentList * getCodeDocumentList();
65
66 QString getUniqueID(CodeDocument * codeDoc);
67
68 virtual void saveToXMI1(QXmlStreamWriter& writer);
69
70 CodeDocument * findCodeDocumentByID(const QString &id);
71
72 virtual void writeCodeToFile();
73 virtual void writeCodeToFile(UMLClassifierList &list);
74
75 void setIncludeHeadings(bool i);
76 bool includeHeadings() const;
77
78 void setHeadingFileDir(const QString &);
79 QString headingFileDir() const;
80
81 void setForceDoc(bool f);
82 bool forceDoc() const;
83
84 void setForceSections(bool f);
85 bool forceSections() const;
86
87 virtual QString getHeadingFile(const QString &file);
88
89 QString findFileName(CodeDocument * codeDocument);
90
91 static QString cleanName(const QString &name);
92
93 static QString formatDoc(const QString& text, const QString& linePrefix = QLatin1String(" *"), int lineWidth = 80);
94
95 static QString formatSourceCode(const QString& code, const QString& indentation);
96
97 static void findObjectsRelated(UMLClassifier *c, UMLPackageList &cList);
98
103 virtual void loadFromXMI1(QDomElement & element);
104
108 virtual Uml::ProgrammingLanguage::Enum language() const = 0;
109
110 CodeDocument * findCodeDocumentByClassifier(UMLClassifier * classifier);
111
112 virtual QStringList defaultDatatypes() const;
113
114 virtual bool isReservedKeyword(const QString & keyword);
115
116 virtual QStringList reservedKeywords() const;
117
118 virtual void createDefaultStereotypes();
119
123 virtual void initFromParentDocument() = 0;
124
125protected:
126 QString overwritableName(const QString& name, const QString &extension);
127
128 bool openFile(QFile& file, const QString &name);
129
130 void writeListedCodeDocsToFile(CodeDocumentList * docs);
131
132 virtual void finalizeRun();
133
134 // map of what code documents we currently have in this generator.
135 QHash<QString, CodeDocument*> m_codeDocumentDictionary;
136
141 bool m_applyToAllRemaining;
142
146 UMLDoc* m_document;
147
148private:
149 CodeDocumentList m_codedocumentVector;
150 int m_lastIDIndex;
151
152 void loadCodeForOperation(const QString& id, const QDomElement& codeDocElement);
153
154public slots:
155 virtual void syncCodeToDocument();
156
157signals:
158 void codeGenerated(UMLClassifier* concept, bool generated);
159 void codeGenerated(UMLClassifier* concept, CodeGenerator::GenerationState result);
160 void showGeneratedFile(const QString& filename);
161};
162
163#endif // CODEGENERATOR_H
basictypes.h
ClassifierCodeDocument
Definition: classifiercodedocument.h:29
CodeDocument
Definition: codedocument.h:30
CodeGenerator
Definition: codegenerator.h:54
CodeGenerator::defaultDatatypes
virtual QStringList defaultDatatypes() const
Definition: codegenerator.cpp:781
CodeGenerator::findCodeDocumentByID
CodeDocument * findCodeDocumentByID(const QString &id)
Definition: codegenerator.cpp:107
CodeGenerator::setForceSections
void setForceSections(bool f)
Definition: codegenerator.cpp:767
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:57
CodeGenerator::Failed
@ Failed
Definition: codegenerator.h:57
CodeGenerator::Generated
@ Generated
Definition: codegenerator.h:57
CodeGenerator::Skipped
@ Skipped
Definition: codegenerator.h:57
CodeGenerator::syncCodeToDocument
virtual void syncCodeToDocument()
Definition: codegenerator.cpp:282
CodeGenerator::includeHeadings
bool includeHeadings() const
CodeGenerator::cleanName
static QString cleanName(const QString &name)
Definition: codegenerator.cpp:546
CodeGenerator::findCodeDocumentByClassifier
CodeDocument * findCodeDocumentByClassifier(UMLClassifier *classifier)
Definition: codegenerator.cpp:297
CodeGenerator::finalizeRun
virtual void finalizeRun()
Definition: codegenerator.cpp:382
CodeGenerator::removeCodeDocument
bool removeCodeDocument(CodeDocument *remove_object)
Definition: codegenerator.cpp:147
CodeGenerator::findFileName
QString findFileName(CodeDocument *codeDocument)
Definition: codegenerator.cpp:562
CodeGenerator::saveToXMI1
virtual void saveToXMI1(QXmlStreamWriter &writer)
Definition: codegenerator.cpp:242
CodeGenerator::forceSections
bool forceSections() const
Definition: codegenerator.cpp:772
CodeGenerator::loadCodeForOperation
void loadCodeForOperation(const QString &id, const QDomElement &codeDocElement)
Definition: codegenerator.cpp:217
CodeGenerator::m_applyToAllRemaining
bool m_applyToAllRemaining
Definition: codegenerator.h:141
CodeGenerator::getHeadingFile
virtual QString getHeadingFile(const QString &file)
Definition: codegenerator.cpp:404
CodeGenerator::writeCodeToFile
virtual void writeCodeToFile()
Definition: codegenerator.cpp:307
CodeGenerator::findObjectsRelated
static void findObjectsRelated(UMLClassifier *c, UMLPackageList &cList)
Definition: codegenerator.cpp:619
CodeGenerator::writeListedCodeDocsToFile
void writeListedCodeDocsToFile(CodeDocumentList *docs)
Definition: codegenerator.cpp:338
CodeGenerator::setHeadingFileDir
void setHeadingFileDir(const QString &)
CodeGenerator::getCodeDocumentList
CodeDocumentList * getCodeDocumentList()
Definition: codegenerator.cpp:166
CodeGenerator::m_lastIDIndex
int m_lastIDIndex
Definition: codegenerator.h:150
CodeGenerator::headingFileDir
QString headingFileDir() const
CodeGenerator::loadFromXMI1
virtual void loadFromXMI1(QDomElement &element)
Definition: codegenerator.cpp:175
CodeGenerator::openFile
bool openFile(QFile &file, const QString &name)
Definition: codegenerator.cpp:520
CodeGenerator::CodeGenerator
CodeGenerator()
Definition: codegenerator.cpp:49
CodeGenerator::language
virtual Uml::ProgrammingLanguage::Enum language() const =0
CodeGenerator::m_codeDocumentDictionary
QHash< QString, CodeDocument * > m_codeDocumentDictionary
Definition: codegenerator.h:135
CodeGenerator::isReservedKeyword
virtual bool isReservedKeyword(const QString &keyword)
Definition: codegenerator.cpp:794
CodeGenerator::m_codedocumentVector
CodeDocumentList m_codedocumentVector
Definition: codegenerator.h:149
CodeGenerator::setIncludeHeadings
void setIncludeHeadings(bool i)
CodeGenerator::overwritableName
QString overwritableName(const QString &name, const QString &extension)
Definition: codegenerator.cpp:424
CodeGenerator::formatDoc
static QString formatDoc(const QString &text, const QString &linePrefix=QLatin1String(" *"), int lineWidth=80)
Definition: codegenerator.cpp:709
CodeGenerator::forceDoc
bool forceDoc() const
Definition: codegenerator.cpp:762
CodeGenerator::~CodeGenerator
virtual ~CodeGenerator()
Definition: codegenerator.cpp:64
CodeGenerator::setForceDoc
void setForceDoc(bool f)
Definition: codegenerator.cpp:757
CodeGenerator::m_document
UMLDoc * m_document
Definition: codegenerator.h:146
CodeGenerator::formatSourceCode
static QString formatSourceCode(const QString &code, const QString &indentation)
Definition: codegenerator.cpp:740
CodeGenerator::createDefaultStereotypes
virtual void createDefaultStereotypes()
Definition: codegenerator.cpp:812
CodeGenerator::addCodeDocument
bool addCodeDocument(CodeDocument *add_object)
Definition: codegenerator.cpp:122
CodeGenerator::showGeneratedFile
void showGeneratedFile(const QString &filename)
CodeGenerator::getUniqueID
QString getUniqueID(CodeDocument *codeDoc)
Definition: codegenerator.cpp:75
CodeGenerator::reservedKeywords
virtual QStringList reservedKeywords() const
Definition: codegenerator.cpp:803
CodeViewerDialog
Definition: codeviewerdialog.h:23
UMLClassifier
Information for a non-graphical Concept/Class.
Definition: classifier.h:35
UMLDoc
Definition: umldoc.h:70
UMLObject
The base class for UML objects.
Definition: umlobject.h:70
codedocumentlist.h
CodeDocumentList
QList< CodeDocument * > CodeDocumentList
Definition: codedocumentlist.h:12
codegenerationpolicy.h
codegenpolicyext.h
codeviewerstate.h
Uml::ProgrammingLanguage::Enum
Enum
Definition: basictypes.h:291
umlclassifierlist.h
UMLClassifierList
QList< UMLClassifier * > UMLClassifierList
Definition: umlclassifierlist.h:12
umlpackagelist.h
UMLPackageList
QList< UMLPackage * > UMLPackageList
Definition: umlpackagelist.h:11