/*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * copyright (C) 2004-2007 * * Umbrello UML Modeller Authors * ***************************************************************************/ /* This code generated by: * Author : thomas * Date : Tue Jul 1 2003 */ // own header #include "codeaccessormethod.h" // qt/kde includes #include // local includes #include "classifiercodedocument.h" #include "codeclassfield.h" #include "attribute.h" #include "umlobject.h" #include "umlrole.h" // Constructors/Destructors // CodeAccessorMethod::CodeAccessorMethod ( CodeClassField * tqparentCF ) : CodeMethodBlock ( tqparentCF->getParentDocument(), tqparentCF->getParentObject() ) { initFields(tqparentCF); } CodeAccessorMethod::~CodeAccessorMethod ( ) { } // // Methods // // Accessor methods // /** * Get the value of m_parentclassfield * @return the value of m_parentclassfield */ CodeClassField * CodeAccessorMethod::getParentClassField ( ) { return m_parentclassfield; } bool CodeAccessorMethod::tqparentIsAttribute( ) { return getParentClassField()->tqparentIsAttribute(); } /** * Utility method to get the value of the tqparent object of the tqparent classifield. * @return the value of the tqparent of the tqparent classfield */ /* UMLObject * CodeAccessorMethod::getParentObject ( ) { return getParentClassField()->getParentObject(); } */ /** return the type of accessor method this is */ CodeAccessorMethod::AccessorType CodeAccessorMethod::getType( ) { return m_accessorType; } /** Set the type of accessor method this is */ void CodeAccessorMethod::setType ( CodeAccessorMethod::AccessorType atype) { m_accessorType = atype; } // Other methods // // this type of textblock is special // we DON'T release it when resetTextBlocks is // called because we re-use it over and over // until the codeclassfield is released. void CodeAccessorMethod::release () { // do nothing } // ok, a method so the tqparent can force it to release void CodeAccessorMethod::forceRelease () { if(m_parentclassfield) m_parentclassfield->disconnect(this); CodeMethodBlock::release(); } /** * load params from the appropriate XMI element node. */ void CodeAccessorMethod::loadFromXMI ( TQDomElement & root ) { setAttributesFromNode(root); } /** * Save the XMI representation of this object */ void CodeAccessorMethod::saveToXMI ( TQDomDocument & doc, TQDomElement & root ) { TQDomElement docElement = doc.createElement( "codeaccessormethod" ); setAttributesOnNode(doc, docElement); root.appendChild( docElement ); } /** set attributes of the node that represents this class * in the XMI document. */ void CodeAccessorMethod::setAttributesOnNode ( TQDomDocument & doc, TQDomElement & elem) { // set super-class attributes CodeMethodBlock::setAttributesOnNode(doc, elem); // set local class attributes elem.setAttribute("accessType",getType()); elem.setAttribute("classfield_id",getParentClassField()->getID()); } /** set the class attributes of this object from * the passed element node. */ void CodeAccessorMethod::setAttributesFromNode ( TQDomElement & root) { // set attributes from the XMI CodeMethodBlock::setAttributesFromNode(root); // superclass load /* // I don't believe this is needed for a load from XMI. We never delete // accessor methods from the tqparent classfield.. they are essentially // in composition with the tqparent class and are arent meant to be out // on their own. Well, this is fine for now, but IF we start allowing // clipping and pasting of these methods between classes/ classfields // then we may have problems (ugh.. I cant imagine allowing this, but // perhaps someone will see a need to allow it. -b.t.) TQString id = root.attribute("classfield_id","-1"); CodeClassField * newCF = 0; ClassifierCodeDocument * cdoc = dynamic_cast(getParentDocument()); if(cdoc) newCF = cdoc->findCodeClassFieldFromParentID (STR2ID(id)); m_parentclassfield->disconnect(this); // always disconnect if(newCF) initFields(newCF); else kError()<<"ERROR: code accessor method cant load tqparent codeclassfield, corrupt file?"<(obj); if(mb) { m_parentclassfield->disconnect(this); // always disconnect initFields(mb->getParentClassField()); setType(mb->getType()); } } void CodeAccessorMethod::initFields(CodeClassField * tqparentClassField ) { m_parentclassfield = tqparentClassField; m_accessorType = GET; m_canDelete = false; // we cant delete these with the codeeditor, delete the UML operation instead. connect(m_parentclassfield,TQT_SIGNAL(modified()),this,TQT_SLOT(syncToParent())); } #include "codeaccessormethod.moc"