diff options
Diffstat (limited to 'src/uml/qumlmultiplicityelement.cpp')
-rw-r--r-- | src/uml/qumlmultiplicityelement.cpp | 258 |
1 files changed, 145 insertions, 113 deletions
diff --git a/src/uml/qumlmultiplicityelement.cpp b/src/uml/qumlmultiplicityelement.cpp index 73172b88..d6cc59ad 100644 --- a/src/uml/qumlmultiplicityelement.cpp +++ b/src/uml/qumlmultiplicityelement.cpp @@ -40,130 +40,192 @@ ****************************************************************************/ #include "qumlmultiplicityelement.h" -#include <QtUml/QUmlComment> -#include <QtUml/QUmlElement> #include <QtUml/QUmlValueSpecification> -QT_BEGIN_NAMESPACE - /*! - \class UmlMultiplicityElement + \class QUmlMultiplicityElement \inmodule QtUml \brief A multiplicity is a definition of an inclusive interval of non-negative integers beginning with a lower bound and ending with a (possibly infinite) upper bound. A multiplicity element embeds this information to specify the allowable cardinalities for an instantiation of this element. */ +QUmlMultiplicityElement::QUmlMultiplicityElement() : + _isOrdered(false), + _isUnique(true), + _lowerValue(0), + _upperValue(0) +{ +} -QUmlMultiplicityElement::QUmlMultiplicityElement(QObject *parent) : - QObject(parent) +QUmlMultiplicityElement::~QUmlMultiplicityElement() { } -// OWNED ATTRIBUTES [Element] +// OWNED ATTRIBUTES /*! - The Comments owned by this element. + For a multivalued multiplicity, this attribute specifies whether the values in an instantiation of this element are sequentially ordered. */ -const QSet<QUmlComment *> QUmlMultiplicityElement::ownedComment() const +bool +QUmlMultiplicityElement::isOrdered() const { - return *(reinterpret_cast<const QSet<QUmlComment *> *>(&_ownedComment)); + // This is a read-write property + + return _isOrdered; } -/*! - The Elements owned by this element. - */ -const QSet<QUmlElement *> QUmlMultiplicityElement::ownedElement() const +void QUmlMultiplicityElement::setOrdered(bool isOrdered) { - return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_ownedElement)); + // This is a read-write property + + if (_isOrdered != isOrdered) { + _isOrdered = isOrdered; + } } /*! - The Element that owns this element. + For a multivalued multiplicity, this attributes specifies whether the values in an instantiation of this element are unique. */ -QUmlElement *QUmlMultiplicityElement::owner() const +bool +QUmlMultiplicityElement::isUnique() const { - return reinterpret_cast<QUmlElement *>(_owner); -} + // This is a read-write property -// OWNED ATTRIBUTES [MultiplicityElement] + return _isUnique; +} -/*! - For a multivalued multiplicity, this attribute specifies whether the values in an instantiation of this element are sequentially ordered. - */ -bool QUmlMultiplicityElement::isOrdered() const +void QUmlMultiplicityElement::setUnique(bool isUnique) { - return _isOrdered; + // This is a read-write property + + if (_isUnique != isUnique) { + _isUnique = isUnique; + } } /*! - For a multivalued multiplicity, this attributes specifies whether the values in an instantiation of this element are unique. + Specifies the lower bound of the multiplicity interval. */ -bool QUmlMultiplicityElement::isUnique() const +int +QUmlMultiplicityElement::lower() const { - return _isUnique; + // This is a read-write derived property + + qWarning("UmlMultiplicityElement::lower(): to be implemented (this is a derived property)"); + + return int(); } -/*! - Specifies the lower bound of the multiplicity interval. - */ -int QUmlMultiplicityElement::lower() const +void QUmlMultiplicityElement::setLower(int lower) { - return UmlMultiplicityElement::lower(); + // This is a read-write derived property + + qWarning("UmlMultiplicityElement::lower(): to be implemented (this is a derived property)"); + Q_UNUSED(lower); + + if (false /* <derivedexclusion-criteria> */) { + // <derived-code> + } } /*! The specification of the lower bound for this multiplicity. */ -QUmlValueSpecification *QUmlMultiplicityElement::lowerValue() const +QUmlValueSpecification * +QUmlMultiplicityElement::lowerValue() const { - return reinterpret_cast<QUmlValueSpecification *>(_lowerValue); + // This is a read-write association end + + return _lowerValue; } -/*! - Specifies the upper bound of the multiplicity interval. - */ -int QUmlMultiplicityElement::upper() const +void QUmlMultiplicityElement::setLowerValue(QUmlValueSpecification *lowerValue) { - return UmlMultiplicityElement::upper(); + // This is a read-write association end + + if (_lowerValue != lowerValue) { + // Adjust subsetted properties + removeOwnedElement(_lowerValue); + + _lowerValue = lowerValue; + if (lowerValue->asQObject() && this->asQObject()) + QObject::connect(lowerValue->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setLowerValue())); + lowerValue->asQObject()->setParent(this->asQObject()); + + // Adjust subsetted properties + if (lowerValue) { + addOwnedElement(lowerValue); + } + } } /*! - The specification of the upper bound for this multiplicity. + Specifies the upper bound of the multiplicity interval. */ -QUmlValueSpecification *QUmlMultiplicityElement::upperValue() const +int +QUmlMultiplicityElement::upper() const { - return reinterpret_cast<QUmlValueSpecification *>(_upperValue); + // This is a read-write derived property + + qWarning("UmlMultiplicityElement::upper(): to be implemented (this is a derived property)"); + + return int(); } -// OPERATIONS [Element] +void QUmlMultiplicityElement::setUpper(int upper) +{ + // This is a read-write derived property + + qWarning("UmlMultiplicityElement::upper(): to be implemented (this is a derived property)"); + Q_UNUSED(upper); + + if (false /* <derivedexclusion-criteria> */) { + // <derived-code> + } +} /*! - The query allOwnedElements() gives all of the direct and indirect owned elements of an element. + The specification of the upper bound for this multiplicity. */ -QSet<QUmlElement *> QUmlMultiplicityElement::allOwnedElements() const +QUmlValueSpecification * +QUmlMultiplicityElement::upperValue() const { - QSet<QUmlElement *> r; - foreach (UmlElement *element, UmlElement::allOwnedElements()) - r.insert(reinterpret_cast<QUmlElement *>(element)); - return r; + // This is a read-write association end + + return _upperValue; } -/*! - 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 QUmlMultiplicityElement::mustBeOwned() const +void QUmlMultiplicityElement::setUpperValue(QUmlValueSpecification *upperValue) { - return UmlElement::mustBeOwned(); + // This is a read-write association end + + if (_upperValue != upperValue) { + // Adjust subsetted properties + removeOwnedElement(_upperValue); + + _upperValue = upperValue; + if (upperValue->asQObject() && this->asQObject()) + QObject::connect(upperValue->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setUpperValue())); + upperValue->asQObject()->setParent(this->asQObject()); + + // Adjust subsetted properties + if (upperValue) { + addOwnedElement(upperValue); + } + } } -// OPERATIONS [MultiplicityElement] +// OPERATIONS /*! The operation compatibleWith takes another multiplicity as input. It checks if one multiplicity is compatible with another. */ bool QUmlMultiplicityElement::compatibleWith(QUmlMultiplicityElement *other) const { - return UmlMultiplicityElement::compatibleWith(other); + qWarning("UmlMultiplicityElement::compatibleWith(): to be implemented (operation)"); + + Q_UNUSED(other); + return bool (); } /*! @@ -171,7 +233,10 @@ bool QUmlMultiplicityElement::compatibleWith(QUmlMultiplicityElement *other) con */ bool QUmlMultiplicityElement::includesCardinality(int C) const { - return UmlMultiplicityElement::includesCardinality(C); + qWarning("UmlMultiplicityElement::includesCardinality(): to be implemented (operation)"); + + Q_UNUSED(C); + return bool (); } /*! @@ -179,7 +244,10 @@ bool QUmlMultiplicityElement::includesCardinality(int C) const */ bool QUmlMultiplicityElement::includesMultiplicity(QUmlMultiplicityElement *M) const { - return UmlMultiplicityElement::includesMultiplicity(M); + qWarning("UmlMultiplicityElement::includesMultiplicity(): to be implemented (operation)"); + + Q_UNUSED(M); + return bool (); } /*! @@ -187,7 +255,11 @@ bool QUmlMultiplicityElement::includesMultiplicity(QUmlMultiplicityElement *M) c */ bool QUmlMultiplicityElement::is(int lowerbound, int upperbound) const { - return UmlMultiplicityElement::is(lowerbound, upperbound); + qWarning("UmlMultiplicityElement::is(): to be implemented (operation)"); + + Q_UNUSED(lowerbound); + Q_UNUSED(upperbound); + return bool (); } /*! @@ -195,7 +267,9 @@ bool QUmlMultiplicityElement::is(int lowerbound, int upperbound) const */ bool QUmlMultiplicityElement::isMultivalued() const { - return UmlMultiplicityElement::isMultivalued(); + qWarning("UmlMultiplicityElement::isMultivalued(): to be implemented (operation)"); + + return bool (); } /*! @@ -203,60 +277,18 @@ bool QUmlMultiplicityElement::isMultivalued() const */ int QUmlMultiplicityElement::lowerBound() const { - return UmlMultiplicityElement::lowerBound(); + qWarning("UmlMultiplicityElement::lowerBound(): to be implemented (operation)"); + + return int (); } /*! The query upperBound() returns the upper bound of the multiplicity for a bounded multiplicity as an unlimited natural. */ -int QUmlMultiplicityElement::upperBound() const -{ - return UmlMultiplicityElement::upperBound(); -} - -// SLOTS FOR OWNED ATTRIBUTES [Element] - -void QUmlMultiplicityElement::addOwnedComment(UmlComment *ownedComment) -{ - UmlElement::addOwnedComment(ownedComment); -} - -void QUmlMultiplicityElement::removeOwnedComment(UmlComment *ownedComment) -{ - UmlElement::removeOwnedComment(ownedComment); -} - -// SLOTS FOR OWNED ATTRIBUTES [MultiplicityElement] - -void QUmlMultiplicityElement::setOrdered(bool isOrdered) -{ - UmlMultiplicityElement::setOrdered(isOrdered); -} - -void QUmlMultiplicityElement::setUnique(bool isUnique) -{ - UmlMultiplicityElement::setUnique(isUnique); -} - -void QUmlMultiplicityElement::setLower(int lower) -{ - UmlMultiplicityElement::setLower(lower); -} - -void QUmlMultiplicityElement::setLowerValue(QUmlValueSpecification *lowerValue) -{ - UmlMultiplicityElement::setLowerValue(lowerValue); -} - -void QUmlMultiplicityElement::setUpper(int upper) -{ - UmlMultiplicityElement::setUpper(upper); -} - -void QUmlMultiplicityElement::setUpperValue(QUmlValueSpecification *upperValue) -{ - UmlMultiplicityElement::setUpperValue(upperValue); -} - -QT_END_NAMESPACE +//int QUmlMultiplicityElement::upperBound() const +//{ +// qWarning("UmlMultiplicityElement::upperBound(): to be implemented (operation)"); +// +// return int (); +//} |