[Uml-devel] kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Sat Oct 18 23:07:10 UTC 2003
CVS commit by okellogg:
findAssociation(): New.
M +27 -2 umldoc.cpp 1.88
M +18 -1 umldoc.h 1.44
--- kdesdk/umbrello/umbrello/umldoc.cpp #1.87:1.88
@@ -854,9 +854,34 @@ void UMLDoc::removeAssocFromConcepts(UML
}
+UMLAssociation * UMLDoc::findAssociation(Uml::Association_Type assocType,
+ UMLObject *roleAObj,
+ UMLObject *roleBObj,
+ bool *swap)
+{
+ UMLAssociationList assocs = getAssociations();
+ UMLAssociation *a, *ret = NULL;
+ for (a = assocs.first(); a; a = assocs.next()) {
+ if (a->getAssocType() != assocType)
+ continue;
+ if (a->getObjectA() == roleAObj && a->getObjectB() == roleBObj)
+ return a;
+ if (a->getObjectA() == roleBObj && a->getObjectB() == roleAObj) {
+ ret = a;
+ }
+ }
+ if (swap)
+ *swap = (ret != NULL);
+ return ret;
+}
+
// create AND add an association. Not currently used by anything.. remove? -b.t.
UMLAssociation* UMLDoc::createUMLAssociation(UMLObject *a, UMLObject *b, Uml::Association_Type type)
{
- UMLAssociation *assoc = new UMLAssociation( this, type, a, b );
+ bool swap;
+ UMLAssociation *assoc = findAssociation(type, a, b, &swap);
+ if (assoc == NULL) {
+ assoc = new UMLAssociation( this, type, a, b );
addAssociation(assoc);
+ }
return assoc;
}
--- kdesdk/umbrello/umbrello/umldoc.h #1.43:1.44
@@ -346,4 +346,21 @@ public:
/**
+ * Finds an association.
+ *
+ * @param assocType Type of the UMLAssociation to seek.
+ * @param roleAObj Pointer to the role A UMLCanvasObject.
+ * @param roleBObj Pointer to the role B UMLCanvasObject.
+ * @param swap Optional pointer to boolean.
+ * The bool is set to true if the assocation
+ * matched with swapped roles, else it is set
+ * to false.
+ * @return Pointer to the UMLAssociation found or NULL if not found.
+ */
+ UMLAssociation * findAssociation(Uml::Association_Type assocType,
+ UMLObject *roleAObj,
+ UMLObject *roleBObj,
+ bool *swap = NULL);
+
+ /**
* Creates a diagram of the given type.
*
@@ -732,5 +749,5 @@ public:
bool activateAllViews();
- /**
+ /** DEPRECATED - CANDIDATE FOR REMOVAL
* Puts into the list variable a list of associations on all
* diagrams that contain the given object. The view is
More information about the umbrello-devel
mailing list