[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Sun Jun 10 18:48:36 UTC 2007


SVN commit 673645 by okellogg:

m_returnId: New. Store the xmi.id of the <UML:Parameter kind="return"> to
avoid gratuitous thrashing of the ID value.


 M  +21 -4     operation.cpp  
 M  +11 -3     operation.h  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/operation.cpp #673644:673645
@@ -26,11 +26,14 @@
 #include "dialogs/umloperationdialog.h"
 
 UMLOperation::UMLOperation(const UMLClassifier *parent, const QString& name,
-                           Uml::IDType id, Uml::Visibility s, const QString& rt)
+                           Uml::IDType id, Uml::Visibility s, UMLObject *rt)
         : UMLClassifierListItem(parent, name, id)
 {
-    if (!rt.isEmpty())
-        setTypeName( rt );
+    if (rt)
+        m_returnId = UniqueID::gen();
+    else
+        m_returnId = Uml::id_None;
+    m_pSecondary = rt;
     m_Vis = s;
     m_BaseType = Uml::ot_Operation;
     m_bConst = false;
@@ -46,6 +49,12 @@
 UMLOperation::~UMLOperation() {
 }
 
+void UMLOperation::setType(UMLObject *type) {
+    UMLClassifierListItem::setType(type);
+    if (m_returnId == Uml::id_None)
+        m_returnId = UniqueID::gen();
+}
+
 void UMLOperation::moveParmLeft(UMLAttribute * a) {
     if (a == NULL) {
         kDebug() << "UMLOperation::moveParmLeft called on NULL attribute"
@@ -281,7 +290,12 @@
     QDomElement featureElement = qDoc.createElement( "UML:BehavioralFeature.parameter" );
     if (m_pSecondary) {
         QDomElement retElement = qDoc.createElement("UML:Parameter");
-        retElement.setAttribute( "xmi.id", ID2STR(UniqueID::gen()) );
+        if (m_returnId == Uml::id_None) {
+            kDebug() << "UMLOperation::saveToXMI(" << m_Name
+                << "): m_returnId is not set, setting it now." << endl;
+            m_returnId = UniqueID::gen();
+        }
+        retElement.setAttribute( "xmi.id", ID2STR(m_returnId) );
         retElement.setAttribute( "type", ID2STR(m_pSecondary->getID()) );
         retElement.setAttribute( "kind", "return" );
         featureElement.appendChild( retElement );
@@ -353,6 +367,9 @@
                 }
             }
             if (kind == "return") {
+                QString returnId = attElement.attribute("xmi.id", "");
+                if (!returnId.isEmpty())
+                    m_returnId = STR2ID(returnId);
                 m_SecondaryId = attElement.attribute( "type", "" );
                 if (m_SecondaryId.isEmpty()) {
                     // Perhaps the type is stored in a child node:
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/operation.h #673644:673645
@@ -40,7 +40,7 @@
     UMLOperation(const UMLClassifier * parent, const QString& name,
                  Uml::IDType id = Uml::id_None,
                  Uml::Visibility s = Uml::Visibility::Public,
-                 const QString& rt = QString::null);
+                 UMLObject *rt = 0);
 
     /**
      * Constructs an UMLOperation.
@@ -75,6 +75,13 @@
     virtual UMLObject* clone() const;
 
     /**
+     * Reimplement method from UMLClassifierListItem.
+     *
+     * @param type      Pointer to the type object.
+     */
+    void setType(UMLObject *type);
+
+    /**
      * Move a parameter one position to the left.
      *
      * @param a         The parameter to move.
@@ -194,8 +201,9 @@
     bool load( QDomElement & element );
 
 private:
-    UMLAttributeList m_List;
-    bool m_bConst;
+    Uml::IDType m_returnId;   ///< Holds the xmi.id of the <UML:Parameter kind="return">
+    UMLAttributeList m_List;   /// Parameter list
+    bool m_bConst;   ///< Holds the isQuery attribute of the <UML:Operation>
 };
 
 #endif




More information about the umbrello-devel mailing list