umbrello 2.34.70-5524f40e1
Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology
Public Slots | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SimpleCodeGenerator Class Referenceabstract

#include <simplecodegenerator.h>

Inheritance diagram for SimpleCodeGenerator:
Collaboration 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)
 
CodeDocumentListgetCodeDocumentList ()
 
QString getUniqueID (CodeDocument *codeDoc)
 
virtual void saveToXMI (QXmlStreamWriter &writer)
 
CodeDocumentfindCodeDocumentByID (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 setForceSections (bool 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
 
CodeDocumentfindCodeDocumentByClassifier (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 *concept, const QString &ext)
 
QString overwritableName (UMLPackage *concept, 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
 
UMLDocm_document
 

Additional Inherited Members

- Public Types inherited from CodeGenerator
enum  GenerationState { Generated , Failed , Skipped }
 
- Signals inherited from CodeGenerator
void codeGenerated (UMLClassifier *concept, bool generated)
 
void codeGenerated (UMLClassifier *concept, 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=QLatin1String(" *"), 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.

Here is the call graph for this function:

◆ ~SimpleCodeGenerator()

SimpleCodeGenerator::~SimpleCodeGenerator ( )
virtual

Destructor.

Member Function Documentation

◆ findFileName()

QString SimpleCodeGenerator::findFileName ( UMLPackage concept,
const QString &  ext 
)
protected

Determine the file name.

Parameters
conceptthe package
extthe file extension
Returns
the valid file name
Here is the call graph for this function:

◆ hasAbstractOps()

bool SimpleCodeGenerator::hasAbstractOps ( UMLClassifier c)
protected

Check whether classifier has abstract operations.

Parameters
cthe classifier to check
Returns
true when classifier has abstract operations
Here is the call graph for this function:

◆ hasDefaultValueAttr()

bool SimpleCodeGenerator::hasDefaultValueAttr ( UMLClassifier c)
protected

Check whether classifier has default values for attributes.

Parameters
cthe classifier to check
Returns
true when classifier attributes has default values
Here is the call graph for this function:

◆ 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 concept,
const QString &  name,
const QString &  ext 
)
protected

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

Parameters
conceptthe package
namethe name of the file
extthe extension of the file
Returns
the valid filename or null
Here is the call graph for this function:

◆ syncCodeToDocument

void SimpleCodeGenerator::syncCodeToDocument ( )
virtualslot

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

Here is the call graph for this function:

◆ writeClass()

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

Call this method to generate code for a UMLClassifier

Parameters
cthe 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.

Here is the call graph for this function:

◆ writeCodeToFile() [2/2]

void SimpleCodeGenerator::writeCodeToFile ( UMLClassifierList concepts)
virtual

Write only selected concepts to file.

Parameters
conceptsthe selected concepts

Reimplemented from CodeGenerator.

Here is the call graph for this function:

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: