• 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
rubycodeclassfield.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 // own header
14 #include "rubycodeclassfield.h"
15 
16 // local includes
17 #include "attribute.h"
18 #include "debug_utils.h"
19 #include "rubyclassifiercodedocument.h"
20 #include "rubycodecomment.h"
21 #include "rubycodegenerator.h"
22 #include "umlobject.h"
23 #include "umlrole.h"
24 #include "uml.h"
25 
26 // qt includes
27 #include <QRegExp>
28 
29 RubyCodeClassField::RubyCodeClassField (ClassifierCodeDocument * parentDoc, UMLRole * role)
30  : CodeClassField(parentDoc, role)
31 {
32 }
33 
34 RubyCodeClassField::RubyCodeClassField (ClassifierCodeDocument * parentDoc, UMLAttribute * attrib)
35  : CodeClassField(parentDoc, attrib)
36 {
37 }
38 
39 RubyCodeClassField::~RubyCodeClassField ()
40 {
41 }
42 
43 QString RubyCodeClassField::getFieldName()
44 {
45  if (parentIsAttribute())
46  {
47  UMLAttribute * at = (UMLAttribute*) getParentObject();
48  return cleanName(at->name());
49  }
50  else
51  {
52  UMLRole * role = (UMLRole*) getParentObject();
53  QString roleName = role->name();
54  if(fieldIsSingleValue()) {
55  return roleName.replace(0, 1, roleName.left(1).toLower());
56  } else {
57  return roleName.toLower() + "Array";
58  }
59  }
60 }
61 
62 
63 QString RubyCodeClassField::getInitialValue()
64 {
65  if (parentIsAttribute())
66  {
67  UMLAttribute * at = dynamic_cast<UMLAttribute*>(getParentObject());
68  if (at) {
69  return fixInitialStringDeclValue(at->getInitialValue(), getTypeName());
70  } else {
71  uError() << "parent object is not a UMLAttribute";
72  return "";
73  }
74  return fixInitialStringDeclValue(at->getInitialValue(), getTypeName());
75  }
76  else
77  {
78  if(fieldIsSingleValue()) {
79  // FIX : IF the multiplicity is "1" then we should init a new object here, if it is 0 or 1,
80  // then we can just return 'empty' string (minor problem).
81  return QString("");
82  } else {
83  return RubyCodeGenerator::getListFieldClassName()+".new()";
84  }
85  }
86 
87 }
88 
89 QString RubyCodeClassField::getTypeName ()
90 {
91  return RubyCodeGenerator::cppToRubyType(CodeClassField::getTypeName());
92 }
93 
94 #include "rubycodeclassfield.moc"
umlobject.h
CodeClassField
class CodeClassField a special type of parameter.
Definition: codeclassfield.h:29
ClassifierCodeDocument
class ClassifierCodeDocument A CodeDocument which represents a UMLClassifier (e.g.
Definition: classifiercodedocument.h:33
UMLAttribute::getInitialValue
QString getInitialValue() const
Returns The initial value of the UMLAttribute.
Definition: attribute.cpp:98
umlrole.h
RubyCodeClassField::getTypeName
QString getTypeName()
Get the value of m_dialog.
Definition: rubycodeclassfield.cpp:89
rubycodecomment.h
UMLAttribute
This class is used to set up information for an attribute.
Definition: attribute.h:27
RubyCodeClassField::getFieldName
QString getFieldName()
Definition: rubycodeclassfield.cpp:43
debug_utils.h
RubyCodeClassField::~RubyCodeClassField
virtual ~RubyCodeClassField()
Empty Destructor.
Definition: rubycodeclassfield.cpp:39
attribute.h
CodeClassField::parentIsAttribute
bool parentIsAttribute() const
Get the value of m_isAbstract.
Definition: codeclassfield.cpp:126
RubyCodeGenerator::getListFieldClassName
static QString getListFieldClassName()
Get the list variable class name to use.
Definition: rubycodegenerator.cpp:99
RubyCodeClassField::RubyCodeClassField
RubyCodeClassField(ClassifierCodeDocument *parentDoc, UMLRole *role)
Constructors.
Definition: rubycodeclassfield.cpp:29
CodeClassField::cleanName
QString cleanName(const QString &name)
A little utility method to make life easier for code document programmers.
Definition: codeclassfield.cpp:373
CodeClassField::fixInitialStringDeclValue
QString fixInitialStringDeclValue(const QString &val, const QString &type)
Another utility method to make life easier for code document programmers this one fixes the initial d...
Definition: codeclassfield.cpp:383
rubycodeclassfield.h
rubyclassifiercodedocument.h
UMLRole
This class contains the non-graphic representation of an association role.
Definition: umlrole.h:24
uError
#define uError()
Definition: debug_utils.h:96
UMLObject::name
QString name() const
Returns a copy of m_name.
Definition: umlobject.cpp:185
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
rubycodegenerator.h
CodeClassField::getTypeName
QString getTypeName()
Get the value of m_dialog.
Definition: codeclassfield.cpp:94
CodeParameter::getParentObject
UMLObject * getParentObject()
Get the ParentObject object.
Definition: codeparameter.cpp:141
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
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