diff options
Diffstat (limited to 'src/uml/qumlinterval.cpp')
-rw-r--r-- | src/uml/qumlinterval.cpp | 361 |
1 files changed, 36 insertions, 325 deletions
diff --git a/src/uml/qumlinterval.cpp b/src/uml/qumlinterval.cpp index 6cc33227..69a25b93 100644 --- a/src/uml/qumlinterval.cpp +++ b/src/uml/qumlinterval.cpp @@ -40,363 +40,74 @@ ****************************************************************************/ #include "qumlinterval.h" -#include <QtUml/QUmlComment> -#include <QtUml/QUmlDependency> -#include <QtUml/QUmlElement> -#include <QtUml/QUmlNamedElement> -#include <QtUml/QUmlNamespace> -#include <QtUml/QUmlPackage> -#include <QtUml/QUmlParameterableElement> -#include <QtUml/QUmlStringExpression> -#include <QtUml/QUmlTemplateParameter> -#include <QtUml/QUmlType> -#include <QtUml/QUmlValueSpecification> - -QT_BEGIN_NAMESPACE +#include "private/qumlintervalobject_p.h" /*! - \class UmlInterval + \class QUmlInterval \inmodule QtUml \brief An interval defines the range between two value specifications. */ - -QUmlInterval::QUmlInterval(QObject *parent) : - QObject(parent) -{ -} - -// OWNED ATTRIBUTES [Element] - -/*! - The Comments owned by this element. - */ -const QSet<QUmlComment *> QUmlInterval::ownedComment() const -{ - return *(reinterpret_cast<const QSet<QUmlComment *> *>(&_ownedComment)); -} - -/*! - The Elements owned by this element. - */ -const QSet<QUmlElement *> QUmlInterval::ownedElement() const -{ - return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_ownedElement)); -} - -/*! - The Element that owns this element. - */ -QUmlElement *QUmlInterval::owner() const -{ - return reinterpret_cast<QUmlElement *>(_owner); -} - -// OWNED ATTRIBUTES [NamedElement] - -/*! - Indicates the dependencies that reference the client. - */ -const QSet<QUmlDependency *> QUmlInterval::clientDependency() const -{ - return *(reinterpret_cast<const QSet<QUmlDependency *> *>(&_clientDependency)); -} - -/*! - The name of the NamedElement. - */ -QString QUmlInterval::name() const -{ - return _name; -} - -/*! - The string expression used to define the name of this named element. - */ -QUmlStringExpression *QUmlInterval::nameExpression() const -{ - return reinterpret_cast<QUmlStringExpression *>(_nameExpression); -} - -/*! - Specifies the namespace that owns the NamedElement. - */ -QUmlNamespace *QUmlInterval::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 QUmlInterval::qualifiedName() const -{ - return UmlNamedElement::qualifiedName(); -} -// OWNED ATTRIBUTES [TypedElement] - -/*! - This information is derived from the return result for this Operation.The type of the TypedElement. - */ -QUmlType *QUmlInterval::type() const -{ - return reinterpret_cast<QUmlType *>(_type); -} - -// OWNED ATTRIBUTES [ParameterableElement] - -/*! - The formal template parameter that owns this element. - */ -QUmlTemplateParameter *QUmlInterval::owningTemplateParameter() const +QUmlInterval::QUmlInterval(bool createQObject) : + _max(0), + _min(0) { - return reinterpret_cast<QUmlTemplateParameter *>(_owningTemplateParameter); + if (createQObject) + _qObject = new QUmlIntervalObject(this); } -/*! - The template parameter that exposes this element as a formal parameter. - */ -QUmlTemplateParameter *QUmlInterval::templateParameter() const +QUmlInterval::~QUmlInterval() { - return reinterpret_cast<QUmlTemplateParameter *>(_templateParameter); + if (!deletingFromQObject) { + _qObject->setProperty("deletingFromModelingObject", true); + delete _qObject; + } } -// OWNED ATTRIBUTES [PackageableElement] - -/*! - Indicates that packageable elements must always have a visibility, i.e., visibility is not optional. - */ -QtUml::VisibilityKind QUmlInterval::visibility() const -{ - return _visibility; -} - -// OWNED ATTRIBUTES [Interval] +// OWNED ATTRIBUTES /*! Refers to the ValueSpecification denoting the maximum value of the range. */ -QUmlValueSpecification *QUmlInterval::max() const -{ - return reinterpret_cast<QUmlValueSpecification *>(_max); -} - -/*! - Refers to the ValueSpecification denoting the minimum value of the range. - */ -QUmlValueSpecification *QUmlInterval::min() const -{ - return reinterpret_cast<QUmlValueSpecification *>(_min); -} - -// OPERATIONS [Element] - -/*! - The query allOwnedElements() gives all of the direct and indirect owned elements of an element. - */ -QSet<QUmlElement *> QUmlInterval::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 QUmlInterval::mustBeOwned() const -{ - return UmlElement::mustBeOwned(); -} - -// OPERATIONS [NamedElement] - -/*! - The query allNamespaces() gives the sequence of namespaces in which the NamedElement is nested, working outwards. - */ -QList<QUmlNamespace *> QUmlInterval::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 *> QUmlInterval::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 QUmlInterval::isDistinguishableFrom(QUmlNamedElement *n, QUmlNamespace *ns) const +QUmlValueSpecification * +QUmlInterval::max() 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 QUmlInterval::separator() const -{ - return UmlNamedElement::separator(); + return _max; } -// OPERATIONS [ParameterableElement] - -/*! - The query isTemplateParameter() determines if this parameterable element is exposed as a formal template parameter. - */ -bool QUmlInterval::isTemplateParameter() const -{ - return UmlParameterableElement::isTemplateParameter(); -} - -// OPERATIONS [ValueSpecification] - -/*! - The query booleanValue() gives a single Boolean value when one can be computed. - */ -bool QUmlInterval::booleanValue() const -{ - return UmlValueSpecification::booleanValue(); -} - -/*! - The query integerValue() gives a single Integer value when one can be computed. - */ -int QUmlInterval::integerValue() const -{ - return UmlValueSpecification::integerValue(); -} - -/*! - 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. In addition, for ValueSpecification, the type must be conformant with the type of the specified parameterable element. - */ -bool QUmlInterval::isCompatibleWith(QUmlParameterableElement *p) const -{ - return UmlValueSpecification::isCompatibleWith(p); -} - -/*! - The query isComputable() determines whether a value specification can be computed in a model. This operation cannot be fully defined in OCL. A conforming implementation is expected to deliver true for this operation for all value specifications that it can compute, and to compute all of those for which the operation is true. A conforming implementation is expected to be able to compute the value of all literals. - */ -bool QUmlInterval::isComputable() const -{ - return UmlValueSpecification::isComputable(); -} - -/*! - The query isNull() returns true when it can be computed that the value is null. - */ -bool QUmlInterval::isNull() const -{ - return UmlValueSpecification::isNull(); -} - -/*! - The query realValue() gives a single Real value when one can be computed. - */ -double QUmlInterval::realValue() const +void QUmlInterval::setMax(QUmlValueSpecification *max) { - return UmlValueSpecification::realValue(); -} + // This is a read-write association end -/*! - The query stringValue() gives a single String value when one can be computed. - */ -QString QUmlInterval::stringValue() const -{ - return UmlValueSpecification::stringValue(); + if (_max != max) { + _max = max; + if (max->asQObject() && this->asQObject()) + QObject::connect(max->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setMax())); + } } /*! - The query unlimitedValue() gives a single UnlimitedNatural value when one can be computed. + Refers to the ValueSpecification denoting the minimum value of the range. */ -int QUmlInterval::unlimitedValue() const -{ - return UmlValueSpecification::unlimitedValue(); -} - -// SLOTS FOR OWNED ATTRIBUTES [Element] - -void QUmlInterval::addOwnedComment(UmlComment *ownedComment) +QUmlValueSpecification * +QUmlInterval::min() const { - UmlElement::addOwnedComment(ownedComment); -} + // This is a read-write association end -void QUmlInterval::removeOwnedComment(UmlComment *ownedComment) -{ - UmlElement::removeOwnedComment(ownedComment); -} - -// SLOTS FOR OWNED ATTRIBUTES [NamedElement] - -void QUmlInterval::addClientDependency(UmlDependency *clientDependency) -{ - UmlNamedElement::addClientDependency(clientDependency); -} - -void QUmlInterval::removeClientDependency(UmlDependency *clientDependency) -{ - UmlNamedElement::removeClientDependency(clientDependency); -} - -void QUmlInterval::setName(QString name) -{ - UmlNamedElement::setName(name); -} - -void QUmlInterval::setNameExpression(QUmlStringExpression *nameExpression) -{ - UmlNamedElement::setNameExpression(nameExpression); -} -// SLOTS FOR OWNED ATTRIBUTES [TypedElement] - -void QUmlInterval::setType(QUmlType *type) -{ - UmlTypedElement::setType(type); -} - -// SLOTS FOR OWNED ATTRIBUTES [ParameterableElement] - -void QUmlInterval::setOwningTemplateParameter(QUmlTemplateParameter *owningTemplateParameter) -{ - UmlParameterableElement::setOwningTemplateParameter(owningTemplateParameter); -} - -void QUmlInterval::setTemplateParameter(QUmlTemplateParameter *templateParameter) -{ - UmlParameterableElement::setTemplateParameter(templateParameter); -} - -// SLOTS FOR OWNED ATTRIBUTES [PackageableElement] - -void QUmlInterval::setVisibility(QtUml::VisibilityKind visibility) -{ - UmlPackageableElement::setVisibility(visibility); -} - -// SLOTS FOR OWNED ATTRIBUTES [Interval] - -void QUmlInterval::setMax(QUmlValueSpecification *max) -{ - UmlInterval::setMax(max); + return _min; } void QUmlInterval::setMin(QUmlValueSpecification *min) { - UmlInterval::setMin(min); -} + // This is a read-write association end -QT_END_NAMESPACE + if (_min != min) { + _min = min; + if (min->asQObject() && this->asQObject()) + QObject::connect(min->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setMin())); + } +} |