summaryrefslogtreecommitdiffstats
path: root/src/uml/qumldependency.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/uml/qumldependency.cpp')
-rw-r--r--src/uml/qumldependency.cpp335
1 files changed, 61 insertions, 274 deletions
diff --git a/src/uml/qumldependency.cpp b/src/uml/qumldependency.cpp
index 97191672..2e57403f 100644
--- a/src/uml/qumldependency.cpp
+++ b/src/uml/qumldependency.cpp
@@ -40,327 +40,114 @@
****************************************************************************/
#include "qumldependency.h"
-#include <QtUml/QUmlComment>
-#include <QtUml/QUmlElement>
-#include <QtUml/QUmlNamedElement>
-#include <QtUml/QUmlNamespace>
-#include <QtUml/QUmlPackage>
-#include <QtUml/QUmlParameterableElement>
-#include <QtUml/QUmlStringExpression>
-#include <QtUml/QUmlTemplateParameter>
+#include "private/qumldependencyobject_p.h"
-QT_BEGIN_NAMESPACE
+#include <QtUml/QUmlNamedElement>
/*!
- \class UmlDependency
+ \class QUmlDependency
\inmodule QtUml
\brief A dependency is a relationship that signifies that a single or a set of model elements requires other model elements for their specification or implementation. This means that the complete semantics of the depending elements is either semantically or structurally dependent on the definition of the supplier element(s).
*/
-
-QUmlDependency::QUmlDependency(QObject *parent) :
- QObject(parent)
-{
-}
-
-// OWNED ATTRIBUTES [Element]
-
-/*!
- The Comments owned by this element.
- */
-const QSet<QUmlComment *> QUmlDependency::ownedComment() const
-{
- return *(reinterpret_cast<const QSet<QUmlComment *> *>(&_ownedComment));
-}
-
-/*!
- The Elements owned by this element.
- */
-const QSet<QUmlElement *> QUmlDependency::ownedElement() const
-{
- return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_ownedElement));
-}
-
-/*!
- The Element that owns this element.
- */
-QUmlElement *QUmlDependency::owner() const
-{
- return reinterpret_cast<QUmlElement *>(_owner);
-}
-
-// OWNED ATTRIBUTES [ParameterableElement]
-
-/*!
- The formal template parameter that owns this element.
- */
-QUmlTemplateParameter *QUmlDependency::owningTemplateParameter() const
-{
- return reinterpret_cast<QUmlTemplateParameter *>(_owningTemplateParameter);
-}
-
-/*!
- The template parameter that exposes this element as a formal parameter.
- */
-QUmlTemplateParameter *QUmlDependency::templateParameter() const
-{
- return reinterpret_cast<QUmlTemplateParameter *>(_templateParameter);
-}
-
-// OWNED ATTRIBUTES [NamedElement]
-
-/*!
- Indicates the dependencies that reference the client.
- */
-const QSet<QUmlDependency *> QUmlDependency::clientDependency() const
-{
- return *(reinterpret_cast<const QSet<QUmlDependency *> *>(&_clientDependency));
-}
-
-/*!
- The name of the NamedElement.
- */
-QString QUmlDependency::name() const
-{
- return _name;
-}
-
-/*!
- The string expression used to define the name of this named element.
- */
-QUmlStringExpression *QUmlDependency::nameExpression() const
-{
- return reinterpret_cast<QUmlStringExpression *>(_nameExpression);
-}
-
-/*!
- Specifies the namespace that owns the NamedElement.
- */
-QUmlNamespace *QUmlDependency::namespace_() const
-{
- return reinterpret_cast<QUmlNamespace *>(_namespace_);
-}
-
-/*!
- A name which allows the NamedElement to be identified within a hierarchy of nested Namespaces. It is constructed from the names of the containing namespaces starting at the root of the hierarchy and ending with the name of the NamedElement itself.
- */
-QString QUmlDependency::qualifiedName() const
-{
- return UmlNamedElement::qualifiedName();
-}
-// OWNED ATTRIBUTES [PackageableElement]
-
-/*!
- Indicates that packageable elements must always have a visibility, i.e., visibility is not optional.
- */
-QtUml::VisibilityKind QUmlDependency::visibility() const
-{
- return _visibility;
-}
-
-// OWNED ATTRIBUTES [Relationship]
-
-/*!
- Specifies the elements related by the Relationship.
- */
-const QSet<QUmlElement *> QUmlDependency::relatedElement() const
-{
- return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_relatedElement));
-}
-
-// OWNED ATTRIBUTES [DirectedRelationship]
-
-/*!
- Specifies the sources of the DirectedRelationship.
- */
-const QSet<QUmlElement *> QUmlDependency::source() const
+QUmlDependency::QUmlDependency(bool createQObject)
{
- return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_source));
+ if (createQObject)
+ _qObject = new QUmlDependencyObject(this);
}
-/*!
- Specifies the targets of the DirectedRelationship.
- */
-const QSet<QUmlElement *> QUmlDependency::target() const
+QUmlDependency::~QUmlDependency()
{
- return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_target));
+ if (!deletingFromQObject) {
+ _qObject->setProperty("deletingFromModelingObject", true);
+ delete _qObject;
+ }
}
-// OWNED ATTRIBUTES [Dependency]
+// OWNED ATTRIBUTES
/*!
The element(s) dependent on the supplier element(s). In some cases (such as a Trace Abstraction) the assignment of direction (that is, the designation of the client element) is at the discretion of the modeler, and is a stipulation.
*/
-const QSet<QUmlNamedElement *> QUmlDependency::client() const
+const QSet<QUmlNamedElement *>
+QUmlDependency::client() const
{
- return *(reinterpret_cast<const QSet<QUmlNamedElement *> *>(&_client));
-}
+ // This is a read-write association end
-/*!
- The element(s) independent of the client element(s), in the same respect and the same dependency relationship. In some directed dependency relationships (such as Refinement Abstractions), a common convention in the domain of class-based OO software is to put the more abstract element in this role. Despite this convention, users of UML may stipulate a sense of dependency suitable for their domain, which makes a more abstract element dependent on that which is more specific.
- */
-const QSet<QUmlNamedElement *> QUmlDependency::supplier() const
-{
- return *(reinterpret_cast<const QSet<QUmlNamedElement *> *>(&_supplier));
+ return _client;
}
-// OPERATIONS [Element]
-
-/*!
- The query allOwnedElements() gives all of the direct and indirect owned elements of an element.
- */
-QSet<QUmlElement *> QUmlDependency::allOwnedElements() const
+void QUmlDependency::addClient(QUmlNamedElement *client)
{
- QSet<QUmlElement *> r;
- foreach (UmlElement *element, UmlElement::allOwnedElements())
- r.insert(reinterpret_cast<QUmlElement *>(element));
- return r;
-}
+ // This is a read-write association end
-/*!
- The query mustBeOwned() indicates whether elements of this type must have an owner. Subclasses of Element that do not require an owner must override this operation.
- */
-bool QUmlDependency::mustBeOwned() const
-{
- return UmlElement::mustBeOwned();
-}
+ if (!_client.contains(client)) {
+ _client.insert(client);
+ if (client->asQObject() && this->asQObject())
+ QObject::connect(client->asQObject(), SIGNAL(destroyed(QObject*)), this->asQObject(), SLOT(removeClient(QObject *)));
-// OPERATIONS [ParameterableElement]
+ // Adjust subsetted properties
+ addSource(client);
-/*!
- The query isCompatibleWith() determines if this parameterable element is compatible with the specified parameterable element. By default parameterable element P is compatible with parameterable element Q if the kind of P is the same or a subtype as the kind of Q. Subclasses should override this operation to specify different compatibility constraints.
- */
-bool QUmlDependency::isCompatibleWith(QUmlParameterableElement *p) const
-{
- return UmlParameterableElement::isCompatibleWith(p);
+ // Adjust opposite properties
+ if (client) {
+ client->addClientDependency(this);
+ }
+ }
}
-/*!
- The query isTemplateParameter() determines if this parameterable element is exposed as a formal template parameter.
- */
-bool QUmlDependency::isTemplateParameter() const
+void QUmlDependency::removeClient(QUmlNamedElement *client)
{
- return UmlParameterableElement::isTemplateParameter();
-}
+ // This is a read-write association end
-// OPERATIONS [NamedElement]
+ if (_client.contains(client)) {
+ _client.remove(client);
-/*!
- The query allNamespaces() gives the sequence of namespaces in which the NamedElement is nested, working outwards.
- */
-QList<QUmlNamespace *> QUmlDependency::allNamespaces() const
-{
- QList<QUmlNamespace *> r;
- foreach (UmlNamespace *element, UmlNamedElement::allNamespaces())
- r.append(reinterpret_cast<QUmlNamespace *>(element));
- return r;
-}
+ // Adjust subsetted properties
+ removeSource(client);
-/*!
- The query allOwningPackages() returns all the directly or indirectly owning packages.
- */
-QSet<QUmlPackage *> QUmlDependency::allOwningPackages() const
-{
- QSet<QUmlPackage *> r;
- foreach (UmlPackage *element, UmlNamedElement::allOwningPackages())
- r.insert(reinterpret_cast<QUmlPackage *>(element));
- return r;
+ // Adjust opposite properties
+ if (client) {
+ client->removeClientDependency(this);
+ }
+ }
}
/*!
- The query isDistinguishableFrom() determines whether two NamedElements may logically co-exist within a Namespace. By default, two named elements are distinguishable if (a) they have unrelated types or (b) they have related types but different names.
+ The element(s) independent of the client element(s), in the same respect and the same dependency relationship. In some directed dependency relationships (such as Refinement Abstractions), a common convention in the domain of class-based OO software is to put the more abstract element in this role. Despite this convention, users of UML may stipulate a sense of dependency suitable for their domain, which makes a more abstract element dependent on that which is more specific.
*/
-bool QUmlDependency::isDistinguishableFrom(QUmlNamedElement *n, QUmlNamespace *ns) const
+const QSet<QUmlNamedElement *>
+QUmlDependency::supplier() const
{
- return UmlNamedElement::isDistinguishableFrom(n, ns);
-}
+ // This is a read-write association end
-/*!
- The query separator() gives the string that is used to separate names when constructing a qualified name.
- */
-QString QUmlDependency::separator() const
-{
- return UmlNamedElement::separator();
+ return _supplier;
}
-// SLOTS FOR OWNED ATTRIBUTES [Element]
-
-void QUmlDependency::addOwnedComment(UmlComment *ownedComment)
+void QUmlDependency::addSupplier(QUmlNamedElement *supplier)
{
- UmlElement::addOwnedComment(ownedComment);
-}
-
-void QUmlDependency::removeOwnedComment(UmlComment *ownedComment)
-{
- UmlElement::removeOwnedComment(ownedComment);
-}
-
-// SLOTS FOR OWNED ATTRIBUTES [ParameterableElement]
-
-void QUmlDependency::setOwningTemplateParameter(QUmlTemplateParameter *owningTemplateParameter)
-{
- UmlParameterableElement::setOwningTemplateParameter(owningTemplateParameter);
-}
-
-void QUmlDependency::setTemplateParameter(QUmlTemplateParameter *templateParameter)
-{
- UmlParameterableElement::setTemplateParameter(templateParameter);
-}
+ // This is a read-write association end
-// SLOTS FOR OWNED ATTRIBUTES [NamedElement]
+ if (!_supplier.contains(supplier)) {
+ _supplier.insert(supplier);
+ if (supplier->asQObject() && this->asQObject())
+ QObject::connect(supplier->asQObject(), SIGNAL(destroyed(QObject*)), this->asQObject(), SLOT(removeSupplier(QObject *)));
-void QUmlDependency::addClientDependency(UmlDependency *clientDependency)
-{
- UmlNamedElement::addClientDependency(clientDependency);
+ // Adjust subsetted properties
+ addTarget(supplier);
+ }
}
-void QUmlDependency::removeClientDependency(UmlDependency *clientDependency)
+void QUmlDependency::removeSupplier(QUmlNamedElement *supplier)
{
- UmlNamedElement::removeClientDependency(clientDependency);
-}
+ // This is a read-write association end
-void QUmlDependency::setName(QString name)
-{
- UmlNamedElement::setName(name);
-}
+ if (_supplier.contains(supplier)) {
+ _supplier.remove(supplier);
-void QUmlDependency::setNameExpression(QUmlStringExpression *nameExpression)
-{
- UmlNamedElement::setNameExpression(nameExpression);
+ // Adjust subsetted properties
+ removeTarget(supplier);
+ }
}
-// SLOTS FOR OWNED ATTRIBUTES [PackageableElement]
-
-void QUmlDependency::setVisibility(QtUml::VisibilityKind visibility)
-{
- UmlPackageableElement::setVisibility(visibility);
-}
-
-// SLOTS FOR OWNED ATTRIBUTES [Relationship]
-
-// SLOTS FOR OWNED ATTRIBUTES [DirectedRelationship]
-
-// SLOTS FOR OWNED ATTRIBUTES [Dependency]
-
-void QUmlDependency::addClient(UmlNamedElement *client)
-{
- UmlDependency::addClient(client);
-}
-
-void QUmlDependency::removeClient(UmlNamedElement *client)
-{
- UmlDependency::removeClient(client);
-}
-
-void QUmlDependency::addSupplier(UmlNamedElement *supplier)
-{
- UmlDependency::addSupplier(supplier);
-}
-
-void QUmlDependency::removeSupplier(UmlNamedElement *supplier)
-{
- UmlDependency::removeSupplier(supplier);
-}
-
-QT_END_NAMESPACE