• 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
codeaccessormethod.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) 2003 Brian Thomas <thomas@mail630.gsfc.nasa.gov> *
8  * copyright (C) 2004-2013 *
9  * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
10  ***************************************************************************/
11 
12 // own header
13 #include "codeaccessormethod.h"
14 
15 // qt/kde includes
16 
17 // local includes
18 #include "codeclassfield.h"
19 
23 CodeAccessorMethod::CodeAccessorMethod(CodeClassField * parentCF)
24  : CodeMethodBlock (parentCF->getParentDocument(), parentCF->getParentObject())
25 {
26  initFields(parentCF);
27 }
28 
32 CodeAccessorMethod::~CodeAccessorMethod()
33 {
34 }
35 
40 CodeClassField * CodeAccessorMethod::getParentClassField()
41 {
42  return m_parentclassfield;
43 }
44 
45 bool CodeAccessorMethod::parentIsAttribute()
46 {
47  return getParentClassField()->parentIsAttribute();
48 }
49 
54 /*
55 UMLObject * CodeAccessorMethod::getParentObject()
56 {
57  return getParentClassField()->getParentObject();
58 }
59 */
60 
64 CodeAccessorMethod::AccessorType CodeAccessorMethod::getType()
65 {
66  return m_accessorType;
67 }
68 
72 void CodeAccessorMethod::setType(CodeAccessorMethod::AccessorType atype)
73 {
74  m_accessorType = atype;
75 }
76 
83 void CodeAccessorMethod::release()
84 {
85  // do nothing
86 }
87 
91 void CodeAccessorMethod::forceRelease()
92 {
93  if (m_parentclassfield) {
94  m_parentclassfield->disconnect(this);
95  }
96  CodeMethodBlock::release();
97 }
98 
102 void CodeAccessorMethod::loadFromXMI(QDomElement & root)
103 {
104  setAttributesFromNode(root);
105 }
106 
110 void CodeAccessorMethod::saveToXMI(QDomDocument & doc, QDomElement & root)
111 {
112  QDomElement docElement = doc.createElement("codeaccessormethod");
113 
114  setAttributesOnNode(doc, docElement);
115 
116  root.appendChild(docElement);
117 }
118 
123 void CodeAccessorMethod::setAttributesOnNode(QDomDocument & doc, QDomElement & elem)
124 {
125  // set super-class attributes
126  CodeMethodBlock::setAttributesOnNode(doc, elem);
127 
128  // set local class attributes
129  elem.setAttribute("accessType", getType());
130  elem.setAttribute("classfield_id", getParentClassField()->ID());
131 }
132 
137 void CodeAccessorMethod::setAttributesFromNode(QDomElement & root)
138 {
139  // set attributes from the XMI
140  CodeMethodBlock::setAttributesFromNode(root); // superclass load
141 
142  /*
143  // I don't believe this is needed for a load from XMI. We never delete
144  // accessor methods from the parent classfield.. they are essentially
145  // in composition with the parent class and are arent meant to be out
146  // on their own. Well, this is fine for now, but IF we start allowing
147  // clipping and pasting of these methods between classes/ classfields
148  // then we may have problems (ugh.. I cant imagine allowing this, but
149  // perhaps someone will see a need to allow it. -b.t.)
150  QString id = root.attribute("classfield_id","-1");
151  CodeClassField * newCF = 0;
152  ClassifierCodeDocument * cdoc = dynamic_cast<ClassifierCodeDocument*>(getParentDocument());
153  if (cdoc)
154  newCF = cdoc->findCodeClassFieldFromParentID (Uml::ID::fromString(id));
155 
156  m_parentclassfield->disconnect(this); // always disconnect
157  if (newCF)
158  initFields(newCF);
159  else
160  uError()<<"ERROR: code accessor method cant load parent codeclassfield, corrupt file?"<<endl;
161 
162  */
163  // now load/set other local attributes
164  setType((AccessorType)root.attribute("accessType","0").toInt());
165 }
166 
170 void CodeAccessorMethod::setAttributesFromObject(TextBlock * obj)
171 {
172  CodeMethodBlock::setAttributesFromObject(obj);
173 
174  CodeAccessorMethod * mb = dynamic_cast<CodeAccessorMethod*>(obj);
175  if (mb) {
176  m_parentclassfield->disconnect(this); // always disconnect
177 
178  initFields(mb->getParentClassField());
179 
180  setType(mb->getType());
181  }
182 }
183 
184 void CodeAccessorMethod::initFields(CodeClassField * parentClassField)
185 {
186  m_parentclassfield = parentClassField;
187  m_accessorType = GET;
188  setCanDelete(false); // we cant delete these with the codeeditor, delete the UML operation instead.
189 
190  connect(m_parentclassfield, SIGNAL(modified()), this, SLOT(syncToParent()));
191 }
192 
193 #include "codeaccessormethod.moc"
CodeAccessorMethod::setType
void setType(AccessorType type)
Set the type of accessor method this is.
Definition: codeaccessormethod.cpp:72
CodeClassField
class CodeClassField a special type of parameter.
Definition: codeclassfield.h:29
codeaccessormethod.h
CodeAccessorMethod::saveToXMI
virtual void saveToXMI(QDomDocument &doc, QDomElement &root)
Save the XMI representation of this object.
Definition: codeaccessormethod.cpp:110
CodeAccessorMethod::getType
AccessorType getType()
Utility method to get the value of the parent object of the parent classifield.
Definition: codeaccessormethod.cpp:64
CodeMethodBlock::release
virtual void release()
Causes the text block to release all of its connections and any other text blocks that it 'owns'...
Definition: codemethodblock.cpp:76
CodeAccessorMethod::getParentClassField
CodeClassField * getParentClassField()
Get the value of m_parentclassfield.
Definition: codeaccessormethod.cpp:40
CodeAccessorMethod::AccessorType
AccessorType
Definition: codeaccessormethod.h:32
CodeAccessorMethod::~CodeAccessorMethod
virtual ~CodeAccessorMethod()
Empty Destructor.
Definition: codeaccessormethod.cpp:32
CodeAccessorMethod::CodeAccessorMethod
CodeAccessorMethod(CodeClassField *field)
Constructors.
Definition: codeaccessormethod.cpp:23
CodeAccessorMethod::setAttributesFromObject
virtual void setAttributesFromObject(TextBlock *obj)
Set the class attributes from a passed object.
Definition: codeaccessormethod.cpp:170
TextBlock::setCanDelete
void setCanDelete(bool canDelete)
Set the attribute m_canDelete.
Definition: textblock.cpp:50
CodeClassField::parentIsAttribute
bool parentIsAttribute() const
Get the value of m_isAbstract.
Definition: codeclassfield.cpp:126
CodeMethodBlock
class CodeMethodBlock A common type of "code block" that occurs in OO code.
Definition: codemethodblock.h:28
CodeAccessorMethod::setAttributesOnNode
virtual void setAttributesOnNode(QDomDocument &doc, QDomElement &blockElement)
Set attributes of the node that represents this class in the XMI document.
Definition: codeaccessormethod.cpp:123
CodeAccessorMethod::release
virtual void release()
This type of textblock is special we DON'T release it when resetTextBlocks is called because we re-us...
Definition: codeaccessormethod.cpp:83
CodeAccessorMethod
Definition: codeaccessormethod.h:20
codeclassfield.h
CodeMethodBlock::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &element)
Set the class attributes of this object from the passed element node.
Definition: codemethodblock.cpp:106
CodeAccessorMethod::setAttributesFromNode
virtual void setAttributesFromNode(QDomElement &element)
Set the class attributes of this object from the passed element node.
Definition: codeaccessormethod.cpp:137
TextBlock
The fundemental unit of text within an output file containing code.
Definition: textblock.h:24
CodeAccessorMethod::forceRelease
void forceRelease()
A method so the parent code classfield can force code block to release.
Definition: codeaccessormethod.cpp:91
CodeAccessorMethod::GET
Definition: codeaccessormethod.h:32
CodeAccessorMethod::parentIsAttribute
bool parentIsAttribute()
Definition: codeaccessormethod.cpp:45
CodeMethodBlock::setAttributesOnNode
virtual void setAttributesOnNode(QDomDocument &doc, QDomElement &blockElement)
Set attributes of the node that represents this class in the XMI document.
Definition: codemethodblock.cpp:87
CodeMethodBlock::syncToParent
virtual void syncToParent()
Definition: codemethodblock.cpp:169
CodeMethodBlock::setAttributesFromObject
virtual void setAttributesFromObject(TextBlock *obj)
Set the class attributes from a passed object.
Definition: codemethodblock.cpp:124
CodeAccessorMethod::loadFromXMI
virtual void loadFromXMI(QDomElement &root)
Load params from the appropriate XMI element node.
Definition: codeaccessormethod.cpp:102
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