summaryrefslogtreecommitdiffstats
path: root/src/uml/qumlgeneralization.cpp
diff options
context:
space:
mode:
authorSandro S. Andrade <sandroandrade@kde.org>2013-09-02 22:02:41 -0300
committerSandro S. Andrade <sandroandrade@kde.org>2013-09-03 03:04:37 +0200
commita143fe8c5451493b128b4c6f0750f02b58af8666 (patch)
tree4b74787f6ece9256db04dc65002cae749f6936b3 /src/uml/qumlgeneralization.cpp
parent2bfe659e4d30b449747585e18eeb84bfc5d73f43 (diff)
Add initial version of new UML metamodel implementation
Change-Id: Ic29a04dc49fac075d9c736237573b7f4e3da85ef Reviewed-by: Sandro S. Andrade <sandroandrade@kde.org>
Diffstat (limited to 'src/uml/qumlgeneralization.cpp')
-rw-r--r--src/uml/qumlgeneralization.cpp205
1 files changed, 92 insertions, 113 deletions
diff --git a/src/uml/qumlgeneralization.cpp b/src/uml/qumlgeneralization.cpp
index cda73f1e..0674bfd0 100644
--- a/src/uml/qumlgeneralization.cpp
+++ b/src/uml/qumlgeneralization.cpp
@@ -40,177 +40,156 @@
****************************************************************************/
#include "qumlgeneralization.h"
+#include "private/qumlgeneralizationobject_p.h"
+
#include <QtUml/QUmlClassifier>
-#include <QtUml/QUmlComment>
-#include <QtUml/QUmlElement>
#include <QtUml/QUmlGeneralizationSet>
-QT_BEGIN_NAMESPACE
-
/*!
- \class UmlGeneralization
+ \class QUmlGeneralization
\inmodule QtUml
\brief A generalization is a taxonomic relationship between a more general classifier and a more specific classifier. Each instance of the specific classifier is also an indirect instance of the general classifier. Thus, the specific classifier inherits the features of the more general classifier.A generalization relates a specific classifier to a more general classifier, and is owned by the specific classifier.
*/
-
-QUmlGeneralization::QUmlGeneralization(QObject *parent) :
- QObject(parent)
+QUmlGeneralization::QUmlGeneralization(bool createQObject) :
+ _general(0),
+ _isSubstitutable(true),
+ _specific(0)
{
+ if (createQObject)
+ _qObject = new QUmlGeneralizationObject(this);
}
-// OWNED ATTRIBUTES [Element]
-
-/*!
- The Comments owned by this element.
- */
-const QSet<QUmlComment *> QUmlGeneralization::ownedComment() const
+QUmlGeneralization::~QUmlGeneralization()
{
- return *(reinterpret_cast<const QSet<QUmlComment *> *>(&_ownedComment));
+ if (!deletingFromQObject) {
+ _qObject->setProperty("deletingFromModelingObject", true);
+ delete _qObject;
+ }
}
+// OWNED ATTRIBUTES
+
/*!
- The Elements owned by this element.
+ References the general classifier in the Generalization relationship.
*/
-const QSet<QUmlElement *> QUmlGeneralization::ownedElement() const
+QUmlClassifier *
+QUmlGeneralization::general() const
{
- return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_ownedElement));
+ // This is a read-write association end
+
+ return _general;
}
-/*!
- The Element that owns this element.
- */
-QUmlElement *QUmlGeneralization::owner() const
+void QUmlGeneralization::setGeneral(QUmlClassifier *general)
{
- return reinterpret_cast<QUmlElement *>(_owner);
-}
+ // This is a read-write association end
-// OWNED ATTRIBUTES [Relationship]
+ if (_general != general) {
+ // Adjust subsetted properties
+ removeTarget(_general);
-/*!
- Specifies the elements related by the Relationship.
- */
-const QSet<QUmlElement *> QUmlGeneralization::relatedElement() const
-{
- return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_relatedElement));
-}
+ _general = general;
+ if (general->asQObject() && this->asQObject())
+ QObject::connect(general->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setGeneral()));
-// OWNED ATTRIBUTES [DirectedRelationship]
+ // Adjust subsetted properties
+ if (general) {
+ addTarget(general);
+ }
+ }
+}
/*!
- Specifies the sources of the DirectedRelationship.
+ Designates a set in which instances of Generalization is considered members.
*/
-const QSet<QUmlElement *> QUmlGeneralization::source() const
+const QSet<QUmlGeneralizationSet *>
+QUmlGeneralization::generalizationSet() const
{
- return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_source));
+ // This is a read-write association end
+
+ return _generalizationSet;
}
-/*!
- Specifies the targets of the DirectedRelationship.
- */
-const QSet<QUmlElement *> QUmlGeneralization::target() const
+void QUmlGeneralization::addGeneralizationSet(QUmlGeneralizationSet *generalizationSet)
{
- return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_target));
-}
+ // This is a read-write association end
-// OWNED ATTRIBUTES [Generalization]
+ if (!_generalizationSet.contains(generalizationSet)) {
+ _generalizationSet.insert(generalizationSet);
+ if (generalizationSet->asQObject() && this->asQObject())
+ QObject::connect(generalizationSet->asQObject(), SIGNAL(destroyed(QObject*)), this->asQObject(), SLOT(removeGeneralizationSet(QObject *)));
-/*!
- References the general classifier in the Generalization relationship.
- */
-QUmlClassifier *QUmlGeneralization::general() const
-{
- return reinterpret_cast<QUmlClassifier *>(_general);
+ // Adjust opposite properties
+ if (generalizationSet) {
+ generalizationSet->addGeneralization(this);
+ }
+ }
}
-/*!
- Designates a set in which instances of Generalization is considered members.
- */
-const QSet<QUmlGeneralizationSet *> QUmlGeneralization::generalizationSet() const
+void QUmlGeneralization::removeGeneralizationSet(QUmlGeneralizationSet *generalizationSet)
{
- return *(reinterpret_cast<const QSet<QUmlGeneralizationSet *> *>(&_generalizationSet));
+ // This is a read-write association end
+
+ if (_generalizationSet.contains(generalizationSet)) {
+ _generalizationSet.remove(generalizationSet);
+
+ // Adjust opposite properties
+ if (generalizationSet) {
+ generalizationSet->removeGeneralization(this);
+ }
+ }
}
/*!
Indicates whether the specific classifier can be used wherever the general classifier can be used. If true, the execution traces of the specific classifier will be a superset of the execution traces of the general classifier.
*/
-bool QUmlGeneralization::isSubstitutable() const
+bool
+QUmlGeneralization::isSubstitutable() const
{
+ // This is a read-write property
+
return _isSubstitutable;
}
-/*!
- References the specializing classifier in the Generalization relationship.
- */
-QUmlClassifier *QUmlGeneralization::specific() const
+void QUmlGeneralization::setSubstitutable(bool isSubstitutable)
{
- return reinterpret_cast<QUmlClassifier *>(_specific);
-}
+ // This is a read-write property
-// OPERATIONS [Element]
-
-/*!
- The query allOwnedElements() gives all of the direct and indirect owned elements of an element.
- */
-QSet<QUmlElement *> QUmlGeneralization::allOwnedElements() const
-{
- QSet<QUmlElement *> r;
- foreach (UmlElement *element, UmlElement::allOwnedElements())
- r.insert(reinterpret_cast<QUmlElement *>(element));
- return r;
+ if (_isSubstitutable != isSubstitutable) {
+ _isSubstitutable = isSubstitutable;
+ }
}
/*!
- 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.
+ References the specializing classifier in the Generalization relationship.
*/
-bool QUmlGeneralization::mustBeOwned() const
-{
- return UmlElement::mustBeOwned();
-}
-
-// SLOTS FOR OWNED ATTRIBUTES [Element]
-
-void QUmlGeneralization::addOwnedComment(UmlComment *ownedComment)
+QUmlClassifier *
+QUmlGeneralization::specific() const
{
- UmlElement::addOwnedComment(ownedComment);
-}
+ // This is a read-write association end
-void QUmlGeneralization::removeOwnedComment(UmlComment *ownedComment)
-{
- UmlElement::removeOwnedComment(ownedComment);
+ return _specific;
}
-// SLOTS FOR OWNED ATTRIBUTES [Relationship]
-
-// SLOTS FOR OWNED ATTRIBUTES [DirectedRelationship]
-
-// SLOTS FOR OWNED ATTRIBUTES [Generalization]
-
-void QUmlGeneralization::setGeneral(QUmlClassifier *general)
-{
- UmlGeneralization::setGeneral(general);
-}
-
-void QUmlGeneralization::addGeneralizationSet(UmlGeneralizationSet *generalizationSet)
+void QUmlGeneralization::setSpecific(QUmlClassifier *specific)
{
- UmlGeneralization::addGeneralizationSet(generalizationSet);
-}
+ // This is a read-write association end
-void QUmlGeneralization::removeGeneralizationSet(UmlGeneralizationSet *generalizationSet)
-{
- UmlGeneralization::removeGeneralizationSet(generalizationSet);
-}
+ if (_specific != specific) {
+ // Adjust subsetted properties
+ removeSource(_specific);
-void QUmlGeneralization::setSubstitutable(bool isSubstitutable)
-{
- UmlGeneralization::setSubstitutable(isSubstitutable);
-}
+ _specific = specific;
+ if (specific->asQObject() && this->asQObject())
+ QObject::connect(specific->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setSpecific()));
-void QUmlGeneralization::setSpecific(QUmlClassifier *specific)
-{
- UmlGeneralization::setSpecific(specific);
+ // Adjust subsetted properties
+ setOwner(specific);
+ if (specific) {
+ addSource(specific);
+ }
+ }
}
-QT_END_NAMESPACE
-