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

codegenerationpolicy.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 CODEGENERATIONPOLICY_H
13 #define CODEGENERATIONPOLICY_H
14
15 #include "basictypes.h"
16
17 #include <QDir>
18 #include <QObject>
19
20 class QWidget;
21 class CodeGenerationPolicyPage;
22
29 class CodeGenerationPolicy : public QObject
30 {
31 Q_OBJECT
32 public:
33
46 enum OverwritePolicy {Ok=0, Ask, Never, Cancel};
47 enum ModifyNamePolicy {No=0, Underscore, Capitalise};
48 enum NewLineType {UNIX=0, DOS, MAC};
49 enum IndentationType {NONE=0, TAB, SPACE};
50 enum CommentStyle { SingleLine=0, MultiLine };
51
52 explicit CodeGenerationPolicy(CodeGenerationPolicy * clone);
53 CodeGenerationPolicy();
54
55 virtual ~CodeGenerationPolicy();
56
57 void setOverwritePolicy(OverwritePolicy new_var);
58 OverwritePolicy getOverwritePolicy() const;
59
60 void setCodeVerboseSectionComments(bool new_var);
61 bool getCodeVerboseSectionComments() const;
62
63 void setCodeVerboseDocumentComments(bool new_var);
64 bool getCodeVerboseDocumentComments() const;
65
66 void setHeadingFileDir(const QString & path);
67 QString getHeadingFileDir() const;
68
69 void setIncludeHeadings(bool new_var);
70 bool getIncludeHeadings() const;
71
72 void setOutputDirectory(QDir new_var);
73 QDir getOutputDirectory();
74
75 void setLineEndingType(NewLineType type);
76 NewLineType getLineEndingType();
77
78 QString getNewLineEndingChars() const;
79
80 void setIndentationType(IndentationType type);
81 IndentationType getIndentationType();
82
83 void setIndentationAmount(int amount);
84 int getIndentationAmount();
85
86 QString getIndentation() const;
87
88 void setModifyPolicy(ModifyNamePolicy new_var);
89 ModifyNamePolicy getModifyPolicy() const;
90
91 void setAutoGenerateConstructors(bool var);
92 bool getAutoGenerateConstructors();
93
94 void setAttributeAccessorScope(Uml::Visibility::Enum var);
95 Uml::Visibility::Enum getAttributeAccessorScope();
96
97 void setAssociationFieldScope(Uml::Visibility::Enum var);
98 Uml::Visibility::Enum getAssociationFieldScope();
99
100 virtual CodeGenerationPolicyPage * createPage(QWidget *parent = 0, const char * name = 0);
101
102 QString getHeadingFile(const QString& str);
103
104 virtual void setDefaults(CodeGenerationPolicy * defaults, bool emitUpdateSignal = true);
105 virtual void setDefaults(bool emitUpdateSignal = true);
106
107 virtual void writeConfig();
108
109 void emitModifiedCodeContentSig();
110
111 void setCommentStyle(CommentStyle new_var);
112 CommentStyle getCommentStyle();
113
114 signals:
115
116 void modifiedCodeContent();
117
118 protected:
119
120 /*
121 // Policy of how to deal with overwriting existing files. Allowed values are "ask", "yes" and "no".
122 OverwritePolicy m_overwritePolicy;
123
124 // Whether or not verbose code commenting for sections is desired.
125 // If true, comments for sections will be written even if the section is empty.
126 bool m_codeVerboseSectionComments;
127
128 // Whether or not verbose code commenting for documentation is desired.
129 // If true, documentation for various code will be written even if no
130 //code would normally be created at that point in the file.
131 bool m_codeVerboseDocumentComments;
132
133 QDir m_headingFiles; // location of the header file template.
134 bool m_includeHeadings;
135 QDir m_outputDirectory; // location of where output files will go.
136 NewLineType m_lineEndingType; // What type of line ending characters to use.
137 IndentationType m_indentationType; // The amount and type of whitespace to indent with.
138 int m_indentationAmount; // The amount of units to indent with.
139 ModifyNamePolicy m_modifyPolicy;
140 bool m_autoGenerateConstructors;
141 CommentStyle m_commentStyle;
142 Uml::Visibility::Value m_attributeAccessorScope;
143 Uml::Visibility::Value m_associationFieldScope;
144 */
145
146 // these 2 private fields 'cache' the string values of other fields we may frequently call for
147 QString m_lineEndingChars;
148 QString m_indentation;
149
150 void calculateIndentation();
151
152 /*
153 protected:
154
155 void initFields();
156 */
157 };
158
159 #endif // CODEGENERATIONPOLICY_H
CodeGenerationPolicy::Ok
@ Ok
Definition: codegenerationpolicy.h:46
UmbrelloSettings::setDefaultAttributeAccessorScope
static void setDefaultAttributeAccessorScope(Uml::Visibility::Enum v)
Definition: umbrellosettings.h:1631
CodeGenerationPolicy::NONE
@ NONE
Definition: codegenerationpolicy.h:49
UmbrelloSettings::setOverwritePolicy
static void setOverwritePolicy(CodeGenerationPolicy::OverwritePolicy v)
Definition: umbrellosettings.h:1918
CodeGenerationPolicy::~CodeGenerationPolicy
virtual ~CodeGenerationPolicy()
Definition: codegenerationpolicy.cpp:64
CodeGenerationPolicy::setIndentationType
void setIndentationType(IndentationType type)
Definition: codegenerationpolicy.cpp:263
MAXLINES
#define MAXLINES
Definition: codegenerationpolicy.cpp:39
CodeGenerationPolicy::modifiedCodeContent
void modifiedCodeContent()
Definition: moc_codegenerationpolicy.cpp:130
Settings::CodeGenerationState::indentationType
CodeGenerationPolicy::IndentationType indentationType
Definition: optionstate.h:171
CodeGenerationPolicy::Ask
@ Ask
Definition: codegenerationpolicy.h:46
CodeGenerationPolicy::setModifyPolicy
void setModifyPolicy(ModifyNamePolicy new_var)
Definition: codegenerationpolicy.cpp:337
CodeGenerationPolicy::setAssociationFieldScope
void setAssociationFieldScope(Uml::Visibility::Enum var)
Definition: codegenerationpolicy.cpp:393
UmbrelloSettings::setIndentationAmount
static void setIndentationAmount(int v)
Definition: umbrellosettings.h:1771
UmbrelloSettings::forceSections
static bool forceSections()
Definition: umbrellosettings.h:1697
CodeGenerationPolicy::IndentationType
IndentationType
Definition: codegenerationpolicy.h:49
UmbrelloSettings::indentationAmount
static int indentationAmount()
Definition: umbrellosettings.h:1788
UmbrelloSettings::setForceSections
static void setForceSections(bool v)
Definition: umbrellosettings.h:1687
Settings::CodeGenerationState::lineEndingType
CodeGenerationPolicy::NewLineType lineEndingType
Definition: optionstate.h:172
CodeGenerationPolicy::setCodeVerboseDocumentComments
void setCodeVerboseDocumentComments(bool new_var)
Definition: codegenerationpolicy.cpp:139
UmbrelloSettings::setHeadingsDirectory
static void setHeadingsDirectory(const QString &v)
Definition: umbrellosettings.h:1715
CodeGenerationPolicy::calculateIndentation
void calculateIndentation()
Definition: codegenerationpolicy.cpp:312
UmbrelloSettings::indentationType
static CodeGenerationPolicy::IndentationType indentationType()
Definition: umbrellosettings.h:1816
UmbrelloSettings::autoGenEmptyConstructors
static bool autoGenEmptyConstructors()
Definition: umbrellosettings.h:1557
CodeGenerationPolicy::setCodeVerboseSectionComments
void setCodeVerboseSectionComments(bool new_var)
Definition: codegenerationpolicy.cpp:115
CodeGenerationPolicy::MAC
@ MAC
Definition: codegenerationpolicy.h:48
UmbrelloSettings::lineEndingType
static CodeGenerationPolicy::NewLineType lineEndingType()
Definition: umbrellosettings.h:1844
CodeGenerationPolicy::CodeGenerationPolicy
CodeGenerationPolicy()
Definition: codegenerationpolicy.cpp:56
CodeGenerationPolicy::setAutoGenerateConstructors
void setAutoGenerateConstructors(bool var)
Definition: codegenerationpolicy.cpp:355
CodeGenerationPolicy::MultiLine
@ MultiLine
Definition: codegenerationpolicy.h:50
UmbrelloSettings::setIndentationType
static void setIndentationType(CodeGenerationPolicy::IndentationType v)
Definition: umbrellosettings.h:1806
umbrellosettings.h
CodeGenerationPolicy::setAttributeAccessorScope
void setAttributeAccessorScope(Uml::Visibility::Enum var)
Definition: codegenerationpolicy.cpp:374
Settings::CodeGenerationState::indentationAmount
int indentationAmount
Definition: optionstate.h:170
CodeGenerationPolicy::UNIX
@ UNIX
Definition: codegenerationpolicy.h:48
CodeGenerationPolicy::Never
@ Never
Definition: codegenerationpolicy.h:46
UmbrelloSettings::overwritePolicy
static CodeGenerationPolicy::OverwritePolicy overwritePolicy()
Definition: umbrellosettings.h:1928
UmbrelloSettings::setCommentStyle
static void setCommentStyle(CodeGenerationPolicy::CommentStyle v)
Definition: umbrellosettings.h:1575
Settings::CodeGenerationState::overwritePolicy
CodeGenerationPolicy::OverwritePolicy overwritePolicy
Definition: optionstate.h:175
CodeGenerationPolicy::SPACE
@ SPACE
Definition: codegenerationpolicy.h:49
CodeGenerationPolicy::m_lineEndingChars
QString m_lineEndingChars
Definition: codegenerationpolicy.h:147
UmbrelloSettings::headingsDirectory
static QString headingsDirectory()
Definition: umbrellosettings.h:1725
Settings::CodeGenerationState::forceSections
bool forceSections
Definition: optionstate.h:167
UmbrelloSettings::setAutoGenEmptyConstructors
static void setAutoGenEmptyConstructors(bool v)
Definition: umbrellosettings.h:1547
CodeGenerationPolicy::setOverwritePolicy
void setOverwritePolicy(OverwritePolicy new_var)
Definition: codegenerationpolicy.cpp:74
UmbrelloSettings::outputDirectory
static QString outputDirectory()
Definition: umbrellosettings.h:1900
CodeGenerationPolicy::setDefaults
virtual void setDefaults(CodeGenerationPolicy *defaults, bool emitUpdateSignal=true)
Definition: codegenerationpolicy.cpp:429
CodeGenerationPolicy::emitModifiedCodeContentSig
void emitModifiedCodeContentSig()
Definition: codegenerationpolicy.cpp:420
UmbrelloSettings::setOutputDirectory
static void setOutputDirectory(const QString &v)
Definition: umbrellosettings.h:1890
CodeGenerationPolicy::getIncludeHeadings
bool getIncludeHeadings() const
Definition: codegenerationpolicy.cpp:191
Settings::CodeGenerationState::defaultAttributeAccessorScope
Uml::Visibility::Enum defaultAttributeAccessorScope
Definition: optionstate.h:165
codegenerationpolicypage.h
CodeGenerationPolicy::Cancel
@ Cancel
Definition: codegenerationpolicy.h:46
Uml::ModelType::toString
QString toString(Enum item)
Definition: basictypes.cpp:47
CodeGenerationPolicy::setHeadingFileDir
void setHeadingFileDir(const QString &path)
Definition: codegenerationpolicy.cpp:162
Settings::OptionState::codeGenerationState
CodeGenerationState codeGenerationState
Definition: optionstate.h:331
CodeGenerationPolicy::CommentStyle
CommentStyle
Definition: codegenerationpolicy.h:50
Settings::optionState
OptionState & optionState()
Definition: optionstate.cpp:362
CodeGenerationPolicy::getAssociationFieldScope
Uml::Visibility::Enum getAssociationFieldScope()
Definition: codegenerationpolicy.cpp:403
CodeGenerationPolicy::writeConfig
virtual void writeConfig()
Definition: codegenerationpolicy.cpp:508
CodeGenerationPolicy::getLineEndingType
NewLineType getLineEndingType()
Definition: codegenerationpolicy.cpp:244
UmbrelloSettings::defaultAssocFieldScope
static Uml::Visibility::Enum defaultAssocFieldScope()
Definition: umbrellosettings.h:1613
Settings::CodeGenerationState::outputDirectory
QDir outputDirectory
Definition: optionstate.h:174
UmbrelloSettings::setModnamePolicy
static void setModnamePolicy(CodeGenerationPolicy::ModifyNamePolicy v)
Definition: umbrellosettings.h:1862
UmbrelloSettings::setIncludeHeadings
static void setIncludeHeadings(bool v)
Definition: umbrellosettings.h:1743
CodeGenerationPolicy::getHeadingFile
QString getHeadingFile(const QString &str)
Definition: codegenerationpolicy.cpp:546
CodeGenerationPolicy::getModifyPolicy
ModifyNamePolicy getModifyPolicy() const
Definition: codegenerationpolicy.cpp:346
CodeGenerationPolicy::setIncludeHeadings
void setIncludeHeadings(bool new_var)
Definition: codegenerationpolicy.cpp:181
uWarning
#define uWarning()
Definition: debug_utils.h:124
CodeGenerationPolicy::TAB
@ TAB
Definition: codegenerationpolicy.h:49
Settings::CodeGenerationState::modnamePolicy
CodeGenerationPolicy::ModifyNamePolicy modnamePolicy
Definition: optionstate.h:173
CodeGenerationPolicy::getIndentation
QString getIndentation() const
Definition: codegenerationpolicy.cpp:304
CodeGenerationPolicy::No
@ No
Definition: codegenerationpolicy.h:47
CodeGenerationPolicy::setCommentStyle
void setCommentStyle(CommentStyle new_var)
Definition: codegenerationpolicy.cpp:94
CodeGenerationPolicy::getHeadingFileDir
QString getHeadingFileDir() const
Definition: codegenerationpolicy.cpp:172
UmbrelloSettings::setDefaultAssocFieldScope
static void setDefaultAssocFieldScope(Uml::Visibility::Enum v)
Definition: umbrellosettings.h:1603
basictypes.h
codegenerationpolicy.h
CodeGenerationPolicy::OverwritePolicy
OverwritePolicy
Definition: codegenerationpolicy.h:46
CodeGenerationPolicy
Definition: codegenerationpolicy.h:30
CodeGenerationPolicy::getCodeVerboseDocumentComments
bool getCodeVerboseDocumentComments() const
Definition: codegenerationpolicy.cpp:152
CodeGenerationPolicyPage
Definition: codegenerationpolicypage.h:31
UmbrelloSettings::forceDoc
static bool forceDoc()
Definition: umbrellosettings.h:1669
Settings::CodeGenerationState::includeHeadings
bool includeHeadings
Definition: optionstate.h:169
CodeGenerationPolicy::getIndentationType
IndentationType getIndentationType()
Definition: codegenerationpolicy.cpp:273
CodeGenerationPolicy::setLineEndingType
void setLineEndingType(NewLineType type)
Definition: codegenerationpolicy.cpp:221
CodeGenerationPolicy::getCommentStyle
CommentStyle getCommentStyle()
Definition: codegenerationpolicy.cpp:104
CodeGenerationPolicy::getOverwritePolicy
OverwritePolicy getOverwritePolicy() const
Definition: codegenerationpolicy.cpp:85
UMLApp::app
static UMLApp * app()
Definition: uml.cpp:278
Settings::CodeGenerationState::autoGenEmptyConstructors
bool autoGenEmptyConstructors
Definition: optionstate.h:162
CodeGenerationPolicy::ModifyNamePolicy
ModifyNamePolicy
Definition: codegenerationpolicy.h:47
CodeGenerationPolicy::getIndentationAmount
int getIndentationAmount()
Definition: codegenerationpolicy.cpp:295
CodeGenerationPolicy::SingleLine
@ SingleLine
Definition: codegenerationpolicy.h:50
Settings::CodeGenerationState::commentStyle
CodeGenerationPolicy::CommentStyle commentStyle
Definition: optionstate.h:163
Uml::Visibility::Enum
Enum
Definition: basictypes.h:59
UmbrelloSettings::includeHeadings
static bool includeHeadings()
Definition: umbrellosettings.h:1753
UmbrelloSettings::setLineEndingType
static void setLineEndingType(CodeGenerationPolicy::NewLineType v)
Definition: umbrellosettings.h:1834
CodeGenerationPolicy::setIndentationAmount
void setIndentationAmount(int amount)
Definition: codegenerationpolicy.cpp:282
CodeGenerationPolicy::DOS
@ DOS
Definition: codegenerationpolicy.h:48
uml.h
CodeGenerationPolicy::setOutputDirectory
void setOutputDirectory(QDir new_var)
Definition: codegenerationpolicy.cpp:201
CodeGenerationPolicy::NewLineType
NewLineType
Definition: codegenerationpolicy.h:48
CodeGenerationPolicy::getNewLineEndingChars
QString getNewLineEndingChars() const
Definition: codegenerationpolicy.cpp:253
debug_utils.h
CodeGenerationPolicy::getOutputDirectory
QDir getOutputDirectory()
Definition: codegenerationpolicy.cpp:211
CodeGenerationPolicy::Underscore
@ Underscore
Definition: codegenerationpolicy.h:47
UmbrelloSettings::defaultAttributeAccessorScope
static Uml::Visibility::Enum defaultAttributeAccessorScope()
Definition: umbrellosettings.h:1641
UmbrelloSettings::setForceDoc
static void setForceDoc(bool v)
Definition: umbrellosettings.h:1659
Settings::CodeGenerationState::defaultAssocFieldScope
Uml::Visibility::Enum defaultAssocFieldScope
Definition: optionstate.h:164
CodeGenerationPolicy::Capitalise
@ Capitalise
Definition: codegenerationpolicy.h:47
CodeGenerationPolicy::getAttributeAccessorScope
Uml::Visibility::Enum getAttributeAccessorScope()
Definition: codegenerationpolicy.cpp:384
Settings::CodeGenerationState::forceDoc
bool forceDoc
Definition: optionstate.h:166
UmbrelloSettings::commentStyle
static CodeGenerationPolicy::CommentStyle commentStyle()
Definition: umbrellosettings.h:1585
CodeGenerationPolicy::getAutoGenerateConstructors
bool getAutoGenerateConstructors()
Definition: codegenerationpolicy.cpp:365
UmbrelloSettings::modnamePolicy
static CodeGenerationPolicy::ModifyNamePolicy modnamePolicy()
Definition: umbrellosettings.h:1872
CodeGenerationPolicy::createPage
virtual CodeGenerationPolicyPage * createPage(QWidget *parent=0, const char *name=0)
Definition: codegenerationpolicy.cpp:412
CodeGenerationPolicy::getCodeVerboseSectionComments
bool getCodeVerboseSectionComments() const
Definition: codegenerationpolicy.cpp:127
umldoc.h
CodeGenerationPolicy::m_indentation
QString m_indentation
Definition: codegenerationpolicy.h:148
Settings::CodeGenerationState::headingsDirectory
QDir headingsDirectory
Definition: optionstate.h:168