• 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
  • ruby
rubyclassdeclarationblock.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) 2005 *
8  * Richard Dale <Richard_Dale@tipitina.demon.co.uk> *
9  * copyright (C) 2006-2013 *
10  * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
11  ***************************************************************************/
12 
13 #include "rubyclassdeclarationblock.h"
14 #include "rubycodedocumentation.h"
15 #include "rubycodegenerator.h"
16 #include "uml.h"
17 
18 RubyClassDeclarationBlock::RubyClassDeclarationBlock
19  (RubyClassifierCodeDocument * parentDoc, const QString &startText, const QString &endText, const QString &comment)
20  : OwnedHierarchicalCodeBlock(parentDoc->getParentClassifier(), parentDoc, startText, endText, comment)
21 {
22  init(parentDoc, comment);
23 }
24 
25 RubyClassDeclarationBlock::~RubyClassDeclarationBlock ()
26 {
27 }
28 
32 void RubyClassDeclarationBlock::saveToXMI (QDomDocument & doc, QDomElement & root)
33 {
34  QDomElement blockElement = doc.createElement("rubyclassdeclarationblock");
35 
36  setAttributesOnNode(doc, blockElement);
37 
38  root.appendChild(blockElement);
39 }
40 
44 void RubyClassDeclarationBlock::loadFromXMI (QDomElement & root)
45 {
46  setAttributesFromNode(root);
47 }
48 
52 void RubyClassDeclarationBlock::updateContent ()
53 {
54  RubyClassifierCodeDocument *parentDoc = dynamic_cast<RubyClassifierCodeDocument*>(getParentDocument());
55  UMLClassifier *c = parentDoc->getParentClassifier();
56  CodeGenerationPolicy * p = UMLApp::app()->commonPolicy();
57  QString endLine = p->getNewLineEndingChars();
58  bool isInterface = parentDoc->parentIsInterface(); // a little shortcut
59  QString RubyClassName = parentDoc->getRubyClassName(c->name());
60  bool forceDoc = p->getCodeVerboseDocumentComments();
61 
62  // COMMENT
63  QString comment = c->doc();
64  comment.remove("@ref ");
65  comment.replace("@see", "_See_");
66  comment.replace("@short", "_Summary_");
67  comment.replace("@author", "_Author_");
68 
69  if (isInterface)
70  getComment()->setText("Module " + RubyClassName + endLine + comment);
71  else
72  getComment()->setText("Class " + RubyClassName + endLine + comment);
73 
74  if (forceDoc || !c->doc().isEmpty())
75  getComment()->setWriteOutText(true);
76  else
77  getComment()->setWriteOutText(false);
78 
79  // Now set START/ENDING Text
80  QString startText = "";
81 
82  if (parentDoc->parentIsInterface()) {
83  startText.append("module ");
84  } else {
85  startText.append("class ");
86  }
87 
88  UMLClassifierList superclasses = c->findSuperClassConcepts(UMLClassifier::CLASS);
89  UMLClassifierList superinterfaces = c->findSuperClassConcepts(UMLClassifier::INTERFACE);
90 
91  // write out inheritance
92  startText.append(RubyClassName);
93 
94  int i = 0;
95  foreach (UMLClassifier* concept, superclasses) {
96  if (i == 0) {
97  startText.append(QString(" < ") + RubyCodeGenerator::cppToRubyType(concept->name()) + endLine);
98  } else {
99  // After the first superclass name in the list, assume the classes
100  // are ruby modules that can be mixed in,
101  startText.append("include " + RubyCodeGenerator::cppToRubyType(concept->name()) + endLine);
102  }
103  i++;
104  }
105 
106  // Write out the interfaces we 'implement'. Are these modules to be mixed in, in Ruby?
107  foreach (UMLClassifier* concept, superinterfaces) {
108  startText.append(QString("include ") + RubyCodeGenerator::cppToRubyType(concept->name()) + endLine);
109  }
110 
111  // Set the header and end text for the hier.codeblock
112  setStartText(startText);
113 }
114 
115 void RubyClassDeclarationBlock::init (RubyClassifierCodeDocument *parentDoc, const QString &comment)
116 {
117  setComment(new RubyCodeDocumentation(parentDoc));
118  getComment()->setText(comment);
119 
120  setEndText("end");
121 }
122 
123 #include "rubyclassdeclarationblock.moc"
RubyClassifierCodeDocument::getRubyClassName
QString getRubyClassName(const QString &name)
Definition: rubyclassifiercodedocument.cpp:87
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
RubyClassDeclarationBlock::~RubyClassDeclarationBlock
virtual ~RubyClassDeclarationBlock()
Empty Destructor.
Definition: rubyclassdeclarationblock.cpp:25
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
RubyCodeDocumentation
class RubyCodeDocumentation A Ruby code comment.
Definition: rubycodedocumentation.h:29
RubyClassDeclarationBlock::saveToXMI
virtual void saveToXMI(QDomDocument &doc, QDomElement &root)
Save the XMI representation of this object.
Definition: rubyclassdeclarationblock.cpp:32
UMLApp::app
static UMLApp * app()
Get the last created instance of this class.
Definition: uml.cpp:206
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
RubyClassDeclarationBlock::loadFromXMI
virtual void loadFromXMI(QDomElement &root)
load params from the appropriate XMI element node.
Definition: rubyclassdeclarationblock.cpp:44
RubyClassDeclarationBlock::updateContent
void updateContent()
Update the start/end text of this codeblock.
Definition: rubyclassdeclarationblock.cpp:52
rubyclassdeclarationblock.h
CodeGenerationPolicy::getCodeVerboseDocumentComments
bool getCodeVerboseDocumentComments() const
Get the value of m_codeVerboseDocumentComments Whether or not verbose code commenting for documentati...
Definition: codegenerationpolicy.cpp:147
OwnedHierarchicalCodeBlock::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &element)
set the class attributes of this object from the passed element node.
Definition: ownedhierarchicalcodeblock.cpp:83
RubyClassifierCodeDocument
class RubyClassifierCodeDocument A Ruby UMLClassifier Code Document.
Definition: rubyclassifiercodedocument.h:36
RubyClassDeclarationBlock::RubyClassDeclarationBlock
RubyClassDeclarationBlock(RubyClassifierCodeDocument *parentDoc, const QString &start="", const QString &endText="end", const QString &comment="")
Empty Constructor.
Definition: rubyclassdeclarationblock.cpp:19
ClassifierCodeDocument::parentIsInterface
bool parentIsInterface()
Return if the parent classifier is an interface.
Definition: classifiercodedocument.cpp:413
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
UMLClassifierList
QList< UMLClassifier * > UMLClassifierList
Definition: umlclassifierlist.h:17
rubycodedocumentation.h
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
UMLClassifier::findSuperClassConcepts
UMLClassifierList findSuperClassConcepts(ClassifierType type=ALL)
Returns a list of concepts which this concept inherits from.
Definition: classifier.cpp:616
UMLClassifier::CLASS
Definition: classifier.h:47
UMLObject::name
QString name() const
Returns a copy of m_name.
Definition: umlobject.cpp:185
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
rubycodegenerator.h
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
RubyCodeGenerator::cppToRubyType
static QString cppToRubyType(const QString &cppType)
Convert a C++ type such as 'int' or 'QWidget' to ruby types Integer and Qt::Widget.
Definition: rubycodegenerator.cpp:110
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:06:00 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