diff options
Diffstat (limited to 'src/uml/qumldurationobservation.cpp')
-rw-r--r-- | src/uml/qumldurationobservation.cpp | 281 |
1 files changed, 34 insertions, 247 deletions
diff --git a/src/uml/qumldurationobservation.cpp b/src/uml/qumldurationobservation.cpp index 899c297f..e774f4ba 100644 --- a/src/uml/qumldurationobservation.cpp +++ b/src/uml/qumldurationobservation.cpp @@ -40,286 +40,73 @@ ****************************************************************************/ #include "qumldurationobservation.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 "private/qumldurationobservationobject_p.h" -QT_BEGIN_NAMESPACE +#include <QtUml/QUmlNamedElement> /*! - \class UmlDurationObservation + \class QUmlDurationObservation \inmodule QtUml \brief A duration observation is a reference to a duration during an execution. It points out the element(s) in the model to observe and whether the observations are when this model element is entered or when it is exited. */ - -QUmlDurationObservation::QUmlDurationObservation(QObject *parent) : - QObject(parent) -{ -} - -// OWNED ATTRIBUTES [Element] - -/*! - The Comments owned by this element. - */ -const QSet<QUmlComment *> QUmlDurationObservation::ownedComment() const +QUmlDurationObservation::QUmlDurationObservation(bool createQObject) : + _event(0) { - return *(reinterpret_cast<const QSet<QUmlComment *> *>(&_ownedComment)); + if (createQObject) + _qObject = new QUmlDurationObservationObject(this); } -/*! - The Elements owned by this element. - */ -const QSet<QUmlElement *> QUmlDurationObservation::ownedElement() const +QUmlDurationObservation::~QUmlDurationObservation() { - return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_ownedElement)); + if (!deletingFromQObject) { + _qObject->setProperty("deletingFromModelingObject", true); + delete _qObject; + } } -/*! - The Element that owns this element. - */ -QUmlElement *QUmlDurationObservation::owner() const -{ - return reinterpret_cast<QUmlElement *>(_owner); -} - -// OWNED ATTRIBUTES [ParameterableElement] - -/*! - The formal template parameter that owns this element. - */ -QUmlTemplateParameter *QUmlDurationObservation::owningTemplateParameter() const -{ - return reinterpret_cast<QUmlTemplateParameter *>(_owningTemplateParameter); -} - -/*! - The template parameter that exposes this element as a formal parameter. - */ -QUmlTemplateParameter *QUmlDurationObservation::templateParameter() const -{ - return reinterpret_cast<QUmlTemplateParameter *>(_templateParameter); -} - -// OWNED ATTRIBUTES [NamedElement] - -/*! - Indicates the dependencies that reference the client. - */ -const QSet<QUmlDependency *> QUmlDurationObservation::clientDependency() const -{ - return *(reinterpret_cast<const QSet<QUmlDependency *> *>(&_clientDependency)); -} - -/*! - The name of the NamedElement. - */ -QString QUmlDurationObservation::name() const -{ - return _name; -} - -/*! - The string expression used to define the name of this named element. - */ -QUmlStringExpression *QUmlDurationObservation::nameExpression() const -{ - return reinterpret_cast<QUmlStringExpression *>(_nameExpression); -} - -/*! - Specifies the namespace that owns the NamedElement. - */ -QUmlNamespace *QUmlDurationObservation::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 QUmlDurationObservation::qualifiedName() const -{ - return UmlNamedElement::qualifiedName(); -} -// OWNED ATTRIBUTES [PackageableElement] - -/*! - Indicates that packageable elements must always have a visibility, i.e., visibility is not optional. - */ -QtUml::VisibilityKind QUmlDurationObservation::visibility() const -{ - return _visibility; -} - -// OWNED ATTRIBUTES [DurationObservation] +// OWNED ATTRIBUTES /*! The observation is determined by the entering or exiting of the event element during execution. */ -QUmlNamedElement *QUmlDurationObservation::event() const +QUmlNamedElement * +QUmlDurationObservation::event() const { - return reinterpret_cast<QUmlNamedElement *>(_event); -} + // This is a read-write association end -/*! - The value of firstEvent[i] is related to event[i] (where i is 1 or 2). If firstEvent[i] is true, then the corresponding observation event is the first time instant the execution enters event[i]. If firstEvent[i] is false, then the corresponding observation event is the time instant the execution exits event[i]. Default value is true applied when event[i] refers an element that represents only one time instant. - */ -bool QUmlDurationObservation::firstEvent() const -{ - return _firstEvent; + return _event; } -// OPERATIONS [Element] - -/*! - The query allOwnedElements() gives all of the direct and indirect owned elements of an element. - */ -QSet<QUmlElement *> QUmlDurationObservation::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 QUmlDurationObservation::mustBeOwned() const -{ - return UmlElement::mustBeOwned(); -} - -// OPERATIONS [ParameterableElement] - -/*! - 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 QUmlDurationObservation::isCompatibleWith(QUmlParameterableElement *p) const -{ - return UmlParameterableElement::isCompatibleWith(p); -} - -/*! - The query isTemplateParameter() determines if this parameterable element is exposed as a formal template parameter. - */ -bool QUmlDurationObservation::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 *> QUmlDurationObservation::allNamespaces() const +void QUmlDurationObservation::setEvent(QUmlNamedElement *event) { - 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 *> QUmlDurationObservation::allOwningPackages() const -{ - QSet<QUmlPackage *> r; - foreach (UmlPackage *element, UmlNamedElement::allOwningPackages()) - r.insert(reinterpret_cast<QUmlPackage *>(element)); - return r; + if (_event != event) { + _event = event; + if (event->asQObject() && this->asQObject()) + QObject::connect(event->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setEvent())); + } } /*! - 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 QUmlDurationObservation::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. + The value of firstEvent[i] is related to event[i] (where i is 1 or 2). If firstEvent[i] is true, then the corresponding observation event is the first time instant the execution enters event[i]. If firstEvent[i] is false, then the corresponding observation event is the time instant the execution exits event[i]. Default value is true applied when event[i] refers an element that represents only one time instant. */ -QString QUmlDurationObservation::separator() const -{ - return UmlNamedElement::separator(); -} - -// SLOTS FOR OWNED ATTRIBUTES [Element] - -void QUmlDurationObservation::addOwnedComment(UmlComment *ownedComment) -{ - UmlElement::addOwnedComment(ownedComment); -} - -void QUmlDurationObservation::removeOwnedComment(UmlComment *ownedComment) -{ - UmlElement::removeOwnedComment(ownedComment); -} - -// SLOTS FOR OWNED ATTRIBUTES [ParameterableElement] - -void QUmlDurationObservation::setOwningTemplateParameter(QUmlTemplateParameter *owningTemplateParameter) -{ - UmlParameterableElement::setOwningTemplateParameter(owningTemplateParameter); -} - -void QUmlDurationObservation::setTemplateParameter(QUmlTemplateParameter *templateParameter) -{ - UmlParameterableElement::setTemplateParameter(templateParameter); -} - -// SLOTS FOR OWNED ATTRIBUTES [NamedElement] - -void QUmlDurationObservation::addClientDependency(UmlDependency *clientDependency) -{ - UmlNamedElement::addClientDependency(clientDependency); -} - -void QUmlDurationObservation::removeClientDependency(UmlDependency *clientDependency) +bool +QUmlDurationObservation::firstEvent() const { - UmlNamedElement::removeClientDependency(clientDependency); -} - -void QUmlDurationObservation::setName(QString name) -{ - UmlNamedElement::setName(name); -} + // This is a read-write property -void QUmlDurationObservation::setNameExpression(QUmlStringExpression *nameExpression) -{ - UmlNamedElement::setNameExpression(nameExpression); -} -// SLOTS FOR OWNED ATTRIBUTES [PackageableElement] - -void QUmlDurationObservation::setVisibility(QtUml::VisibilityKind visibility) -{ - UmlPackageableElement::setVisibility(visibility); -} - -// SLOTS FOR OWNED ATTRIBUTES [DurationObservation] - -void QUmlDurationObservation::setEvent(QUmlNamedElement *event) -{ - UmlDurationObservation::setEvent(event); + return _firstEvent; } void QUmlDurationObservation::setFirstEvent(bool firstEvent) { - UmlDurationObservation::setFirstEvent(firstEvent); -} + // This is a read-write property -QT_END_NAMESPACE + if (_firstEvent != firstEvent) { + _firstEvent = firstEvent; + } +} |