umbrello: umbrello/codegenerators/codedocument.h Source File

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

codedocument.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 CODEDOCUMENT_H
13 #define CODEDOCUMENT_H
14
15 #include "codegenobjectwithtextblocks.h"
16 #include "hierarchicalcodeblock.h"
17
18 #include <QMap>
19 #include <QObject>
20 #include <QString>
21
22 class CodeBlockWithComments;
23 class CodeComment;
24 class QXmlStreamWriter;
25 class TextBlock;
26 class UMLPackage;
27
33 class CodeDocument : public QObject, public CodeGenObjectWithTextBlocks
34 {
35 friend class HierarchicalCodeBlock;
36 Q_OBJECT
37 public:
38
39 CodeDocument ();
40 virtual ~CodeDocument ();
41
42 void setFileExtension (const QString &new_var);
43 QString getFileExtension () const;
44
45 void setFileName (const QString &new_var);
46 QString getFileName () const;
47
48 void setPackage (UMLPackage *new_var);
49 QString getPackage () const;
50
51 virtual QString getPath ();
52
53 void setID (const QString &new_id);
54 QString ID () const;
55
56 void setWriteOutCode (bool new_var);
57 bool getWriteOutCode ();
58
59 void setHeader (CodeComment * comment);
60 CodeComment * getHeader ();
61
62 bool insertTextBlock (TextBlock * newBlock, TextBlock * existingBlock, bool after = true);
63
64 TextBlock * findTextBlockByTag(const QString &tag, bool descendIntoChildren = false);
65
66 virtual QString toString ();
67
68 virtual void saveToXMI1(QXmlStreamWriter& writer);
69 virtual void loadFromXMI1 (QDomElement & root);
70
71 virtual CodeBlock * newCodeBlock ();
72 virtual HierarchicalCodeBlock * newHierarchicalCodeBlock ();
73 virtual CodeBlockWithComments * newCodeBlockWithComments ();
74
75 virtual QString getUniqueTag(const QString& prefix = QString());
76
77 QString cleanName (const QString &name);
78
79 virtual void synchronize();
80
81 virtual void updateContent();
82
83 friend QDebug operator<<(QDebug os, const CodeDocument& obj);
84
85 protected:
86
87 virtual void setAttributesOnNode (QXmlStreamWriter& writer);
88
89 virtual void setAttributesFromNode (QDomElement & element);
90
91 // these next 2 are needed by child hierarchical code blocks so
92 // that when they call getUniqueTag, we really get a unique tag
93 // Also, it allows 'findTextBlockByTag' To find any tagged text block
94 // anywhere in the document, whether directly owned by the document OR
95 // by some child hierarchical textblock
96 void addChildTagToMap (const QString &tag, TextBlock * tb);
97 void removeChildTagFromMap (const QString &tag);
98
99 void updateHeader ();
100
101 void resetTextBlocks();
102
103 virtual TextBlock * findCodeClassFieldTextBlockByTag(const QString &tag);
104
105 private:
106
107 int m_lastTagIndex;
108 QString m_filename;
109 QString m_fileExtension;
110 QString m_ID;
111 QString m_pathName;
112 UMLPackage *m_package;
113
114 bool m_writeOutCode; // Whether or not to write out this code document
115 // and any codeblocks, etc that it owns.
116
117 CodeComment * m_header;
118
119 // for recording all of the textblocks held by child hierarchical codeblocks
120 QMap<QString, TextBlock *> m_childTextBlockTagMap;
121
122 };
123
124 #endif // CODEDOCUMENT_H
CodeBlockWithComments
Definition: codeblockwithcomments.h:24
CodeBlock
Definition: codeblock.h:21
CodeComment
Definition: codecomment.h:24
CodeDocument
Definition: codedocument.h:34
CodeDocument::updateHeader
void updateHeader()
Definition: codedocument.cpp:280
CodeDocument::setAttributesOnNode
virtual void setAttributesOnNode(QXmlStreamWriter &writer)
Definition: codedocument.cpp:358
CodeDocument::setPackage
void setPackage(UMLPackage *new_var)
Definition: codedocument.cpp:92
CodeDocument::getFileExtension
QString getFileExtension() const
Definition: codedocument.cpp:83
CodeDocument::setWriteOutCode
void setWriteOutCode(bool new_var)
Definition: codedocument.cpp:155
CodeDocument::setFileExtension
void setFileExtension(const QString &new_var)
Definition: codedocument.cpp:73
CodeDocument::m_filename
QString m_filename
Definition: codedocument.h:108
CodeDocument::getWriteOutCode
bool getWriteOutCode()
Definition: codedocument.cpp:166
CodeDocument::operator<<
friend QDebug operator<<(QDebug os, const CodeDocument &obj)
Definition: codedocument.cpp:527
CodeDocument::removeChildTagFromMap
void removeChildTagFromMap(const QString &tag)
Definition: codedocument.cpp:486
CodeDocument::m_ID
QString m_ID
Definition: codedocument.h:110
CodeDocument::getPackage
QString getPackage() const
Definition: codedocument.cpp:124
CodeDocument::insertTextBlock
bool insertTextBlock(TextBlock *newBlock, TextBlock *existingBlock, bool after=true)
Definition: codedocument.cpp:217
CodeDocument::m_fileExtension
QString m_fileExtension
Definition: codedocument.h:109
CodeDocument::newHierarchicalCodeBlock
virtual HierarchicalCodeBlock * newHierarchicalCodeBlock()
Definition: codedocument.cpp:479
CodeDocument::getUniqueTag
virtual QString getUniqueTag(const QString &prefix=QString())
Definition: codedocument.cpp:194
CodeDocument::getFileName
QString getFileName() const
Definition: codedocument.cpp:64
CodeDocument::synchronize
virtual void synchronize()
Definition: codedocument.cpp:330
CodeDocument::findCodeClassFieldTextBlockByTag
virtual TextBlock * findCodeClassFieldTextBlockByTag(const QString &tag)
Definition: codedocument.cpp:521
CodeDocument::setHeader
void setHeader(CodeComment *comment)
Definition: codedocument.cpp:175
CodeDocument::newCodeBlockWithComments
virtual CodeBlockWithComments * newCodeBlockWithComments()
Definition: codedocument.cpp:470
CodeDocument::toString
virtual QString toString()
Definition: codedocument.cpp:303
CodeDocument::m_package
UMLPackage * m_package
Definition: codedocument.h:112
CodeDocument::setFileName
void setFileName(const QString &new_var)
Definition: codedocument.cpp:54
CodeDocument::loadFromXMI1
virtual void loadFromXMI1(QDomElement &root)
Definition: codedocument.cpp:349
CodeDocument::getPath
virtual QString getPath()
Definition: codedocument.cpp:101
CodeDocument::getHeader
CodeComment * getHeader()
Definition: codedocument.cpp:184
CodeDocument::m_writeOutCode
bool m_writeOutCode
Definition: codedocument.h:114
CodeDocument::m_childTextBlockTagMap
QMap< QString, TextBlock * > m_childTextBlockTagMap
Definition: codedocument.h:120
CodeDocument::CodeDocument
CodeDocument()
Definition: codedocument.cpp:30
CodeDocument::saveToXMI1
virtual void saveToXMI1(QXmlStreamWriter &writer)
Definition: codedocument.cpp:438
CodeDocument::~CodeDocument
virtual ~CodeDocument()
Definition: codedocument.cpp:41
CodeDocument::addChildTagToMap
void addChildTagToMap(const QString &tag, TextBlock *tb)
Definition: codedocument.cpp:491
CodeDocument::setID
void setID(const QString &new_id)
Definition: codedocument.cpp:135
CodeDocument::resetTextBlocks
void resetTextBlocks()
Definition: codedocument.cpp:339
CodeDocument::m_pathName
QString m_pathName
Definition: codedocument.h:111
CodeDocument::ID
QString ID() const
Definition: codedocument.cpp:144
CodeDocument::m_lastTagIndex
int m_lastTagIndex
Definition: codedocument.h:107
CodeDocument::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &element)
Definition: codedocument.cpp:389
CodeDocument::newCodeBlock
virtual CodeBlock * newCodeBlock()
Definition: codedocument.cpp:461
CodeDocument::updateContent
virtual void updateContent()
Definition: codedocument.cpp:452
CodeDocument::m_header
CodeComment * m_header
Definition: codedocument.h:117
CodeDocument::cleanName
QString cleanName(const QString &name)
Definition: codedocument.cpp:271
CodeDocument::findTextBlockByTag
TextBlock * findTextBlockByTag(const QString &tag, bool descendIntoChildren=false)
Definition: codedocument.cpp:504
CodeGenObjectWithTextBlocks
Definition: codegenobjectwithtextblocks.h:33
HierarchicalCodeBlock
Definition: hierarchicalcodeblock.h:25
TextBlock
Definition: textblock.h:27
UMLPackage
Non-graphical information for a Package.
Definition: package.h:33
codegenobjectwithtextblocks.h
hierarchicalcodeblock.h