summaryrefslogtreecommitdiffstats
path: root/src/uml/qumlactivityedge.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/qumlactivityedge.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/qumlactivityedge.cpp')
-rw-r--r--src/uml/qumlactivityedge.cpp475
1 files changed, 209 insertions, 266 deletions
diff --git a/src/uml/qumlactivityedge.cpp b/src/uml/qumlactivityedge.cpp
index abecb407..b28fc27c 100644
--- a/src/uml/qumlactivityedge.cpp
+++ b/src/uml/qumlactivityedge.cpp
@@ -44,399 +44,342 @@
#include <QtUml/QUmlActivityGroup>
#include <QtUml/QUmlActivityNode>
#include <QtUml/QUmlActivityPartition>
-#include <QtUml/QUmlClassifier>
-#include <QtUml/QUmlComment>
-#include <QtUml/QUmlDependency>
-#include <QtUml/QUmlElement>
#include <QtUml/QUmlInterruptibleActivityRegion>
-#include <QtUml/QUmlNamedElement>
-#include <QtUml/QUmlNamespace>
-#include <QtUml/QUmlPackage>
-#include <QtUml/QUmlRedefinableElement>
-#include <QtUml/QUmlStringExpression>
#include <QtUml/QUmlStructuredActivityNode>
#include <QtUml/QUmlValueSpecification>
-QT_BEGIN_NAMESPACE
-
/*!
- \class UmlActivityEdge
+ \class QUmlActivityEdge
\inmodule QtUml
\brief Activity edges can be contained in interruptible regions.An activity edge is an abstract class for directed connections between two activity nodes.
*/
-
-QUmlActivityEdge::QUmlActivityEdge(QObject *parent) :
- QObject(parent)
+QUmlActivityEdge::QUmlActivityEdge() :
+ _activity(0),
+ _guard(0),
+ _inStructuredNode(0),
+ _interrupts(0),
+ _source(0),
+ _target(0),
+ _weight(0)
{
}
-// OWNED ATTRIBUTES [Element]
-
-/*!
- The Comments owned by this element.
- */
-const QSet<QUmlComment *> QUmlActivityEdge::ownedComment() const
+QUmlActivityEdge::~QUmlActivityEdge()
{
- return *(reinterpret_cast<const QSet<QUmlComment *> *>(&_ownedComment));
}
+// OWNED ATTRIBUTES
+
/*!
- The Elements owned by this element.
+ Activity containing the edge.
*/
-const QSet<QUmlElement *> QUmlActivityEdge::ownedElement() const
+QUmlActivity *
+QUmlActivityEdge::activity() const
{
- return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_ownedElement));
+ // This is a read-write association end
+
+ return _activity;
}
-/*!
- The Element that owns this element.
- */
-QUmlElement *QUmlActivityEdge::owner() const
+void QUmlActivityEdge::setActivity(QUmlActivity *activity)
{
- return reinterpret_cast<QUmlElement *>(_owner);
-}
+ // This is a read-write association end
-// OWNED ATTRIBUTES [NamedElement]
+ if (_activity != activity) {
+ // Adjust subsetted properties
-/*!
- Indicates the dependencies that reference the client.
- */
-const QSet<QUmlDependency *> QUmlActivityEdge::clientDependency() const
-{
- return *(reinterpret_cast<const QSet<QUmlDependency *> *>(&_clientDependency));
-}
+ _activity = activity;
+ if (activity->asQObject() && this->asQObject())
+ QObject::connect(activity->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setActivity()));
-/*!
- The name of the NamedElement.
- */
-QString QUmlActivityEdge::name() const
-{
- return _name;
+ // Adjust subsetted properties
+ setOwner(activity);
+ }
}
/*!
- The string expression used to define the name of this named element.
+ Specification evaluated at runtime to determine if the edge can be traversed.
*/
-QUmlStringExpression *QUmlActivityEdge::nameExpression() const
+QUmlValueSpecification *
+QUmlActivityEdge::guard() const
{
- return reinterpret_cast<QUmlStringExpression *>(_nameExpression);
-}
+ // This is a read-write association end
-/*!
- Specifies the namespace that owns the NamedElement.
- */
-QUmlNamespace *QUmlActivityEdge::namespace_() const
-{
- return reinterpret_cast<QUmlNamespace *>(_namespace_);
+ return _guard;
}
-/*!
- 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 QUmlActivityEdge::qualifiedName() const
+void QUmlActivityEdge::setGuard(QUmlValueSpecification *guard)
{
- return UmlNamedElement::qualifiedName();
-}
+ // This is a read-write association end
-/*!
- Determines where the NamedElement appears within different Namespaces within the overall model, and its accessibility.
- */
-QtUml::VisibilityKind QUmlActivityEdge::visibility() const
-{
- return _visibility;
-}
+ if (_guard != guard) {
+ // Adjust subsetted properties
+ removeOwnedElement(_guard);
-// OWNED ATTRIBUTES [RedefinableElement]
+ _guard = guard;
+ if (guard->asQObject() && this->asQObject())
+ QObject::connect(guard->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setGuard()));
+ guard->asQObject()->setParent(this->asQObject());
-/*!
- Indicates whether it is possible to further redefine a RedefinableElement. If the value is true, then it is not possible to further redefine the RedefinableElement. Note that this property is preserved through package merge operations; that is, the capability to redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in the resulting RedefinableElement of a package merge operation where a RedefinableElement with isLeaf=false is merged with a matching RedefinableElement with isLeaf=true: the resulting RedefinableElement will have isLeaf=false. Default value is false.
- */
-bool QUmlActivityEdge::isLeaf() const
-{
- return _isLeaf;
+ // Adjust subsetted properties
+ if (guard) {
+ addOwnedElement(guard);
+ }
+ }
}
/*!
- The redefinable element that is being redefined by this element.
+ Groups containing the edge.
*/
-const QSet<QUmlRedefinableElement *> QUmlActivityEdge::redefinedElement() const
+const QSet<QUmlActivityGroup *>
+QUmlActivityEdge::inGroup() const
{
- return *(reinterpret_cast<const QSet<QUmlRedefinableElement *> *>(&_redefinedElement));
+ // This is a read-only derived union association end
+
+ return _inGroup;
}
-/*!
- References the contexts that this element may be redefined from.
- */
-const QSet<QUmlClassifier *> QUmlActivityEdge::redefinitionContext() const
+void QUmlActivityEdge::addInGroup(QUmlActivityGroup *inGroup)
{
- return *(reinterpret_cast<const QSet<QUmlClassifier *> *>(&_redefinitionContext));
-}
+ // This is a read-only derived union association end
-// OWNED ATTRIBUTES [ActivityEdge]
+ if (!_inGroup.contains(inGroup)) {
+ _inGroup.insert(inGroup);
+ if (inGroup->asQObject() && this->asQObject())
+ QObject::connect(inGroup->asQObject(), SIGNAL(destroyed(QObject*)), this->asQObject(), SLOT(removeInGroup(QObject *)));
-/*!
- Activity containing the edge.
- */
-QUmlActivity *QUmlActivityEdge::activity() const
-{
- return reinterpret_cast<QUmlActivity *>(_activity);
+ // Adjust opposite properties
+ if (inGroup) {
+ inGroup->addContainedEdge(this);
+ }
+ }
}
-/*!
- Specification evaluated at runtime to determine if the edge can be traversed.
- */
-QUmlValueSpecification *QUmlActivityEdge::guard() const
+void QUmlActivityEdge::removeInGroup(QUmlActivityGroup *inGroup)
{
- return reinterpret_cast<QUmlValueSpecification *>(_guard);
-}
+ // This is a read-only derived union association end
-/*!
- Groups containing the edge.
- */
-const QSet<QUmlActivityGroup *> QUmlActivityEdge::inGroup() const
-{
- return *(reinterpret_cast<const QSet<QUmlActivityGroup *> *>(&_inGroup));
+ if (_inGroup.contains(inGroup)) {
+ _inGroup.remove(inGroup);
+
+ // Adjust opposite properties
+ if (inGroup) {
+ inGroup->removeContainedEdge(this);
+ }
+ }
}
/*!
Partitions containing the edge.
*/
-const QSet<QUmlActivityPartition *> QUmlActivityEdge::inPartition() const
+const QSet<QUmlActivityPartition *>
+QUmlActivityEdge::inPartition() const
{
- return *(reinterpret_cast<const QSet<QUmlActivityPartition *> *>(&_inPartition));
-}
+ // This is a read-write association end
-/*!
- Structured activity node containing the edge.
- */
-QUmlStructuredActivityNode *QUmlActivityEdge::inStructuredNode() const
-{
- return reinterpret_cast<QUmlStructuredActivityNode *>(_inStructuredNode);
+ return _inPartition;
}
-/*!
- Region that the edge can interrupt.
- */
-QUmlInterruptibleActivityRegion *QUmlActivityEdge::interrupts() const
+void QUmlActivityEdge::addInPartition(QUmlActivityPartition *inPartition)
{
- return reinterpret_cast<QUmlInterruptibleActivityRegion *>(_interrupts);
-}
+ // This is a read-write association end
-/*!
- Inherited edges replaced by this edge in a specialization of the activity.
- */
-const QSet<QUmlActivityEdge *> QUmlActivityEdge::redefinedEdge() const
-{
- return *(reinterpret_cast<const QSet<QUmlActivityEdge *> *>(&_redefinedEdge));
-}
+ if (!_inPartition.contains(inPartition)) {
+ _inPartition.insert(inPartition);
+ if (inPartition->asQObject() && this->asQObject())
+ QObject::connect(inPartition->asQObject(), SIGNAL(destroyed(QObject*)), this->asQObject(), SLOT(removeInPartition(QObject *)));
-/*!
- Node from which tokens are taken when they traverse the edge.
- */
-QUmlActivityNode *QUmlActivityEdge::source() const
-{
- return reinterpret_cast<QUmlActivityNode *>(_source);
-}
+ // Adjust subsetted properties
+ addInGroup(inPartition);
-/*!
- Node to which tokens are put when they traverse the edge.
- */
-QUmlActivityNode *QUmlActivityEdge::target() const
-{
- return reinterpret_cast<QUmlActivityNode *>(_target);
+ // Adjust opposite properties
+ if (inPartition) {
+ inPartition->addEdge(this);
+ }
+ }
}
-/*!
- The minimum number of tokens that must traverse the edge at the same time.
- */
-QUmlValueSpecification *QUmlActivityEdge::weight() const
+void QUmlActivityEdge::removeInPartition(QUmlActivityPartition *inPartition)
{
- return reinterpret_cast<QUmlValueSpecification *>(_weight);
-}
+ // This is a read-write association end
-// OPERATIONS [Element]
+ if (_inPartition.contains(inPartition)) {
+ _inPartition.remove(inPartition);
-/*!
- The query allOwnedElements() gives all of the direct and indirect owned elements of an element.
- */
-QSet<QUmlElement *> QUmlActivityEdge::allOwnedElements() const
-{
- QSet<QUmlElement *> r;
- foreach (UmlElement *element, UmlElement::allOwnedElements())
- r.insert(reinterpret_cast<QUmlElement *>(element));
- return r;
-}
+ // Adjust subsetted properties
+ removeInGroup(inPartition);
-/*!
- 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 QUmlActivityEdge::mustBeOwned() const
-{
- return UmlElement::mustBeOwned();
+ // Adjust opposite properties
+ if (inPartition) {
+ inPartition->removeEdge(this);
+ }
+ }
}
-// OPERATIONS [NamedElement]
-
/*!
- The query allNamespaces() gives the sequence of namespaces in which the NamedElement is nested, working outwards.
+ Structured activity node containing the edge.
*/
-QList<QUmlNamespace *> QUmlActivityEdge::allNamespaces() const
+QUmlStructuredActivityNode *
+QUmlActivityEdge::inStructuredNode() const
{
- QList<QUmlNamespace *> r;
- foreach (UmlNamespace *element, UmlNamedElement::allNamespaces())
- r.append(reinterpret_cast<QUmlNamespace *>(element));
- return r;
-}
+ // This is a read-write association end
-/*!
- The query allOwningPackages() returns all the directly or indirectly owning packages.
- */
-QSet<QUmlPackage *> QUmlActivityEdge::allOwningPackages() const
-{
- QSet<QUmlPackage *> r;
- foreach (UmlPackage *element, UmlNamedElement::allOwningPackages())
- r.insert(reinterpret_cast<QUmlPackage *>(element));
- return r;
+ return _inStructuredNode;
}
-/*!
- 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.
- */
-bool QUmlActivityEdge::isDistinguishableFrom(QUmlNamedElement *n, QUmlNamespace *ns) const
+void QUmlActivityEdge::setInStructuredNode(QUmlStructuredActivityNode *inStructuredNode)
{
- 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 QUmlActivityEdge::separator() const
-{
- return UmlNamedElement::separator();
-}
+ if (_inStructuredNode != inStructuredNode) {
+ // Adjust subsetted properties
+ removeInGroup(_inStructuredNode);
-// OPERATIONS [RedefinableElement]
+ _inStructuredNode = inStructuredNode;
+ if (inStructuredNode->asQObject() && this->asQObject())
+ QObject::connect(inStructuredNode->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setInStructuredNode()));
-/*!
- The query isConsistentWith() specifies, for any two RedefinableElements in a context in which redefinition is possible, whether redefinition would be logically consistent. By default, this is false; this operation must be overridden for subclasses of RedefinableElement to define the consistency conditions.
- */
-bool QUmlActivityEdge::isConsistentWith(QUmlRedefinableElement *redefinee) const
-{
- return UmlRedefinableElement::isConsistentWith(redefinee);
+ // Adjust subsetted properties
+ if (inStructuredNode) {
+ addInGroup(inStructuredNode);
+ }
+ setOwner(inStructuredNode);
+ }
}
/*!
- The query isRedefinitionContextValid() specifies whether the redefinition contexts of this RedefinableElement are properly related to the redefinition contexts of the specified RedefinableElement to allow this element to redefine the other. By default at least one of the redefinition contexts of this element must be a specialization of at least one of the redefinition contexts of the specified element.
+ Region that the edge can interrupt.
*/
-bool QUmlActivityEdge::isRedefinitionContextValid(QUmlRedefinableElement *redefined) const
+QUmlInterruptibleActivityRegion *
+QUmlActivityEdge::interrupts() const
{
- return UmlRedefinableElement::isRedefinitionContextValid(redefined);
-}
+ // This is a read-write association end
-// SLOTS FOR OWNED ATTRIBUTES [Element]
-
-void QUmlActivityEdge::addOwnedComment(UmlComment *ownedComment)
-{
- UmlElement::addOwnedComment(ownedComment);
+ return _interrupts;
}
-void QUmlActivityEdge::removeOwnedComment(UmlComment *ownedComment)
+void QUmlActivityEdge::setInterrupts(QUmlInterruptibleActivityRegion *interrupts)
{
- UmlElement::removeOwnedComment(ownedComment);
-}
-
-// SLOTS FOR OWNED ATTRIBUTES [NamedElement]
+ // This is a read-write association end
-void QUmlActivityEdge::addClientDependency(UmlDependency *clientDependency)
-{
- UmlNamedElement::addClientDependency(clientDependency);
+ if (_interrupts != interrupts) {
+ _interrupts = interrupts;
+ if (interrupts->asQObject() && this->asQObject())
+ QObject::connect(interrupts->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setInterrupts()));
+ }
}
-void QUmlActivityEdge::removeClientDependency(UmlDependency *clientDependency)
+/*!
+ Inherited edges replaced by this edge in a specialization of the activity.
+ */
+const QSet<QUmlActivityEdge *>
+QUmlActivityEdge::redefinedEdge() const
{
- UmlNamedElement::removeClientDependency(clientDependency);
-}
+ // This is a read-write association end
-void QUmlActivityEdge::setName(QString name)
-{
- UmlNamedElement::setName(name);
+ return _redefinedEdge;
}
-void QUmlActivityEdge::setNameExpression(QUmlStringExpression *nameExpression)
+void QUmlActivityEdge::addRedefinedEdge(QUmlActivityEdge *redefinedEdge)
{
- UmlNamedElement::setNameExpression(nameExpression);
-}
+ // This is a read-write association end
-void QUmlActivityEdge::setVisibility(QtUml::VisibilityKind visibility)
-{
- UmlNamedElement::setVisibility(visibility);
-}
+ if (!_redefinedEdge.contains(redefinedEdge)) {
+ _redefinedEdge.insert(redefinedEdge);
+ if (redefinedEdge->asQObject() && this->asQObject())
+ QObject::connect(redefinedEdge->asQObject(), SIGNAL(destroyed(QObject*)), this->asQObject(), SLOT(removeRedefinedEdge(QObject *)));
-// SLOTS FOR OWNED ATTRIBUTES [RedefinableElement]
+ // Adjust subsetted properties
+ addRedefinedElement(redefinedEdge);
+ }
+}
-void QUmlActivityEdge::setLeaf(bool isLeaf)
+void QUmlActivityEdge::removeRedefinedEdge(QUmlActivityEdge *redefinedEdge)
{
- UmlRedefinableElement::setLeaf(isLeaf);
-}
+ // This is a read-write association end
-// SLOTS FOR OWNED ATTRIBUTES [ActivityEdge]
+ if (_redefinedEdge.contains(redefinedEdge)) {
+ _redefinedEdge.remove(redefinedEdge);
-void QUmlActivityEdge::setActivity(QUmlActivity *activity)
-{
- UmlActivityEdge::setActivity(activity);
+ // Adjust subsetted properties
+ removeRedefinedElement(redefinedEdge);
+ }
}
-void QUmlActivityEdge::setGuard(QUmlValueSpecification *guard)
+/*!
+ Node from which tokens are taken when they traverse the edge.
+ */
+QUmlActivityNode *
+QUmlActivityEdge::source() const
{
- UmlActivityEdge::setGuard(guard);
-}
+ // This is a read-write association end
-void QUmlActivityEdge::addInPartition(UmlActivityPartition *inPartition)
-{
- UmlActivityEdge::addInPartition(inPartition);
+ return _source;
}
-void QUmlActivityEdge::removeInPartition(UmlActivityPartition *inPartition)
+void QUmlActivityEdge::setSource(QUmlActivityNode *source)
{
- UmlActivityEdge::removeInPartition(inPartition);
-}
+ // This is a read-write association end
-void QUmlActivityEdge::setInStructuredNode(QUmlStructuredActivityNode *inStructuredNode)
-{
- UmlActivityEdge::setInStructuredNode(inStructuredNode);
+ if (_source != source) {
+ _source = source;
+ if (source->asQObject() && this->asQObject())
+ QObject::connect(source->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setSource()));
+ }
}
-void QUmlActivityEdge::setInterrupts(QUmlInterruptibleActivityRegion *interrupts)
+/*!
+ Node to which tokens are put when they traverse the edge.
+ */
+QUmlActivityNode *
+QUmlActivityEdge::target() const
{
- UmlActivityEdge::setInterrupts(interrupts);
-}
+ // This is a read-write association end
-void QUmlActivityEdge::addRedefinedEdge(UmlActivityEdge *redefinedEdge)
-{
- UmlActivityEdge::addRedefinedEdge(redefinedEdge);
+ return _target;
}
-void QUmlActivityEdge::removeRedefinedEdge(UmlActivityEdge *redefinedEdge)
+void QUmlActivityEdge::setTarget(QUmlActivityNode *target)
{
- UmlActivityEdge::removeRedefinedEdge(redefinedEdge);
-}
+ // This is a read-write association end
-void QUmlActivityEdge::setSource(QUmlActivityNode *source)
-{
- UmlActivityEdge::setSource(source);
+ if (_target != target) {
+ _target = target;
+ if (target->asQObject() && this->asQObject())
+ QObject::connect(target->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setTarget()));
+ }
}
-void QUmlActivityEdge::setTarget(QUmlActivityNode *target)
+/*!
+ The minimum number of tokens that must traverse the edge at the same time.
+ */
+QUmlValueSpecification *
+QUmlActivityEdge::weight() const
{
- UmlActivityEdge::setTarget(target);
+ // This is a read-write association end
+
+ return _weight;
}
void QUmlActivityEdge::setWeight(QUmlValueSpecification *weight)
{
- UmlActivityEdge::setWeight(weight);
-}
+ // This is a read-write association end
+
+ if (_weight != weight) {
+ // Adjust subsetted properties
+ removeOwnedElement(_weight);
-QT_END_NAMESPACE
+ _weight = weight;
+ if (weight->asQObject() && this->asQObject())
+ QObject::connect(weight->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setWeight()));
+ weight->asQObject()->setParent(this->asQObject());
+
+ // Adjust subsetted properties
+ if (weight) {
+ addOwnedElement(weight);
+ }
+ }
+}