umbrello 2.32.3 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 TextBlock;
25 class UMLPackage;
26
32 class CodeDocument : public QObject, public CodeGenObjectWithTextBlocks
33 {
34 friend class HierarchicalCodeBlock;
35 Q_OBJECT
36 public:
37
38 CodeDocument ();
39 virtual ~CodeDocument ();
40
41 void setFileExtension (const QString &new_var);
42 QString getFileExtension () const;
43
44 void setFileName (const QString &new_var);
45 QString getFileName () const;
46
47 void setPackage (UMLPackage *new_var);
48 QString getPackage () const;
49
50 virtual QString getPath ();
51
52 void setID (const QString &new_id);
53 QString ID () const;
54
55 void setWriteOutCode (bool new_var);
56 bool getWriteOutCode ();
57
58 void setHeader (CodeComment * comment);
59 CodeComment * getHeader ();
60
61 bool insertTextBlock (TextBlock * newBlock, TextBlock * existingBlock, bool after = true);
62
63 TextBlock * findTextBlockByTag(const QString &tag, bool descendIntoChildren = false);
64
65 virtual QString toString ();
66
67 virtual void saveToXMI1 (QDomDocument & doc, QDomElement & root);
68 virtual void loadFromXMI1 (QDomElement & root);
69
70 virtual CodeBlock * newCodeBlock ();
71 virtual HierarchicalCodeBlock * newHierarchicalCodeBlock ();
72 virtual CodeBlockWithComments * newCodeBlockWithComments ();
73
74 virtual QString getUniqueTag(const QString& prefix = QString());
75
76 QString cleanName (const QString &name);
77
78 virtual void synchronize();
79
80 virtual void updateContent();
81
82 friend QDebug operator<<(QDebug os, const CodeDocument& obj);
83
84 protected:
85
86 virtual void setAttributesOnNode (QDomDocument & doc, QDomElement & blockElement);
87
88 virtual void setAttributesFromNode (QDomElement & element);
89
90 // these next 2 are needed by child hierarchical code blocks so
91 // that when they call getUniqueTag, we really get a unique tag
92 // Also, it allows 'findTextBlockByTag' To find any tagged text block
93 // anywhere in the document, whether directly owned by the document OR
94 // by some child hierarchical textblock
95 void addChildTagToMap (const QString &tag, TextBlock * tb);
96 void removeChildTagFromMap (const QString &tag);
97
98 void updateHeader ();
99
100 void resetTextBlocks();
101
102 virtual TextBlock * findCodeClassFieldTextBlockByTag(const QString &tag);
103
104 private:
105
106 int m_lastTagIndex;
107 QString m_filename;
108 QString m_fileExtension;
109 QString m_ID;
110 QString m_pathName;
111 UMLPackage *m_package;
112
113 bool m_writeOutCode; // Whether or not to write out this code document
114 // and any codeblocks, etc that it owns.
115
116 CodeComment * m_header;
117
118 // for recording all of the textblocks held by child hierarchical codeblocks
119 QMap<QString, TextBlock *> m_childTextBlockTagMap;
120
121 };
122
123 #endif // CODEDOCUMENT_H
UMLObject::id
virtual Uml::ID::Type id() const
Definition: umlobject.cpp:425
CodeDocument::m_header
CodeComment * m_header
Definition: codedocument.h:116
CodeGenObjectWithTextBlocks::resetTextBlocks
virtual void resetTextBlocks()
Definition: codegenobjectwithtextblocks.cpp:323
CodeDocument::setWriteOutCode
void setWriteOutCode(bool new_var)
Definition: codedocument.cpp:154
TextBlock::getWriteOutText
bool getWriteOutText() const
Definition: textblock.cpp:141
CodeDocument::resetTextBlocks
void resetTextBlocks()
Definition: codedocument.cpp:338
CodeDocument::m_childTextBlockTagMap
QMap< QString, TextBlock * > m_childTextBlockTagMap
Definition: codedocument.h:119
CodeDocument::newHierarchicalCodeBlock
virtual HierarchicalCodeBlock * newHierarchicalCodeBlock()
Definition: codedocument.cpp:478
TextBlock::toString
virtual QString toString() const
Definition: textblock.cpp:407
UMLObject::name
QString name() const
Definition: umlobject.cpp:211
CodeDocument::addChildTagToMap
void addChildTagToMap(const QString &tag, TextBlock *tb)
Definition: codedocument.cpp:490
CodeGenerator::cleanName
static QString cleanName(const QString &name)
Definition: codegenerator.cpp:549
CodeGenObjectWithTextBlocks::m_textBlockTagMap
QMap< QString, TextBlock * > m_textBlockTagMap
Definition: codegenobjectwithtextblocks.h:95
hierarchicalcodeblock.h
CodeDocument::setFileName
void setFileName(const QString &new_var)
Definition: codedocument.cpp:53
CodeComment
Definition: codecomment.h:24
TextBlock::setWriteOutText
void setWriteOutText(bool write)
Definition: textblock.cpp:131
Uml::ID::None
const Type None
special value for uninitialized ID
Definition: basictypes.h:353
CodeDocument::operator<<
friend QDebug operator<<(QDebug os, const CodeDocument &obj)
Definition: codedocument.cpp:526
CodeDocument::setFileExtension
void setFileExtension(const QString &new_var)
Definition: codedocument.cpp:72
UMLApp::commonPolicy
CodeGenerationPolicy * commonPolicy() const
Definition: uml.cpp:2283
Uml::ID::toString
QString toString(const ID::Type &id)
Definition: basictypes.cpp:1263
CodeComment::saveToXMI1
virtual void saveToXMI1(QDomDocument &doc, QDomElement &root)
Definition: codecomment.cpp:31
CodeDocument::m_pathName
QString m_pathName
Definition: codedocument.h:110
TextBlock::setTag
void setTag(const QString &value)
Definition: textblock.cpp:121
Uml::ID::Type
std::string Type
Definition: basictypes.h:351
CodeDocument::getFileExtension
QString getFileExtension() const
Definition: codedocument.cpp:82
CodeDocument
Definition: codedocument.h:33
CodeDocument::removeChildTagFromMap
void removeChildTagFromMap(const QString &tag)
Definition: codedocument.cpp:485
CodeDocument::saveToXMI1
virtual void saveToXMI1(QDomDocument &doc, QDomElement &root)
Definition: codedocument.cpp:437
UMLObject
The base class for UML objects.
Definition: umlobject.h:74
CodeDocument::CodeDocument
CodeDocument()
Definition: codedocument.cpp:29
CodeGenObjectWithTextBlocks::getTextBlockList
TextBlockList * getTextBlockList() const
Definition: codegenobjectwithtextblocks.cpp:46
CodeDocument::toString
virtual QString toString()
Definition: codedocument.cpp:302
CodeBlock
Definition: codeblock.h:21
CodeDocument::getPackage
QString getPackage() const
Definition: codedocument.cpp:123
CodeDocument::m_fileExtension
QString m_fileExtension
Definition: codedocument.h:108
CodeDocument::getPath
virtual QString getPath()
Definition: codedocument.cpp:100
Uml::ID::fromString
ID::Type fromString(const QString &id)
Definition: basictypes.cpp:1268
CodeDocument::HierarchicalCodeBlock
friend class HierarchicalCodeBlock
Definition: codedocument.h:34
CodeDocument::loadFromXMI1
virtual void loadFromXMI1(QDomElement &root)
Definition: codedocument.cpp:348
CodeGenerationPolicy::getHeadingFile
QString getHeadingFile(const QString &str)
Definition: codegenerationpolicy.cpp:546
CodeGenObjectWithTextBlocks
Definition: codegenobjectwithtextblocks.h:32
CodeGenObjectWithTextBlocks::m_textblockVector
TextBlockList m_textblockVector
Definition: codegenobjectwithtextblocks.h:96
UMLDoc::findObjectById
UMLObject * findObjectById(Uml::ID::Type id)
Definition: umldoc.cpp:1038
uWarning
#define uWarning()
Definition: debug_utils.h:124
CodeDocument::setPackage
void setPackage(UMLPackage *new_var)
Definition: codedocument.cpp:91
CodeBlockWithComments
Definition: codeblockwithcomments.h:24
UMLApp::app
static UMLApp * app()
Definition: uml.cpp:278
UMLDoc
Definition: umldoc.h:75
operator<<
QDebug operator<<(QDebug os, const CodeDocument &obj)
Definition: codedocument.cpp:526
CodeDocument::m_writeOutCode
bool m_writeOutCode
Definition: codedocument.h:113
CodeDocument::synchronize
virtual void synchronize()
Definition: codedocument.cpp:329
CodeDocument::updateContent
virtual void updateContent()
Definition: codedocument.cpp:451
CodeGenObjectWithTextBlocks::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &element)
Definition: codegenobjectwithtextblocks.cpp:373
CodeDocument::insertTextBlock
bool insertTextBlock(TextBlock *newBlock, TextBlock *existingBlock, bool after=true)
Definition: codedocument.cpp:216
CodeDocument::cleanName
QString cleanName(const QString &name)
Definition: codedocument.cpp:270
CodeDocument::newCodeBlock
virtual CodeBlock * newCodeBlock()
Definition: codedocument.cpp:460
codegenobjectwithtextblocks.h
codedocument.h
CodeDocument::updateHeader
void updateHeader()
Definition: codedocument.cpp:279
CodeDocument::~CodeDocument
virtual ~CodeDocument()
Definition: codedocument.cpp:40
HierarchicalCodeBlock::insertTextBlock
bool insertTextBlock(TextBlock *newBlock, TextBlock *existingBlock, bool after=true)
Definition: hierarchicalcodeblock.cpp:107
UMLDoc::findUMLObject
UMLObject * findUMLObject(const QString &name, UMLObject::ObjectType type=UMLObject::ot_UMLObject, UMLObject *currentObj=0)
Definition: umldoc.cpp:1067
HierarchicalCodeBlock
Definition: hierarchicalcodeblock.h:23
CodeGenObjectWithTextBlocks::setAttributesOnNode
virtual void setAttributesOnNode(QDomDocument &doc, QDomElement &elem)
Definition: codegenobjectwithtextblocks.cpp:355
CodeDocument::m_lastTagIndex
int m_lastTagIndex
Definition: codedocument.h:106
CodeDocument::setAttributesOnNode
virtual void setAttributesOnNode(QDomDocument &doc, QDomElement &blockElement)
Definition: codedocument.cpp:357
CodeDocument::m_filename
QString m_filename
Definition: codedocument.h:107
CodeDocument::getFileName
QString getFileName() const
Definition: codedocument.cpp:63
uml.h
debug_utils.h
CodeDocument::newCodeBlockWithComments
virtual CodeBlockWithComments * newCodeBlockWithComments()
Definition: codedocument.cpp:469
TextBlockList
QList< TextBlock * > TextBlockList
Definition: textblocklist.h:17
CodeComment::loadFromXMI1
virtual void loadFromXMI1(QDomElement &root)
Definition: codecomment.cpp:42
CodeDocument::ID
QString ID() const
Definition: codedocument.cpp:143
TextBlock
Definition: textblock.h:25
codegenerator.h
CodeDocument::setHeader
void setHeader(CodeComment *comment)
Definition: codedocument.cpp:174
UMLObject::asUMLPackage
UMLPackage * asUMLPackage()
Definition: umlobject.cpp:1325
CodeDocument::getWriteOutCode
bool getWriteOutCode()
Definition: codedocument.cpp:165
TextBlock::setText
void setText(const QString &text)
Definition: textblock.cpp:80
CodeDocument::getHeader
CodeComment * getHeader()
Definition: codedocument.cpp:183
package.h
CodeDocument::findCodeClassFieldTextBlockByTag
virtual TextBlock * findCodeClassFieldTextBlockByTag(const QString &tag)
Definition: codedocument.cpp:520
CodeDocument::setID
void setID(const QString &new_id)
Definition: codedocument.cpp:134
UMLApp::document
UMLDoc * document() const
Definition: uml.cpp:1064
TextBlock::getTag
QString getTag() const
Definition: textblock.cpp:110
umldoc.h
CodeDocument::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &element)
Definition: codedocument.cpp:388
CodeDocument::findTextBlockByTag
TextBlock * findTextBlockByTag(const QString &tag, bool descendIntoChildren=false)
Definition: codedocument.cpp:503
CodeDocument::m_package
UMLPackage * m_package
Definition: codedocument.h:111
CodeDocument::getUniqueTag
virtual QString getUniqueTag(const QString &prefix=QString())
Definition: codedocument.cpp:193
CodeDocument::m_ID
QString m_ID
Definition: codedocument.h:109
UMLPackage
Non-graphical information for a Package.
Definition: package.h:33