umbrello: umbrello/codegenerators/codegenerationpolicy.h Source File

umbrello 2.31.1 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
CodeGenerationPolicy::NONE
@ NONE
Definition: codegenerationpolicy.h:49
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()
Settings::CodeGenerationState::indentationType
CodeGenerationPolicy::IndentationType indentationType
Definition: optionstate.h:179
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
CodeGenerationPolicy::IndentationType
IndentationType
Definition: codegenerationpolicy.h:49
Settings::CodeGenerationState::lineEndingType
CodeGenerationPolicy::NewLineType lineEndingType
Definition: optionstate.h:180
CodeGenerationPolicy::setCodeVerboseDocumentComments
void setCodeVerboseDocumentComments(bool new_var)
Definition: codegenerationpolicy.cpp:139
CodeGenerationPolicy::calculateIndentation
void calculateIndentation()
Definition: codegenerationpolicy.cpp:312
CodeGenerationPolicy::setCodeVerboseSectionComments
void setCodeVerboseSectionComments(bool new_var)
Definition: codegenerationpolicy.cpp:115
CodeGenerationPolicy::MAC
@ MAC
Definition: codegenerationpolicy.h:48
CodeGenerationPolicy::CodeGenerationPolicy
CodeGenerationPolicy()
Definition: codegenerationpolicy.cpp:56
CodeGenerationPolicy::setAutoGenerateConstructors
void setAutoGenerateConstructors(bool var)
Definition: codegenerationpolicy.cpp:355
CodeGenerationPolicy::MultiLine
@ MultiLine
Definition: codegenerationpolicy.h:50
CodeGenerationPolicy::setAttributeAccessorScope
void setAttributeAccessorScope(Uml::Visibility::Enum var)
Definition: codegenerationpolicy.cpp:374
Settings::CodeGenerationState::indentationAmount
int indentationAmount
Definition: optionstate.h:178
CodeGenerationPolicy::UNIX
@ UNIX
Definition: codegenerationpolicy.h:48
CodeGenerationPolicy::Never
@ Never
Definition: codegenerationpolicy.h:46
Settings::CodeGenerationState::overwritePolicy
CodeGenerationPolicy::OverwritePolicy overwritePolicy
Definition: optionstate.h:183
CodeGenerationPolicy::SPACE
@ SPACE
Definition: codegenerationpolicy.h:49
CodeGenerationPolicy::m_lineEndingChars
QString m_lineEndingChars
Definition: codegenerationpolicy.h:147
Settings::CodeGenerationState::forceSections
bool forceSections
Definition: optionstate.h:175
CodeGenerationPolicy::setOverwritePolicy
void setOverwritePolicy(OverwritePolicy new_var)
Definition: codegenerationpolicy.cpp:74
CodeGenerationPolicy::setDefaults
virtual void setDefaults(CodeGenerationPolicy *defaults, bool emitUpdateSignal=true)
Definition: codegenerationpolicy.cpp:429
CodeGenerationPolicy::emitModifiedCodeContentSig
void emitModifiedCodeContentSig()
Definition: codegenerationpolicy.cpp:420
CodeGenerationPolicy::getIncludeHeadings
bool getIncludeHeadings() const
Definition: codegenerationpolicy.cpp:191
Settings::CodeGenerationState::defaultAttributeAccessorScope
Uml::Visibility::Enum defaultAttributeAccessorScope
Definition: optionstate.h:173
codegenerationpolicypage.h
CodeGenerationPolicy::Cancel
@ Cancel
Definition: codegenerationpolicy.h:46
Uml::ModelType::toString
QString toString(Enum item)
Definition: basictypes.cpp:81
CodeGenerationPolicy::setHeadingFileDir
void setHeadingFileDir(const QString &path)
Definition: codegenerationpolicy.cpp:162
Settings::OptionState::codeGenerationState
CodeGenerationState codeGenerationState
Definition: optionstate.h:339
CodeGenerationPolicy::CommentStyle
CommentStyle
Definition: codegenerationpolicy.h:50
Settings::optionState
OptionState & optionState()
Definition: optionstate.cpp:370
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
Settings::CodeGenerationState::outputDirectory
QDir outputDirectory
Definition: optionstate.h:182
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:181
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
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
Settings::CodeGenerationState::includeHeadings
bool includeHeadings
Definition: optionstate.h:177
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:269
Settings::CodeGenerationState::autoGenEmptyConstructors
bool autoGenEmptyConstructors
Definition: optionstate.h:170
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:171
Uml::Visibility::Enum
Enum
Definition: basictypes.h:76
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
Settings::CodeGenerationState::defaultAssocFieldScope
Uml::Visibility::Enum defaultAssocFieldScope
Definition: optionstate.h:172
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:174
CodeGenerationPolicy::getAutoGenerateConstructors
bool getAutoGenerateConstructors()
Definition: codegenerationpolicy.cpp:365
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:176