umbrello: CPPCodeGenerator Class Reference

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

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

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

Public Slots | Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | List of all members
CPPCodeGenerator Class Reference

`#include <cppcodegenerator.h>`

Inheritance 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
CodeDocument * | newClassifierCodeDocument (UMLClassifier *classifier)
CPPHeaderCodeDocument * | newHeaderClassifierCodeDocument (UMLClassifier *classifier)
virtual CodeViewerDialog * | getCodeViewerDialog (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 ()
virtual CodeDocument * | newClassifierCodeDocument (UMLClassifier *classifier)=0
virtual CodeViewerDialog * | getCodeViewerDialog (QWidget *parent, CodeDocument *doc, Settings::CodeViewerState &state)
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)
virtual void | writeCodeToFile ()
virtual void | writeCodeToFile (UMLClassifierList &list)
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 ()
virtual void | initFromParentDocument ()=0

## Static Public Attributes
static const bool | DEFAULT_BUILD_MAKEFILE = false

## Protected Member Functions
CPPMakefileCodeDocument * | newMakefileCodeDocument ()
CPPHeaderCodeDocument * | findHeaderCodeDocumentByClassifier (UMLClassifier *classifier)
Protected Member Functions inherited from AdvancedCodeGenerator
virtual void | initFromParentDocument ()
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 *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=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
UMLDoc * | m_document

## Constructor & Destructor Documentation

## ◆ CPPCodeGenerator()

CPPCodeGenerator::CPPCodeGenerator | ( |  | ) |

Basic Constructor.

## ◆ ~CPPCodeGenerator()

CPPCodeGenerator::~CPPCodeGenerator | ( |  | ) |
| virtual

Destructor.

## Member Function Documentation

## ◆ addHeaderCodeDocument()

bool CPPCodeGenerator::addHeaderCodeDocument | ( | CPPHeaderCodeDocument * | doc | ) |

Add a header CodeDocument object from m_headercodedocumentVector List

Parameters

  doc | the header code document

Returns
  success status

## ◆ 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

  obj | the UML object

## ◆ 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

  obj | the UML object

## ◆ createDefaultStereotypes()

void CPPCodeGenerator::createDefaultStereotypes | ( |  | ) |
| virtual

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

Reimplemented from CodeGenerator.

## ◆ defaultDatatypes()

QStringList CPPCodeGenerator::defaultDatatypes | ( |  | ) | const
| virtual

Add C++ primitives as datatypes.

Returns
  a string list of C++ datatypes

Reimplemented from CodeGenerator.

## ◆ findHeaderCodeDocumentByClassifier()

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

Find a cppheadercodedocument by the given classifier.

Parameters

  classifier | UML classifier

Returns
  CPPHeaderCodeDocument object

## ◆ 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

  name | type name

Returns
  clean name

## ◆ 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

  parent | the parent widget
  doc | the code document
  state | the code viewer state

Returns
  the code viewer dialog object

Reimplemented from AdvancedCodeGenerator.

## ◆ 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.

## ◆ 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

  classifier | the classifier for which the CodeDocument is to be created

Returns
  created ClassifierCodeDocument object

Implements AdvancedCodeGenerator.

## ◆ newHeaderClassifierCodeDocument()

CPPHeaderCodeDocument * CPPCodeGenerator::newHeaderClassifierCodeDocument | ( | UMLClassifier * | classifier | ) |

Generate header classifier code document.

Parameters

  classifier | the classifier for which the CodeDocument is to be created

Returns
  created CPPHeaderCodeDocument object

## ◆ 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

## ◆ reservedKeywords()

QStringList CPPCodeGenerator::reservedKeywords | ( |  | ) | const
| virtual

Get list of reserved keywords.

Returns
  a string list with reserve keywords of this language

Reimplemented from CodeGenerator.

## ◆ 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

  writer | QXmlStreamWriter serialization target

Reimplemented from CodeGenerator.

## ◆ setCreateProjectMakefile()

void CPPCodeGenerator::setCreateProjectMakefile | ( | bool | buildIt | ) |

Set the value of m_createMakefile

Parameters

  buildIt | the new value to set for creating makefile

## ◆ 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.

## ◆ writeCodeToFile() [1/2]

void CPPCodeGenerator::writeCodeToFile | ( |  | ) |
| virtual

Write out all code documents to file as appropriate.

Reimplemented from CodeGenerator.

## ◆ 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.

## 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:

- umbrello/codegenerators/cpp/cppcodegenerator.h
- umbrello/codegenerators/cpp/cppcodegenerator.cpp