umbrello: SimpleCodeGenerator Class Reference

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

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

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Slots | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SimpleCodeGenerator Class Referenceabstract

`#include <simplecodegenerator.h>`

Inheritance diagram for SimpleCodeGenerator:

## Public Slots
virtual void | syncCodeToDocument ()
Public Slots inherited from CodeGenerator
virtual void | syncCodeToDocument ()

## Public Member Functions
| SimpleCodeGenerator (bool createDirHierarchyForPackages=true)
virtual | ~SimpleCodeGenerator ()
void | writeCodeToFile (UMLClassifierList &concepts)
void | writeCodeToFile ()
virtual void | writeClass (UMLClassifier *c)=0
Public Member Functions inherited from CodeGenerator
| CodeGenerator ()
virtual | ~CodeGenerator ()
bool | addCodeDocument (CodeDocument *add_object)
bool | removeCodeDocument (CodeDocument *remove_object)
CodeDocumentList * | getCodeDocumentList ()
QString | getUniqueID (CodeDocument *codeDoc)
virtual void | saveToXMI (QXmlStreamWriter &writer)
CodeDocument * | findCodeDocumentByID (const QString &id)
void | setIncludeHeadings (bool i)
bool | includeHeadings () const
void | setHeadingFileDir (const QString &)
QString | headingFileDir () const
void | setForceDoc (bool f)
bool | forceDoc () const
void | setSectionCommentPolicy (CodeGenerationPolicy::WriteSectionCommentsPolicy f)
bool | forceSections () const
virtual QString | getHeadingFile (const QString &file)
QString | findFileName (CodeDocument *codeDocument)
virtual void | loadFromXMI (QDomElement &element)
virtual Uml::ProgrammingLanguage::Enum | language () const =0
CodeDocument * | findCodeDocumentByClassifier (UMLClassifier *classifier)
virtual QStringList | defaultDatatypes () const
virtual bool | isReservedKeyword (const QString &keyword)
virtual QStringList | reservedKeywords () const
virtual void | createDefaultStereotypes ()

## Protected Member Functions
QString | findFileName (UMLPackage *classifier, const QString &ext)
QString | overwritableName (UMLPackage *classifier, const QString &name, const QString &ext)
bool | hasDefaultValueAttr (UMLClassifier *c)
bool | hasAbstractOps (UMLClassifier *c)
QString | indent ()
virtual void | initFromParentDocument ()
Protected Member Functions inherited from CodeGenerator
QString | overwritableName (const QString &name, const QString &extension)
bool | openFile (QFile &file, const QString &name)
void | writeListedCodeDocsToFile (CodeDocumentList *docs)
virtual void | finalizeRun ()

## Protected Attributes
QString | className_
QString | fileName_
QMap< UMLPackage *, QString > | m_fileMap
bool | m_createDirHierarchyForPackages
QString | m_indentation
int | m_indentLevel
QString | m_endl
Protected Attributes inherited from CodeGenerator
QHash< QString, CodeDocument * > | m_codeDocumentDictionary
bool | m_applyToAllRemaining
UMLDoc * | m_document

## Additional Inherited Members
Public Types inherited from CodeGenerator
enum | GenerationState { Generated , Failed , Skipped }
Signals inherited from CodeGenerator
void | codeGenerated (UMLClassifier *classifier, bool generated)
void | codeGenerated (UMLClassifier *classifier, CodeGenerator::GenerationState result)
void | showGeneratedFile (const QString &filename)
Static Public Member Functions inherited from CodeGenerator
static QString | cleanName (const QString &name)
static QString | formatDoc (const QString &text, const QString &linePrefix=QStringLiteral(" *"), int lineWidth=80)
static QString | formatFullDocBlock (const QString &text, const QString &blockHeader=QStringLiteral("/* "), const QString &blockFooter=QStringLiteral(" */"), const QString &linePrefix=QStringLiteral(" *"), int lineWidth=80)
static QString | formatSourceCode (const QString &code, const QString &indentation)
static void | findObjectsRelated (UMLClassifier *c, UMLPackageList &cList)

## Detailed Description

A simple code generator interface designed to work with the existing codewriters.

Code can be entered into a QTextEdit widget in the ClassPropertiesDialog. This code is then stored in the respective UMLOperation, written to the xmi file, and also used when generating the source files. The code fragments are stored into the xmi file in the section "codegeneration" with the tag "sourcecode".

## Constructor & Destructor Documentation

## ◆ SimpleCodeGenerator()

SimpleCodeGenerator::SimpleCodeGenerator | ( | bool | createDirHierarchyForPackages = true | ) |
| explicit

Constructor.

## ◆ ~SimpleCodeGenerator()

SimpleCodeGenerator::~SimpleCodeGenerator | ( |  | ) |
| virtual

Destructor.

## Member Function Documentation

## ◆ findFileName()

QString SimpleCodeGenerator::findFileName | ( | UMLPackage * | classifier,
|  | const QString & | ext )
| protected

Determine the file name.

Parameters

  classifier | the package
  ext | the file extension

Returns
  the valid file name

## ◆ hasAbstractOps()

bool SimpleCodeGenerator::hasAbstractOps | ( | UMLClassifier * | c | ) |
| protected

Check whether classifier has abstract operations.

Parameters

  c | the classifier to check

Returns
  true when classifier has abstract operations

## ◆ hasDefaultValueAttr()

bool SimpleCodeGenerator::hasDefaultValueAttr | ( | UMLClassifier * | c | ) |
| protected

Check whether classifier has default values for attributes.

Parameters

  c | the classifier to check

Returns
  true when classifier attributes has default values

## ◆ indent()

QString SimpleCodeGenerator::indent | ( |  | ) |
| protected

Returns the current indent string based on m_indentLevel and m_indentation.

Returns
  indentation string

## ◆ initFromParentDocument()

void SimpleCodeGenerator::initFromParentDocument | ( |  | ) |
| protectedvirtual

Override parent method.

Implements CodeGenerator.

## ◆ overwritableName()

QString SimpleCodeGenerator::overwritableName | ( | UMLPackage * | classifier,
|  | const QString & | name,
|  | const QString & | ext )
| protected

Check if a file named "name" with extension "ext" already exists.

Parameters

  classifier | the package
  name | the name of the file
  ext | the extension of the file

Returns
  the valid filename or null

## ◆ syncCodeToDocument

void SimpleCodeGenerator::syncCodeToDocument | ( |  | ) |
| virtualslot

A little method to provide some compatibility between the newer codegenpolicy object and the older class fields.

## ◆ writeClass()

virtual void SimpleCodeGenerator::writeClass | ( | UMLClassifier * | c | ) |
| pure virtual

Call this method to generate code for a UMLClassifier

Parameters

  c | the class you want to generate code for.

Implemented in AdaWriter, ASWriter, CppWriter, CSharpWriter, DWriter, IDLWriter, JavaWriter, JSWriter, PascalWriter, PerlWriter, Php5Writer, PhpWriter, PythonWriter, RubyWriter, SQLWriter, TclWriter, ValaWriter, and XMLSchemaWriter.

## ◆ writeCodeToFile() [1/2]

void SimpleCodeGenerator::writeCodeToFile | ( |  | ) |
| virtual

Write all concepts in project to file.

Reimplemented from CodeGenerator.

## ◆ writeCodeToFile() [2/2]

void SimpleCodeGenerator::writeCodeToFile | ( | UMLClassifierList & | concepts | ) |
| virtual

Write only selected concepts to file.

Parameters

  concepts | the selected concepts

Reimplemented from CodeGenerator.

## Member Data Documentation

## ◆ className_

QString SimpleCodeGenerator::className_
| protected

## ◆ fileName_

QString SimpleCodeGenerator::fileName_
| protected

## ◆ m_createDirHierarchyForPackages

bool SimpleCodeGenerator::m_createDirHierarchyForPackages
| protected

For some code generators, it does not make much sense to create a directory for each package because that would lead to a rather sparsely populated directory tree (maximum of just one source file per directory.)

## ◆ m_endl

QString SimpleCodeGenerator::m_endl
| protected

## ◆ m_fileMap

QMap<UMLPackage*, QString> SimpleCodeGenerator::m_fileMap
| protected

Maps UMLObjects to filenames. Used for finding out which file each class was written to.

## ◆ m_indentation

QString SimpleCodeGenerator::m_indentation
| protected

## ◆ m_indentLevel

int SimpleCodeGenerator::m_indentLevel
| protected

The documentation for this class was generated from the following files:

- umbrello/codegenerators/simplecodegenerator.h
- umbrello/codegenerators/simplecodegenerator.cpp