umbrello  2.32.2
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  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 
12 #include "hierarchicalcodeblock.h"
13 
14 #include <QMap>
15 #include <QObject>
16 #include <QString>
17 
19 class CodeComment;
20 class QXmlStreamWriter;
21 class TextBlock;
22 class UMLPackage;
23 
29 class CodeDocument : public QObject, public CodeGenObjectWithTextBlocks
30 {
31  friend class HierarchicalCodeBlock;
32  Q_OBJECT
33 public:
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 saveToXMI1(QXmlStreamWriter& writer);
65  virtual void loadFromXMI1 (QDomElement & root);
66 
67  virtual CodeBlock * newCodeBlock ();
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 
81 protected:
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 
101 private:
102 
104  QString m_filename;
106  QString m_ID;
107  QString m_pathName;
109 
110  bool m_writeOutCode; // Whether or not to write out this code document
111  // and any codeblocks, etc that it owns.
112 
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
UMLObject::id
virtual Uml::ID::Type id() const
Definition: umlobject.cpp:420
CodeDocument::m_header
CodeComment * m_header
Definition: codedocument.h:113
CodeGenObjectWithTextBlocks::resetTextBlocks
virtual void resetTextBlocks()
Definition: codegenobjectwithtextblocks.cpp:322
CodeDocument::setWriteOutCode
void setWriteOutCode(bool new_var)
Definition: codedocument.cpp:151
CodeDocument::resetTextBlocks
void resetTextBlocks()
Definition: codedocument.cpp:335
CodeDocument::m_childTextBlockTagMap
QMap< QString, TextBlock * > m_childTextBlockTagMap
Definition: codedocument.h:116
CodeDocument::newHierarchicalCodeBlock
virtual HierarchicalCodeBlock * newHierarchicalCodeBlock()
Definition: codedocument.cpp:475
TextBlock::toString
virtual QString toString() const
Definition: textblock.cpp:401
UMLObject::name
QString name() const
Definition: umlobject.cpp:206
CodeDocument::addChildTagToMap
void addChildTagToMap(const QString &tag, TextBlock *tb)
Definition: codedocument.cpp:487
CodeGenerator::cleanName
static QString cleanName(const QString &name)
Definition: codegenerator.cpp:546
CodeGenObjectWithTextBlocks::m_textBlockTagMap
QMap< QString, TextBlock * > m_textBlockTagMap
Definition: codegenobjectwithtextblocks.h:92
hierarchicalcodeblock.h
CodeDocument::saveToXMI1
virtual void saveToXMI1(QXmlStreamWriter &writer)
Definition: codedocument.cpp:434
CodeDocument::setFileName
void setFileName(const QString &new_var)
Definition: codedocument.cpp:50
CodeComment
Definition: codecomment.h:19
TextBlock::setWriteOutText
void setWriteOutText(bool write)
Definition: textblock.cpp:127
CodeComment::saveToXMI1
virtual void saveToXMI1(QXmlStreamWriter &writer)
Definition: codecomment.cpp:27
Uml::ID::None
const Type None
special value for uninitialized ID
Definition: basictypes.h:373
this
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent this
Definition: GPL-2.0-only.txt:51
CodeDocument::operator<<
friend QDebug operator<<(QDebug os, const CodeDocument &obj)
Definition: codedocument.cpp:523
CodeDocument::setFileExtension
void setFileExtension(const QString &new_var)
Definition: codedocument.cpp:69
UMLApp::commonPolicy
CodeGenerationPolicy * commonPolicy() const
Definition: uml.cpp:2283
Uml::ID::toString
QString toString(const ID::Type &id)
Definition: basictypes.cpp:1300
CodeDocument::m_pathName
QString m_pathName
Definition: codedocument.h:107
TextBlock::setTag
void setTag(const QString &value)
Definition: textblock.cpp:117
CodeDocument::getPath
virtual QString getPath() const
Definition: codedocument.cpp:97
Uml::ID::Type
std::string Type
Definition: basictypes.h:371
CodeDocument::getFileExtension
QString getFileExtension() const
Definition: codedocument.cpp:79
CodeDocument
Definition: codedocument.h:29
CodeDocument::removeChildTagFromMap
void removeChildTagFromMap(const QString &tag)
Definition: codedocument.cpp:482
UMLObject
The base class for UML objects.
Definition: umlobject.h:69
CodeDocument::CodeDocument
CodeDocument()
Definition: codedocument.cpp:26
CodeGenObjectWithTextBlocks::getTextBlockList
TextBlockList * getTextBlockList() const
Definition: codegenobjectwithtextblocks.cpp:45
CodeBlock
Definition: codeblock.h:16
CodeDocument::getPackage
QString getPackage() const
Definition: codedocument.cpp:120
CodeDocument::m_fileExtension
QString m_fileExtension
Definition: codedocument.h:105
Uml::ID::fromString
ID::Type fromString(const QString &id)
Definition: basictypes.cpp:1305
CodeDocument::HierarchicalCodeBlock
friend class HierarchicalCodeBlock
Definition: codedocument.h:31
CodeDocument::loadFromXMI1
virtual void loadFromXMI1(QDomElement &root)
Definition: codedocument.cpp:345
CodeGenerationPolicy::getHeadingFile
QString getHeadingFile(const QString &str)
Definition: codegenerationpolicy.cpp:542
CodeGenObjectWithTextBlocks
Definition: codegenobjectwithtextblocks.h:28
CodeDocument::getHeader
CodeComment * getHeader() const
Definition: codedocument.cpp:180
CodeGenObjectWithTextBlocks::m_textblockVector
TextBlockList m_textblockVector
Definition: codegenobjectwithtextblocks.h:93
UMLDoc::findObjectById
UMLObject * findObjectById(Uml::ID::Type id)
Definition: umldoc.cpp:1039
number
it is up to the author donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License If the distribution and or use of the Library is restricted in certain countries either by patents or by copyrighted the original copyright holder who places the Library under this License may add an geographical distribution limitation excluding those so that distribution is permitted only in or among countries not thus excluded In such this License incorporates the limitation as if written in the body of this License The Free Software Foundation may publish revised and or new versions of the Library General Public License from time to time Such new versions will be similar in spirit to the present but may differ in detail to address new problems or concerns Each version is given a distinguishing version number If the Library specifies a version number of this License which applies to it and any later you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation If the Library does not specify a license version number
Definition: LGPL-2.0-only.txt:368
CodeDocument::setAttributesOnNode
virtual void setAttributesOnNode(QXmlStreamWriter &writer)
Definition: codedocument.cpp:354
uWarning
#define uWarning()
Definition: debug_utils.h:110
CodeDocument::setPackage
void setPackage(UMLPackage *new_var)
Definition: codedocument.cpp:88
c
type show c for details The hypothetical commands show w and show c should show the appropriate parts of the General Public License Of the commands you use may be called something other than show w and show c
Definition: GPL-2.0-only.txt:301
CodeBlockWithComments
Definition: codeblockwithcomments.h:19
UMLApp::app
static UMLApp * app()
Definition: uml.cpp:275
UMLDoc
Definition: umldoc.h:69
operator<<
QDebug operator<<(QDebug os, const CodeDocument &obj)
Definition: codedocument.cpp:523
CodeDocument::m_writeOutCode
bool m_writeOutCode
Definition: codedocument.h:110
CodeDocument::synchronize
virtual void synchronize()
Definition: codedocument.cpp:326
CodeDocument::updateContent
virtual void updateContent()
Definition: codedocument.cpp:448
CodeGenObjectWithTextBlocks::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &element)
Definition: codegenobjectwithtextblocks.cpp:372
CodeDocument::insertTextBlock
bool insertTextBlock(TextBlock *newBlock, TextBlock *existingBlock, bool after=true)
Definition: codedocument.cpp:213
CodeDocument::cleanName
QString cleanName(const QString &name)
Definition: codedocument.cpp:267
CodeDocument::newCodeBlock
virtual CodeBlock * newCodeBlock()
Definition: codedocument.cpp:457
codegenobjectwithtextblocks.h
codedocument.h
CodeDocument::updateHeader
void updateHeader()
Definition: codedocument.cpp:276
CodeDocument::~CodeDocument
virtual ~CodeDocument()
Definition: codedocument.cpp:37
HierarchicalCodeBlock::insertTextBlock
bool insertTextBlock(TextBlock *newBlock, TextBlock *existingBlock, bool after=true)
Definition: hierarchicalcodeblock.cpp:106
UMLDoc::findUMLObject
UMLObject * findUMLObject(const QString &name, UMLObject::ObjectType type=UMLObject::ot_UMLObject, UMLObject *currentObj=0)
Definition: umldoc.cpp:1068
HierarchicalCodeBlock
Definition: hierarchicalcodeblock.h:20
CodeDocument::m_lastTagIndex
int m_lastTagIndex
Definition: codedocument.h:103
CodeDocument::m_filename
QString m_filename
Definition: codedocument.h:104
CodeDocument::getFileName
QString getFileName() const
Definition: codedocument.cpp:60
uml.h
CodeDocument::findTextBlockByTag
TextBlock * findTextBlockByTag(const QString &tag, bool descendIntoChildren=false) const
Definition: codedocument.cpp:500
debug_utils.h
CodeDocument::newCodeBlockWithComments
virtual CodeBlockWithComments * newCodeBlockWithComments()
Definition: codedocument.cpp:466
TextBlockList
QList< TextBlock * > TextBlockList
Definition: textblocklist.h:12
CodeGenObjectWithTextBlocks::setAttributesOnNode
virtual void setAttributesOnNode(QXmlStreamWriter &writer)
Definition: codegenobjectwithtextblocks.cpp:354
CodeComment::loadFromXMI1
virtual void loadFromXMI1(QDomElement &root)
Definition: codecomment.cpp:38
CodeDocument::ID
QString ID() const
Definition: codedocument.cpp:140
TextBlock
Definition: textblock.h:22
codegenerator.h
CodeDocument::setHeader
void setHeader(CodeComment *comment)
Definition: codedocument.cpp:171
UMLObject::asUMLPackage
UMLPackage * asUMLPackage()
Definition: umlobject.cpp:1405
TextBlock::setText
void setText(const QString &text)
Definition: textblock.cpp:76
package.h
CodeDocument::getWriteOutCode
bool getWriteOutCode() const
Definition: codedocument.cpp:162
CodeDocument::findCodeClassFieldTextBlockByTag
virtual TextBlock * findCodeClassFieldTextBlockByTag(const QString &tag)
Definition: codedocument.cpp:517
CodeDocument::setID
void setID(const QString &new_id)
Definition: codedocument.cpp:131
UMLApp::document
UMLDoc * document() const
Definition: uml.cpp:1063
TextBlock::getTag
QString getTag() const
Definition: textblock.cpp:106
umldoc.h
CodeDocument::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &element)
Definition: codedocument.cpp:385
CodeDocument::m_package
UMLPackage * m_package
Definition: codedocument.h:108
CodeDocument::toString
virtual QString toString() const
Definition: codedocument.cpp:299
CodeDocument::getUniqueTag
virtual QString getUniqueTag(const QString &prefix=QString())
Definition: codedocument.cpp:190
CodeDocument::m_ID
QString m_ID
Definition: codedocument.h:106
UMLPackage
Non-graphical information for a Package.
Definition: package.h:27