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

#include <cppcodegenerator.h>

Inheritance diagram for CPPCodeGenerator:
Collaboration diagram for CPPCodeGenerator:

Public Slots

virtual void checkAddUMLObject (UMLObject *obj)
 
virtual void checkRemoveUMLObject (UMLObject *obj)
 
virtual void syncCodeToDocument ()
 
- Public Slots inherited from AdvancedCodeGenerator
virtual void checkAddUMLObject (UMLObject *obj)
 
virtual void checkRemoveUMLObject (UMLObject *obj)
 
- Public Slots inherited from CodeGenerator
virtual void syncCodeToDocument ()
 

Public Member Functions

 CPPCodeGenerator ()
 
virtual ~CPPCodeGenerator ()
 
void setCreateProjectMakefile (bool buildIt)
 
bool getCreateProjectMakefile ()
 
QString fixTypeName (const QString &name)
 
bool addHeaderCodeDocument (CPPHeaderCodeDocument *doc)
 
bool removeHeaderCodeDocument (CPPHeaderCodeDocument *remove_object)
 
Uml::ProgrammingLanguage::Enum language () const
 
CodeDocumentnewClassifierCodeDocument (UMLClassifier *classifier)
 
CPPHeaderCodeDocumentnewHeaderClassifierCodeDocument (UMLClassifier *classifier)
 
virtual CodeViewerDialoggetCodeViewerDialog (QWidget *parent, CodeDocument *doc, Settings::CodeViewerState &state)
 
virtual void writeCodeToFile ()
 
virtual void writeCodeToFile (UMLClassifierList &list)
 
QStringList defaultDatatypes () const
 
virtual void saveToXMI (QXmlStreamWriter &writer)
 
virtual QStringList reservedKeywords () const
 
virtual void createDefaultStereotypes ()
 
void initFromParentDocument ()
 
- Public Member Functions inherited from AdvancedCodeGenerator
 AdvancedCodeGenerator ()
 
virtual ~AdvancedCodeGenerator ()
 
- Public Member Functions inherited from CodeGenerator
 CodeGenerator ()
 
virtual ~CodeGenerator ()
 
bool addCodeDocument (CodeDocument *add_object)
 
bool removeCodeDocument (CodeDocument *remove_object)
 
CodeDocumentListgetCodeDocumentList ()
 
QString getUniqueID (CodeDocument *codeDoc)
 
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 setSectionCommentPolicy (CodeGenerationPolicy::WriteSectionCommentsPolicy f)
 
bool forceSections () const
 
virtual QString getHeadingFile (const QString &file)
 
QString findFileName (CodeDocument *codeDocument)
 
virtual void loadFromXMI (QDomElement &element)
 
CodeDocumentfindCodeDocumentByClassifier (UMLClassifier *classifier)
 
virtual bool isReservedKeyword (const QString &keyword)
 

Static Public Attributes

static const bool DEFAULT_BUILD_MAKEFILE = false
 

Protected Member Functions

CPPMakefileCodeDocumentnewMakefileCodeDocument ()
 
CPPHeaderCodeDocumentfindHeaderCodeDocumentByClassifier (UMLClassifier *classifier)
 
- Protected Member Functions inherited from AdvancedCodeGenerator
void connectSlots ()
 
- 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 ()
 

Private Attributes

bool m_createMakefile
 
CodeDocumentList m_headercodedocumentVector
 

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)
 
- Protected Attributes inherited from CodeGenerator
QHash< QString, CodeDocument * > m_codeDocumentDictionary
 
bool m_applyToAllRemaining
 
UMLDocm_document
 

Constructor & Destructor Documentation

◆ CPPCodeGenerator()

CPPCodeGenerator::CPPCodeGenerator ( )

Basic Constructor.

Here is the call graph for this function:

◆ ~CPPCodeGenerator()

CPPCodeGenerator::~CPPCodeGenerator ( )
virtual

Destructor.

Member Function Documentation

◆ addHeaderCodeDocument()

bool CPPCodeGenerator::addHeaderCodeDocument ( CPPHeaderCodeDocument * doc)

Add a header CodeDocument object from m_headercodedocumentVector List

Parameters
docthe header code document
Returns
success status
Here is the call graph for this function:

◆ checkAddUMLObject

void CPPCodeGenerator::checkAddUMLObject ( UMLObject * obj)
virtualslot

Check for adding objects to the UMLDocument. They are need to be overridden here because unlike in the Java (or most other lang) we add 2 types of classifiercodedocument per classifier, e.g. a "source" and a "header" document. Need to worry about adding both source, and header documents for each classifier.

Parameters
objthe UML object
Here is the call graph for this function:

◆ checkRemoveUMLObject

void CPPCodeGenerator::checkRemoveUMLObject ( UMLObject * obj)
virtualslot

Check for removing objects to the UMLDocument. they are need to be overridden here because unlike in the Java (or most other lang) we add 2 types of classifiercodedocument per classifier, e.g. a "source" and a "header" document. Need to worry about removing both source, and header documents for each classifier.

Parameters
objthe UML object
Here is the call graph for this function:

◆ createDefaultStereotypes()

void CPPCodeGenerator::createDefaultStereotypes ( )
virtual

Add the default stereotypes for c++ (constructor, int etc)

Reimplemented from CodeGenerator.

Here is the call graph for this function:

◆ defaultDatatypes()

QStringList CPPCodeGenerator::defaultDatatypes ( ) const
virtual

Add C++ primitives as datatypes.

Returns
a string list of C++ datatypes

Reimplemented from CodeGenerator.

Here is the call graph for this function:

◆ findHeaderCodeDocumentByClassifier()

CPPHeaderCodeDocument * CPPCodeGenerator::findHeaderCodeDocumentByClassifier ( UMLClassifier * classifier)
protected

Find a cppheadercodedocument by the given classifier.

Parameters
classifierUML classifier
Returns
CPPHeaderCodeDocument object
Here is the call graph for this function:

◆ fixTypeName()

QString CPPCodeGenerator::fixTypeName ( const QString & name)

Change the following dataTypes to the ones the user really wants in their code. Not yet complete.

Parameters
nametype name
Returns
clean name
Here is the call graph for this function:

◆ getCodeViewerDialog()

CodeViewerDialog * CPPCodeGenerator::getCodeViewerDialog ( QWidget * parent,
CodeDocument * doc,
Settings::CodeViewerState & state )
virtual

Get the editing dialog for this code document. In the C++ version, we need to make both source and header files as well as the makefile available.

Parameters
parentthe parent widget
docthe code document
statethe code viewer state
Returns
the code viewer dialog object

Reimplemented from AdvancedCodeGenerator.

Here is the call graph for this function:

◆ getCreateProjectMakefile()

bool CPPCodeGenerator::getCreateProjectMakefile ( )

Get the value of m_createMakefile

Returns
the value of m_createMakefile

◆ initFromParentDocument()

void CPPCodeGenerator::initFromParentDocument ( )
virtual

Overloaded so that we may have both source and header documents for each classifier.

Reimplemented from AdvancedCodeGenerator.

Here is the call graph for this function:

◆ language()

Uml::ProgrammingLanguage::Enum CPPCodeGenerator::language ( ) const
virtual

Returns language identifier. In this case "Cpp".

Returns
language identifier

Implements CodeGenerator.

◆ newClassifierCodeDocument()

CodeDocument * CPPCodeGenerator::newClassifierCodeDocument ( UMLClassifier * classifier)
virtual

Generate classifier code document (source document version).

Parameters
classifierthe classifier for which the CodeDocument is to be created
Returns
created ClassifierCodeDocument object

Implements AdvancedCodeGenerator.

Here is the call graph for this function:

◆ newHeaderClassifierCodeDocument()

CPPHeaderCodeDocument * CPPCodeGenerator::newHeaderClassifierCodeDocument ( UMLClassifier * classifier)

Generate header classifier code document.

Parameters
classifierthe classifier for which the CodeDocument is to be created
Returns
created CPPHeaderCodeDocument object
Here is the call graph for this function:

◆ newMakefileCodeDocument()

CPPMakefileCodeDocument * CPPCodeGenerator::newMakefileCodeDocument ( )
protected

Create a new CPPMakefileCodeDocument.

Returns
CPPMakefileCodeDocument object

◆ removeHeaderCodeDocument()

bool CPPCodeGenerator::removeHeaderCodeDocument ( CPPHeaderCodeDocument * remove_object)

Remove a header CodeDocument object from m_headercodedocumentVector List

Here is the call graph for this function:

◆ reservedKeywords()

QStringList CPPCodeGenerator::reservedKeywords ( ) const
virtual

Get list of reserved keywords.

Returns
a string list with reserve keywords of this language

Reimplemented from CodeGenerator.

Here is the call graph for this function:

◆ saveToXMI()

void CPPCodeGenerator::saveToXMI ( QXmlStreamWriter & writer)
virtual

Save the XMI representation of this object. Special method needed so that we write out the header code documents.

Parameters
writerQXmlStreamWriter serialization target

Reimplemented from CodeGenerator.

Here is the call graph for this function:

◆ setCreateProjectMakefile()

void CPPCodeGenerator::setCreateProjectMakefile ( bool buildIt)

Set the value of m_createMakefile

Parameters
buildItthe new value to set for creating makefile
Here is the call graph for this function:

◆ syncCodeToDocument

void CPPCodeGenerator::syncCodeToDocument ( )
virtualslot

Force a synchronize of this code generator, and its present contents, to that of the parent UMLDocument. "UserGenerated" code will be preserved, but Autogenerated contents will be updated/replaced or removed as is apppropriate. Need to override parent method because we have header documents to consider too.

Here is the call graph for this function:

◆ writeCodeToFile() [1/2]

void CPPCodeGenerator::writeCodeToFile ( )
virtual

Write out all code documents to file as appropriate.

Reimplemented from CodeGenerator.

Here is the call graph for this function:

◆ writeCodeToFile() [2/2]

void CPPCodeGenerator::writeCodeToFile ( UMLClassifierList & concepts)
virtual

this method is here to provide class wizard the ability to write out only those classes which are selected by the user. overridden because we need to be able to generate code for both the header and source documents

Reimplemented from CodeGenerator.

Here is the call graph for this function:

Member Data Documentation

◆ DEFAULT_BUILD_MAKEFILE

const bool CPPCodeGenerator::DEFAULT_BUILD_MAKEFILE = false
static

◆ m_createMakefile

bool CPPCodeGenerator::m_createMakefile
private

◆ m_headercodedocumentVector

CodeDocumentList CPPCodeGenerator::m_headercodedocumentVector
private

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