umbrello API Documentation

codeoperation.cpp

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2004-2007                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 /*  This code generated by:
00013  *      Author : thomas
00014  *      Date   : Fri Jun 20 2003
00015  */
00016 
00017 // own header
00018 #include "codeoperation.h"
00019 
00020 // qt/kde includes
00021 #include <kdebug.h>
00022 
00023 // local includes
00024 #include "codedocument.h"
00025 #include "codegenerator.h"
00026 #include "classifiercodedocument.h"
00027 #include "uml.h"
00028 #include "umldoc.h"
00029 #include "umlobject.h"
00030 
00031 
00032 // Constructors/Destructors
00033 //
00034 
00035 CodeOperation::CodeOperation ( ClassifierCodeDocument * doc , UMLOperation * parentOp, const QString & body, const QString & comment)
00036         : CodeMethodBlock ( doc, parentOp, body, comment)
00037 {
00038     init(parentOp);
00039 }
00040 
00041 CodeOperation::~CodeOperation ( ) { }
00042 
00043 //
00044 // Methods
00045 //
00046 
00047 // Accessor methods
00048 //
00049 
00053 /*
00054 void CodeOperation::addParameter ( CodeParameter * add_object ) {
00055     m_parameterVector.append(add_object);
00056 }
00057 */
00058 
00062 /*
00063 void CodeOperation::removeParameter ( CodeParameter * remove_object ) {
00064     m_parameterVector.remove(remove_object);
00065 }
00066 */
00067 
00073 /*
00074 QPtrList<CodeParameter> CodeOperation::getParameterList ( ) {
00075     return m_parameterVector;
00076 }
00077 */
00078 
00082 UMLOperation * CodeOperation::getParentOperation( ) {
00083     return dynamic_cast<UMLOperation*>(getParentObject());
00084 }
00085 
00086 // Other methods
00087 //
00088 
00091 void CodeOperation::saveToXMI ( QDomDocument & doc, QDomElement & root ) {
00092     QDomElement blockElement = doc.createElement( "codeoperation" );
00093 
00094     // set attributes
00095     setAttributesOnNode(doc, blockElement);
00096 
00097     root.appendChild( blockElement );
00098 }
00099 
00103 void CodeOperation::loadFromXMI ( QDomElement & root )
00104 {
00105     setAttributesFromNode(root);
00106 }
00107 
00108 QString CodeOperation::findTag (UMLOperation * op) {
00109     return QString("operation_" + ID2STR(op->getID()));
00110 }
00111 
00115 void CodeOperation::setAttributesOnNode ( QDomDocument & doc, QDomElement & elem)
00116 {
00117 
00118     CodeMethodBlock::setAttributesOnNode(doc,elem); // superclass
00119 
00120 }
00121 
00125 void CodeOperation::setAttributesFromNode ( QDomElement & element)
00126 {
00127 
00128     CodeMethodBlock::setAttributesFromNode(element); // superclass
00129 
00130     // now set local attributes
00131 
00132     // oops..this is done in the parent class "ownedcodeblock".
00133     // we simply need to record the parent operation here
00134     // m_parentOperation->disconnect(this); // always disconnect from current parent
00135 
00136     QString idStr = element.attribute("parent_id","-1");
00137     Uml::IDType id = STR2ID(idStr);
00138     UMLObject * obj = UMLApp::app()->getDocument()->findObjectById(id);
00139     UMLOperation * op = dynamic_cast<UMLOperation*>(obj);
00140 
00141     if(op)
00142         init(op);
00143     else
00144         kError()<<"ERROR: could'nt load code operation because of missing UMLoperation, corrupt savefile?"<<endl;
00145 
00146 }
00147 
00148 void CodeOperation::setAttributesFromObject(TextBlock * obj)
00149 {
00150 
00151     CodeMethodBlock::setAttributesFromObject(obj);
00152 
00153     CodeOperation * op = dynamic_cast<CodeOperation*>(obj);
00154     if(op)
00155         init((UMLOperation*) op->getParentObject());
00156 
00157 }
00158 
00159 void CodeOperation::init (UMLOperation * parentOp)
00160 {
00161 
00162     m_canDelete = false; // we cant delete these with the codeeditor, delete the UML operation instead.
00163     setTag(CodeOperation::findTag(parentOp));
00164 
00165     // not needed.. done by parent "ownedcodeblock" class
00166     //  connect(parentOp,SIGNAL(modified()),this,SLOT(syncToParent()));
00167 
00168 }
00169 
00170 void CodeOperation::updateContent() {
00171     kDebug() << "CodeOperation::updateContent is called!" << endl;
00172     // Empty. Unlike codeaccessor methods for most (all?) languages
00173     // we don't auto-generate content for operations
00174 }
00175 
00176 
00177 #include "codeoperation.moc"
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:07:55 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003