[Uml-devel] kdesdk/umbrello/umbrello

Luis De la Parra Blum lparrab at gmx.net
Wed Mar 5 17:17:16 UTC 2003


CVS commit by luis: 

added acceptAssociationType(..) method to find out if the UMLObject accepts a certain type of associaiton.
untill Umbrello gets OCL support it's either this, or a valid-associations-map


  M +20 -0     concept.cpp   1.10
  M +3 -0      concept.h   1.8
  M +5 -0      umlobject.cpp   1.3
  M +12 -0     umlobject.h   1.5


--- kdesdk/umbrello/umbrello/umlobject.h  #1.4:1.5
@@ -201,4 +201,16 @@ public:
   void setStatic(const bool bStatic);
   
+  /** This should be reimplemented by subclasses if they wish to accept certain
+        types of associations. Note that this only tells if this UMLObject can accept
+        the association type. When creating an association another check is made to see
+        if the associaiton is valid. For example a UMLClass (UMLConcept) can accept
+        generalizations and should return true. If while creating a generalization
+        the superclass is already subclassed from this, the association is not valid and
+        will not be created.
+        
+        The default accepts nothing (returns false)
+        */
+        virtual bool acceptAssociationType(Uml::Association_Type);
+  
 signals:
         void modified();  

--- kdesdk/umbrello/umbrello/umlobject.cpp  #1.2:1.3
@@ -34,4 +34,9 @@ UMLObject::UMLObject(QObject * parent) :
 UMLObject::~UMLObject() {
 }
+
+bool UMLObject::acceptAssociationType(Uml::Association_Type)
+{// A UMLObject accepts nothing. This should be reimplemented by the subclasses
+        return false;
+}
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 bool UMLObject::serialize(QDataStream *s, bool archive, int fileversion) {

--- kdesdk/umbrello/umbrello/concept.h  #1.7:1.8
@@ -225,4 +225,7 @@ public:
          */
         bool loadFromXMI( QDomElement & element );
+        
+        /** reimplemented from UMLObject*/
+        virtual bool acceptAssociationType(Uml::Association_Type);
 
 private:

--- kdesdk/umbrello/umbrello/concept.cpp  #1.9:1.10
@@ -338,4 +338,24 @@ bool UMLConcept::loadFromXMI( QDomElemen
 }
 
+bool UMLConcept::acceptAssociationType(Uml::Association_Type type)
+{
+        switch(type)
+        {
+        case at_Generalization:
+        case at_Aggregation:
+        case at_Dependency:
+        case at_Association:
+//          at_Association_Self,
+        case at_Implementation:
+        case at_Composition:
+        case at_Realization:
+        case at_UniAssociation:
+                return true;
+        default: return false;
+        }
+return false; //shutup compiler warning
+
+}
+
 int UMLConcept::templates() {
         return m_TemplateList.count();






More information about the umbrello-devel mailing list