• 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
rubycodeclassfielddeclarationblock.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 "rubycodeclassfielddeclarationblock.h"
14 
15 #include "classifier.h"
16 #include "codegenerator.h"
17 #include "rubycodeclassfield.h"
18 #include "rubyclassifiercodedocument.h"
19 #include "rubycodegenerationpolicy.h"
20 #include "umlrole.h"
21 #include "uml.h"
22 
26 RubyCodeClassFieldDeclarationBlock::RubyCodeClassFieldDeclarationBlock(CodeClassField * parent)
27  : CodeClassFieldDeclarationBlock(parent)
28 {
29  setOverallIndentationLevel(1);
30 }
31 
35 RubyCodeClassFieldDeclarationBlock::~RubyCodeClassFieldDeclarationBlock()
36 {
37 }
38 
42 void RubyCodeClassFieldDeclarationBlock::updateContent()
43 {
44  CodeClassField * cf = getParentClassField();
45  RubyCodeClassField * rcf = dynamic_cast<RubyCodeClassField*>(cf);
46  CodeGenerationPolicy * p = UMLApp::app()->commonPolicy();
47  Uml::Visibility::Enum scopePolicy = p->getAssociationFieldScope();
48 
49  // Set the comment
50  QString notes = getParentObject()->doc();
51  getComment()->setText(notes);
52 
53  // Set the body
54  QString staticValue = getParentObject()->isStatic() ? "static " : "";
55  QString scopeStr = Uml::Visibility::toString(getParentObject()->visibility());
56 
57  // IF this is from an association, then scope taken as appropriate to policy
58  if(!rcf->parentIsAttribute())
59  {
60  switch (scopePolicy) {
61  case Uml::Visibility::Public:
62  case Uml::Visibility::Private:
63  case Uml::Visibility::Protected:
64  scopeStr = Uml::Visibility::toString(scopePolicy);
65  break;
66  default:
67  case Uml::Visibility::FromParent:
68  // do nothing here... will leave as from parent object
69  break;
70  }
71  }
72 
73  QString typeName = rcf->getTypeName();
74  QString fieldName = rcf->getFieldName();
75  QString initialV = rcf->getInitialValue();
76 
77  if (!cf->parentIsAttribute() && !cf->fieldIsSingleValue())
78  typeName = "Array";
79 
80  QString body = staticValue+scopeStr+' '+typeName+' '+fieldName;
81  if (!initialV.isEmpty())
82  body.append(" = " + initialV);
83  else if (!cf->parentIsAttribute())
84  {
85  UMLRole * role = dynamic_cast<UMLRole*>(cf->getParentObject());
86  if (role->object()->baseType() == UMLObject::ot_Interface)
87  {
88  // do nothing.. can't instanciate an interface
89  } else {
90 
91  // FIX?: IF a constructor method exists in the classifiercodedoc
92  // of the parent Object, then we can use that instead (if its empty).
93  if(cf->fieldIsSingleValue())
94  {
95  if(!typeName.isEmpty())
96  body.append(" = " + typeName + ".new()");
97  } else
98  body.append(" = []");
99  }
100  }
101 
102  setText(body);
103 }
104 
105 #include "rubycodeclassfielddeclarationblock.moc"
CodeClassField
class CodeClassField a special type of parameter.
Definition: codeclassfield.h:29
CodeBlockWithComments::getComment
CodeComment * getComment() const
Get the Comment object.
Definition: codeblockwithcomments.cpp:46
Uml::Visibility::Enum
Enum
Definition: basictypes.h:56
TextBlock::setText
void setText(const QString &text)
Set the value of m_text The actual text of this code block.
Definition: textblock.cpp:80
umlrole.h
rubycodegenerationpolicy.h
RubyCodeClassField::getTypeName
QString getTypeName()
Get the value of m_dialog.
Definition: rubycodeclassfield.cpp:89
UMLApp::app
static UMLApp * app()
Get the last created instance of this class.
Definition: uml.cpp:206
CodeBlockWithComments::setOverallIndentationLevel
void setOverallIndentationLevel(int level)
A utility method that causes the comment and body of the code block to have the same indentation leve...
Definition: codeblockwithcomments.cpp:163
CodeGenerationPolicy
class CodeGenerationPolicy This class describes the code generation policy for this project...
Definition: codegenerationpolicy.h:29
CodeClassFieldDeclarationBlock
Used to declare classifier fields (e.g.
Definition: codeclassfielddeclarationblock.h:29
RubyCodeClassField::getFieldName
QString getFieldName()
Definition: rubycodeclassfield.cpp:43
classifier.h
CodeClassFieldDeclarationBlock::getParentObject
UMLObject * getParentObject()
A utility method to get the parent object of the parentCodeClassfield.
Definition: codeclassfielddeclarationblock.cpp:48
rubycodeclassfielddeclarationblock.h
Uml::Visibility::Private
Definition: basictypes.h:58
codegenerator.h
CodeGenerationPolicy::getAssociationFieldScope
Uml::Visibility::Enum getAssociationFieldScope()
Get the value of m_associationFieldScope.
Definition: codegenerationpolicy.cpp:403
CodeClassField::parentIsAttribute
bool parentIsAttribute() const
Get the value of m_isAbstract.
Definition: codeclassfield.cpp:126
Uml::Visibility::toString
QString toString(Enum item, bool mnemonic)
Convert Visibility item into QString representation.
Definition: basictypes.cpp:99
UMLRole::object
UMLObject * object() const
Returns the UMLObject assigned to the role.
Definition: umlrole.cpp:76
UMLApp::commonPolicy
CodeGenerationPolicy * commonPolicy() const
Returns the default code generation policy.
Definition: uml.cpp:2132
Uml::Visibility::Public
Definition: basictypes.h:57
UMLObject::baseType
ObjectType baseType() const
Returns the type of the object.
Definition: umlobject.cpp:366
RubyCodeClassFieldDeclarationBlock::RubyCodeClassFieldDeclarationBlock
RubyCodeClassFieldDeclarationBlock(CodeClassField *parent)
Constructor.
Definition: rubycodeclassfielddeclarationblock.cpp:26
UMLObject::ot_Interface
Definition: umlobject.h:53
UMLObject::isStatic
bool isStatic() const
Returns true if this UMLObject has classifier scope, otherwise false (the default).
Definition: umlobject.cpp:335
rubycodeclassfield.h
CodeClassFieldDeclarationBlock::getParentClassField
CodeClassField * getParentClassField()
Get the value of m_parentclassfield.
Definition: codeclassfielddeclarationblock.cpp:40
rubyclassifiercodedocument.h
UMLRole
This class contains the non-graphic representation of an association role.
Definition: umlrole.h:24
RubyCodeClassFieldDeclarationBlock::~RubyCodeClassFieldDeclarationBlock
virtual ~RubyCodeClassFieldDeclarationBlock()
Empty Destructor.
Definition: rubycodeclassfielddeclarationblock.cpp:35
RubyCodeClassFieldDeclarationBlock::updateContent
void updateContent()
This will be called by syncToParent whenever the parent object is "modified".
Definition: rubycodeclassfielddeclarationblock.cpp:42
RubyCodeClassField::getInitialValue
QString getInitialValue()
Get the value of m_initialValue The initial value of this code parameter.
Definition: rubycodeclassfield.cpp:63
CodeClassField::fieldIsSingleValue
bool fieldIsSingleValue()
Determine whether the parent object in this classfield indicates that it is a single variable or a Li...
Definition: codeclassfield.cpp:604
Uml::Visibility::FromParent
Definition: basictypes.h:61
Uml::Visibility::Protected
Definition: basictypes.h:59
CodeParameter::getParentObject
UMLObject * getParentObject()
Get the ParentObject object.
Definition: codeparameter.cpp:141
uml.h
UMLObject::doc
QString doc() const
Returns the documentation for the object.
Definition: umlobject.cpp:404
RubyCodeClassField
Definition: rubycodeclassfield.h:22
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