summaryrefslogtreecommitdiffstats
path: root/src/uml/qumlconstraint.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/qumlconstraint.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/qumlconstraint.cpp')
-rw-r--r--src/uml/qumlconstraint.cpp308
1 files changed, 63 insertions, 245 deletions
diff --git a/src/uml/qumlconstraint.cpp b/src/uml/qumlconstraint.cpp
index e35e0948..05c2de72 100644
--- a/src/uml/qumlconstraint.cpp
+++ b/src/uml/qumlconstraint.cpp
@@ -40,305 +40,123 @@
****************************************************************************/
#include "qumlconstraint.h"
-#include <QtUml/QUmlComment>
-#include <QtUml/QUmlDependency>
+#include "private/qumlconstraintobject_p.h"
+
#include <QtUml/QUmlElement>
-#include <QtUml/QUmlNamedElement>
#include <QtUml/QUmlNamespace>
-#include <QtUml/QUmlPackage>
-#include <QtUml/QUmlParameterableElement>
-#include <QtUml/QUmlStringExpression>
-#include <QtUml/QUmlTemplateParameter>
#include <QtUml/QUmlValueSpecification>
-QT_BEGIN_NAMESPACE
-
/*!
- \class UmlConstraint
+ \class QUmlConstraint
\inmodule QtUml
\brief A constraint is a condition or restriction expressed in natural language text or in a machine readable language for the purpose of declaring some of the semantics of an element.
*/
-
-QUmlConstraint::QUmlConstraint(QObject *parent) :
- QObject(parent)
+QUmlConstraint::QUmlConstraint(bool createQObject) :
+ _context(0),
+ _specification(0)
{
+ if (createQObject)
+ _qObject = new QUmlConstraintObject(this);
}
-// OWNED ATTRIBUTES [Element]
-
-/*!
- The Comments owned by this element.
- */
-const QSet<QUmlComment *> QUmlConstraint::ownedComment() const
+QUmlConstraint::~QUmlConstraint()
{
- return *(reinterpret_cast<const QSet<QUmlComment *> *>(&_ownedComment));
+ if (!deletingFromQObject) {
+ _qObject->setProperty("deletingFromModelingObject", true);
+ delete _qObject;
+ }
}
-/*!
- The Elements owned by this element.
- */
-const QSet<QUmlElement *> QUmlConstraint::ownedElement() const
-{
- return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_ownedElement));
-}
+// OWNED ATTRIBUTES
/*!
- The Element that owns this element.
+ The ordered set of Elements referenced by this Constraint.
*/
-QUmlElement *QUmlConstraint::owner() const
+const QList<QUmlElement *>
+QUmlConstraint::constrainedElement() const
{
- return reinterpret_cast<QUmlElement *>(_owner);
-}
-
-// OWNED ATTRIBUTES [ParameterableElement]
+ // This is a read-write association end
-/*!
- The formal template parameter that owns this element.
- */
-QUmlTemplateParameter *QUmlConstraint::owningTemplateParameter() const
-{
- return reinterpret_cast<QUmlTemplateParameter *>(_owningTemplateParameter);
+ return _constrainedElement;
}
-/*!
- The template parameter that exposes this element as a formal parameter.
- */
-QUmlTemplateParameter *QUmlConstraint::templateParameter() const
+void QUmlConstraint::addConstrainedElement(QUmlElement *constrainedElement)
{
- return reinterpret_cast<QUmlTemplateParameter *>(_templateParameter);
-}
+ // This is a read-write association end
-// OWNED ATTRIBUTES [NamedElement]
-
-/*!
- Indicates the dependencies that reference the client.
- */
-const QSet<QUmlDependency *> QUmlConstraint::clientDependency() const
-{
- return *(reinterpret_cast<const QSet<QUmlDependency *> *>(&_clientDependency));
+ if (!_constrainedElement.contains(constrainedElement)) {
+ _constrainedElement.append(constrainedElement);
+ if (constrainedElement->asQObject() && this->asQObject())
+ QObject::connect(constrainedElement->asQObject(), SIGNAL(destroyed(QObject*)), this->asQObject(), SLOT(removeConstrainedElement(QObject *)));
+ }
}
-/*!
- The name of the NamedElement.
- */
-QString QUmlConstraint::name() const
+void QUmlConstraint::removeConstrainedElement(QUmlElement *constrainedElement)
{
- return _name;
-}
+ // This is a read-write association end
-/*!
- The string expression used to define the name of this named element.
- */
-QUmlStringExpression *QUmlConstraint::nameExpression() const
-{
- return reinterpret_cast<QUmlStringExpression *>(_nameExpression);
+ if (_constrainedElement.contains(constrainedElement)) {
+ _constrainedElement.removeAll(constrainedElement);
+ }
}
/*!
Specifies the namespace that owns the NamedElement.
*/
-QUmlNamespace *QUmlConstraint::namespace_() const
+QUmlNamespace *
+QUmlConstraint::context() const
{
- return reinterpret_cast<QUmlNamespace *>(_namespace_);
-}
+ // This is a read-write association end
-/*!
- 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 QUmlConstraint::qualifiedName() const
-{
- return UmlNamedElement::qualifiedName();
+ return _context;
}
-// OWNED ATTRIBUTES [PackageableElement]
-/*!
- Indicates that packageable elements must always have a visibility, i.e., visibility is not optional.
- */
-QtUml::VisibilityKind QUmlConstraint::visibility() const
+void QUmlConstraint::setContext(QUmlNamespace *context)
{
- return _visibility;
-}
+ // This is a read-write association end
-// OWNED ATTRIBUTES [Constraint]
+ if (_context != context) {
+ // Adjust subsetted properties
-/*!
- The ordered set of Elements referenced by this Constraint.
- */
-const QList<QUmlElement *> QUmlConstraint::constrainedElement() const
-{
- return *(reinterpret_cast<const QList<QUmlElement *> *>(&_constrainedElement));
-}
+ _context = context;
+ if (context->asQObject() && this->asQObject())
+ QObject::connect(context->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setContext()));
-/*!
- Specifies the namespace that owns the NamedElement.
- */
-QUmlNamespace *QUmlConstraint::context() const
-{
- return reinterpret_cast<QUmlNamespace *>(_context);
+ // Adjust subsetted properties
+ setNamespace(context);
+ }
}
/*!
A condition that must be true when evaluated in order for the constraint to be satisfied.
*/
-QUmlValueSpecification *QUmlConstraint::specification() const
-{
- return reinterpret_cast<QUmlValueSpecification *>(_specification);
-}
-
-// OPERATIONS [Element]
-
-/*!
- The query allOwnedElements() gives all of the direct and indirect owned elements of an element.
- */
-QSet<QUmlElement *> QUmlConstraint::allOwnedElements() const
-{
- QSet<QUmlElement *> r;
- foreach (UmlElement *element, UmlElement::allOwnedElements())
- r.insert(reinterpret_cast<QUmlElement *>(element));
- return r;
-}
-
-/*!
- 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 QUmlConstraint::mustBeOwned() const
+QUmlValueSpecification *
+QUmlConstraint::specification() const
{
- return UmlElement::mustBeOwned();
-}
-
-// OPERATIONS [ParameterableElement]
+ // This is a read-write association end
-/*!
- 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 QUmlConstraint::isCompatibleWith(QUmlParameterableElement *p) const
-{
- return UmlParameterableElement::isCompatibleWith(p);
+ return _specification;
}
-/*!
- The query isTemplateParameter() determines if this parameterable element is exposed as a formal template parameter.
- */
-bool QUmlConstraint::isTemplateParameter() const
-{
- return UmlParameterableElement::isTemplateParameter();
-}
-
-// OPERATIONS [NamedElement]
-
-/*!
- The query allNamespaces() gives the sequence of namespaces in which the NamedElement is nested, working outwards.
- */
-QList<QUmlNamespace *> QUmlConstraint::allNamespaces() const
-{
- QList<QUmlNamespace *> r;
- foreach (UmlNamespace *element, UmlNamedElement::allNamespaces())
- r.append(reinterpret_cast<QUmlNamespace *>(element));
- return r;
-}
-
-/*!
- The query allOwningPackages() returns all the directly or indirectly owning packages.
- */
-QSet<QUmlPackage *> QUmlConstraint::allOwningPackages() const
-{
- QSet<QUmlPackage *> r;
- foreach (UmlPackage *element, UmlNamedElement::allOwningPackages())
- r.insert(reinterpret_cast<QUmlPackage *>(element));
- return r;
-}
-
-/*!
- 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 QUmlConstraint::isDistinguishableFrom(QUmlNamedElement *n, QUmlNamespace *ns) const
-{
- return UmlNamedElement::isDistinguishableFrom(n, ns);
-}
-
-/*!
- The query separator() gives the string that is used to separate names when constructing a qualified name.
- */
-QString QUmlConstraint::separator() const
-{
- return UmlNamedElement::separator();
-}
-
-// SLOTS FOR OWNED ATTRIBUTES [Element]
-
-void QUmlConstraint::addOwnedComment(UmlComment *ownedComment)
-{
- UmlElement::addOwnedComment(ownedComment);
-}
-
-void QUmlConstraint::removeOwnedComment(UmlComment *ownedComment)
-{
- UmlElement::removeOwnedComment(ownedComment);
-}
-
-// SLOTS FOR OWNED ATTRIBUTES [ParameterableElement]
-
-void QUmlConstraint::setOwningTemplateParameter(QUmlTemplateParameter *owningTemplateParameter)
-{
- UmlParameterableElement::setOwningTemplateParameter(owningTemplateParameter);
-}
-
-void QUmlConstraint::setTemplateParameter(QUmlTemplateParameter *templateParameter)
-{
- UmlParameterableElement::setTemplateParameter(templateParameter);
-}
-
-// SLOTS FOR OWNED ATTRIBUTES [NamedElement]
-
-void QUmlConstraint::addClientDependency(UmlDependency *clientDependency)
-{
- UmlNamedElement::addClientDependency(clientDependency);
-}
-
-void QUmlConstraint::removeClientDependency(UmlDependency *clientDependency)
-{
- UmlNamedElement::removeClientDependency(clientDependency);
-}
-
-void QUmlConstraint::setName(QString name)
-{
- UmlNamedElement::setName(name);
-}
-
-void QUmlConstraint::setNameExpression(QUmlStringExpression *nameExpression)
-{
- UmlNamedElement::setNameExpression(nameExpression);
-}
-// SLOTS FOR OWNED ATTRIBUTES [PackageableElement]
-
-void QUmlConstraint::setVisibility(QtUml::VisibilityKind visibility)
-{
- UmlPackageableElement::setVisibility(visibility);
-}
-
-// SLOTS FOR OWNED ATTRIBUTES [Constraint]
-
-void QUmlConstraint::addConstrainedElement(UmlElement *constrainedElement)
+void QUmlConstraint::setSpecification(QUmlValueSpecification *specification)
{
- UmlConstraint::addConstrainedElement(constrainedElement);
-}
+ // This is a read-write association end
-void QUmlConstraint::removeConstrainedElement(UmlElement *constrainedElement)
-{
- UmlConstraint::removeConstrainedElement(constrainedElement);
-}
+ if (_specification != specification) {
+ // Adjust subsetted properties
+ removeOwnedElement(_specification);
-void QUmlConstraint::setContext(QUmlNamespace *context)
-{
- UmlConstraint::setContext(context);
-}
+ _specification = specification;
+ if (specification->asQObject() && this->asQObject())
+ QObject::connect(specification->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setSpecification()));
+ specification->asQObject()->setParent(this->asQObject());
-void QUmlConstraint::setSpecification(QUmlValueSpecification *specification)
-{
- UmlConstraint::setSpecification(specification);
+ // Adjust subsetted properties
+ if (specification) {
+ addOwnedElement(specification);
+ }
+ }
}
-QT_END_NAMESPACE
-