• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

umbrello/umbrello

  • sources
  • kde-4.12
  • kdesdk
  • umbrello
  • umbrello
  • codegenerators
  • d
dclassdeclarationblock.cpp
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) 2007 Jari-Matti Mäkelä <jmjm@iki.fi> *
8  * copyright (C) 2008-2013 *
9  * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
10  ***************************************************************************/
11 
12 #include "dclassdeclarationblock.h"
13 
14 #include "dcodegenerator.h"
15 #include "dcodegenerationpolicy.h"
16 #include "dcodedocumentation.h"
17 #include "model_utils.h"
18 #include "uml.h"
19 
20 DClassDeclarationBlock::DClassDeclarationBlock
21  (DClassifierCodeDocument * parentDoc, const QString &startText, const QString &endText, const QString &comment)
22  : OwnedHierarchicalCodeBlock(parentDoc->getParentClassifier(), parentDoc, startText, endText, comment)
23 {
24  init(parentDoc, comment);
25 }
26 
27 DClassDeclarationBlock::~DClassDeclarationBlock ()
28 {
29 }
30 
31 void DClassDeclarationBlock::loadFromXMI (QDomElement & root)
32 {
33  setAttributesFromNode(root);
34 }
35 
36 void DClassDeclarationBlock::setAttributesFromObject (TextBlock * obj)
37 {
38  HierarchicalCodeBlock::setAttributesFromObject(obj);
39 }
40 
41 void DClassDeclarationBlock::saveToXMI (QDomDocument & doc, QDomElement & root)
42 {
43  QDomElement blockElement = doc.createElement("dclassdeclarationblock");
44 
45  setAttributesOnNode(doc, blockElement);
46 
47  root.appendChild(blockElement);
48 }
49 
50 void DClassDeclarationBlock::updateContent ()
51 {
52  DClassifierCodeDocument *parentDoc = dynamic_cast<DClassifierCodeDocument*>(getParentDocument());
53  UMLClassifier *c = parentDoc->getParentClassifier();
54  CodeGenerationPolicy *commonPolicy = UMLApp::app()->commonPolicy();
55  QString endLine = commonPolicy->getNewLineEndingChars();
56  bool isInterface = parentDoc->parentIsInterface(); // a little shortcut
57  QString DClassName = parentDoc->getDClassName(c->name());
58 
59  // COMMENT
60 
61  getComment()->setText(
62  (isInterface ? "Interface " : "Class ") +
63  DClassName + endLine + c->doc());
64 
65  bool forceDoc = commonPolicy->getCodeVerboseDocumentComments();
66 
67  getComment()->setWriteOutText(forceDoc || !c->doc().isEmpty());
68 
69  /*
70  * Class declaration
71  *
72  * (private) class foo : class1, ..., classN, interface1, ..., interfaceN {
73  * a b c d e f g
74  */
75 
76  QString startText = "";
77 
78  // (a) visibility modifier
79  switch(c->visibility()) {
80  case Uml::Visibility::Private: startText += "private "; break;
81  default: break;
82  }
83 
84  // (b) keyword
85  if (isInterface) {
86  startText += "interface ";
87  } else {
88  if (c->isAbstract()) {
89  startText += "abstract ";
90  }
91 
92  startText += "class ";
93  }
94 
95  // (c) class name
96  startText += DClassName;
97 
98  // (d) inheritances
99  UMLClassifierList superclasses =
100  c->findSuperClassConcepts(UMLClassifier::CLASS);
101  UMLClassifierList superinterfaces =
102  c->findSuperClassConcepts(UMLClassifier::INTERFACE);
103 
104  int count = superclasses.count() + superinterfaces.count();
105 
106  if (count > 0) startText += " : ";
107 
108  // (e) base classes
109  foreach (UMLClassifier* concept, superclasses) {
110  startText += parentDoc->cleanName(concept->name());
111 
112  count--;
113 
114  if (count>0) startText += ", ";
115  }
116 
117  // (f) interfaces
118  foreach (UMLClassifier* concept, superinterfaces) {
119  startText += parentDoc->cleanName(concept->name());
120 
121  count--;
122 
123  if (count>0) startText += ", ";
124  }
125 
126  // (g) block start
127  startText += " {";
128 
129  setStartText(startText);
130 }
131 
132 void DClassDeclarationBlock::init (DClassifierCodeDocument *parentDoc, const QString &comment)
133 {
134  setComment(new DCodeDocumentation(parentDoc));
135  getComment()->setText(comment);
136 
137  setEndText("}");
138 }
139 
140 
141 #include "dclassdeclarationblock.moc"
UniqueID::init
void init()
Reinitialize the unique ID counter.
Definition: uniqueid.cpp:37
UMLClassifier
This class defines the non-graphical information required for a UML Classifier (ie a class or interfa...
Definition: classifier.h:39
OwnedHierarchicalCodeBlock
class OwnedHierarchicalCodeBlock A "chunk" of code within the code document that is "owned" by some u...
Definition: ownedhierarchicalcodeblock.h:26
CodeBlockWithComments::getComment
CodeComment * getComment() const
Get the Comment object.
Definition: codeblockwithcomments.cpp:46
UMLClassifier::INTERFACE
Definition: classifier.h:47
UMLObject::visibility
Uml::Visibility::Enum visibility() const
Returns the visibility of the object.
Definition: umlobject.cpp:435
DClassifierCodeDocument::getDClassName
QString getDClassName(const QString &name)
Definition: dclassifiercodedocument.cpp:87
TextBlock::setText
void setText(const QString &text)
Set the value of m_text The actual text of this code block.
Definition: textblock.cpp:80
CodeGenerationPolicy::getNewLineEndingChars
QString getNewLineEndingChars() const
Utility function to get the actual characters.
Definition: codegenerationpolicy.cpp:248
UMLApp::app
static UMLApp * app()
Get the last created instance of this class.
Definition: uml.cpp:206
DClassDeclarationBlock::updateContent
void updateContent()
Update the start and end text for this hierarchical codeblock.
Definition: dclassdeclarationblock.cpp:50
HierarchicalCodeBlock::setEndText
void setEndText(const QString &new_var)
Set the value of m_endText.
Definition: hierarchicalcodeblock.cpp:43
CodeGenerationPolicy
class CodeGenerationPolicy This class describes the code generation policy for this project...
Definition: codegenerationpolicy.h:29
ClassifierCodeDocument::getParentClassifier
UMLClassifier * getParentClassifier()
Get the value of m_parentclassifier.
Definition: classifiercodedocument.cpp:271
model_utils.h
Uml::Visibility::Private
Definition: basictypes.h:58
dclassdeclarationblock.h
DClassDeclarationBlock::DClassDeclarationBlock
DClassDeclarationBlock(DClassifierCodeDocument *parentDoc, const QString &start="", const QString &endText="}", const QString &comment="")
Empty Constructor.
Definition: dclassdeclarationblock.cpp:21
DClassDeclarationBlock::setAttributesFromObject
virtual void setAttributesFromObject(TextBlock *obj)
Set the class attributes from a passed object.
Definition: dclassdeclarationblock.cpp:36
CodeGenerationPolicy::getCodeVerboseDocumentComments
bool getCodeVerboseDocumentComments() const
Get the value of m_codeVerboseDocumentComments Whether or not verbose code commenting for documentati...
Definition: codegenerationpolicy.cpp:147
HierarchicalCodeBlock::setAttributesFromObject
virtual void setAttributesFromObject(TextBlock *obj)
set the class attributes from a passed object
Definition: hierarchicalcodeblock.cpp:297
OwnedHierarchicalCodeBlock::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &element)
set the class attributes of this object from the passed element node.
Definition: ownedhierarchicalcodeblock.cpp:83
DCodeDocumentation
A class representing a D documentation comment.
Definition: dcodedocumentation.h:27
ClassifierCodeDocument::parentIsInterface
bool parentIsInterface()
Return if the parent classifier is an interface.
Definition: classifiercodedocument.cpp:413
DClassifierCodeDocument
A D UMLClassifier Code Document.
Definition: dclassifiercodedocument.h:36
TextBlock::setWriteOutText
void setWriteOutText(bool write)
Set the value of m_writeOutText Whether or not to include the text of this TextBlock into a file...
Definition: textblock.cpp:131
DClassDeclarationBlock::loadFromXMI
virtual void loadFromXMI(QDomElement &root)
Load params from the appropriate XMI element node.
Definition: dclassdeclarationblock.cpp:31
UMLClassifierList
QList< UMLClassifier * > UMLClassifierList
Definition: umlclassifierlist.h:17
HierarchicalCodeBlock::setStartText
void setStartText(const QString &text)
Definition: hierarchicalcodeblock.cpp:199
UMLApp::commonPolicy
CodeGenerationPolicy * commonPolicy() const
Returns the default code generation policy.
Definition: uml.cpp:2132
CodeDocument::cleanName
QString cleanName(const QString &name)
A little utility method which calls CodeGenerator::cleanName.
Definition: codedocument.cpp:269
UMLClassifier::findSuperClassConcepts
UMLClassifierList findSuperClassConcepts(ClassifierType type=ALL)
Returns a list of concepts which this concept inherits from.
Definition: classifier.cpp:616
DClassDeclarationBlock::~DClassDeclarationBlock
virtual ~DClassDeclarationBlock()
Empty Destructor.
Definition: dclassdeclarationblock.cpp:27
TextBlock
The fundemental unit of text within an output file containing code.
Definition: textblock.h:24
UMLClassifier::CLASS
Definition: classifier.h:47
dcodedocumentation.h
dcodegenerator.h
UMLObject::name
QString name() const
Returns a copy of m_name.
Definition: umlobject.cpp:185
dcodegenerationpolicy.h
OwnedHierarchicalCodeBlock::setAttributesOnNode
virtual void setAttributesOnNode(QDomDocument &doc, QDomElement &blockElement)
set attributes of the node that represents this class in the XMI document.
Definition: ownedhierarchicalcodeblock.cpp:57
DClassDeclarationBlock::saveToXMI
virtual void saveToXMI(QDomDocument &doc, QDomElement &root)
Save the XMI representation of this object.
Definition: dclassdeclarationblock.cpp:41
UMLObject::isAbstract
bool isAbstract() const
Returns the abstract state of the object.
Definition: umlobject.cpp:312
CodeBlockWithComments::setComment
void setComment(CodeComment *object)
Set the Comment object.
Definition: codeblockwithcomments.cpp:38
OwnedHierarchicalCodeBlock::getParentDocument
CodeDocument * getParentDocument()
Return the parent code document.
Definition: ownedhierarchicalcodeblock.cpp:93
uml.h
UMLObject::doc
QString doc() const
Returns the documentation for the object.
Definition: umlobject.cpp:404
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:05:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

umbrello/umbrello

Skip menu "umbrello/umbrello"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal