umbrello: umbrello/codegenerators/codedocument.h Source File

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

- Main Page
- Related Pages
- Topics
- Namespaces
- Classes
- Files

- File List
- File Members

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