diff options
Diffstat (limited to 'src/uml/qumlpseudostate.cpp')
-rw-r--r-- | src/uml/qumlpseudostate.cpp | 300 |
1 files changed, 54 insertions, 246 deletions
diff --git a/src/uml/qumlpseudostate.cpp b/src/uml/qumlpseudostate.cpp index bd912acc..22c18619 100644 --- a/src/uml/qumlpseudostate.cpp +++ b/src/uml/qumlpseudostate.cpp @@ -40,300 +40,108 @@ ****************************************************************************/ #include "qumlpseudostate.h" -#include <QtUml/QUmlComment> -#include <QtUml/QUmlDependency> -#include <QtUml/QUmlElement> -#include <QtUml/QUmlNamedElement> -#include <QtUml/QUmlNamespace> -#include <QtUml/QUmlPackage> -#include <QtUml/QUmlRegion> +#include "private/qumlpseudostateobject_p.h" + #include <QtUml/QUmlState> #include <QtUml/QUmlStateMachine> -#include <QtUml/QUmlStringExpression> -#include <QtUml/QUmlTransition> - -QT_BEGIN_NAMESPACE /*! - \class UmlPseudostate + \class QUmlPseudostate \inmodule QtUml \brief A pseudostate is an abstraction that encompasses different types of transient vertices in the state machine graph. */ - -QUmlPseudostate::QUmlPseudostate(QObject *parent) : - QObject(parent) -{ -} - -// OWNED ATTRIBUTES [Element] - -/*! - The Comments owned by this element. - */ -const QSet<QUmlComment *> QUmlPseudostate::ownedComment() const -{ - return *(reinterpret_cast<const QSet<QUmlComment *> *>(&_ownedComment)); -} - -/*! - The Elements owned by this element. - */ -const QSet<QUmlElement *> QUmlPseudostate::ownedElement() const -{ - return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_ownedElement)); -} - -/*! - The Element that owns this element. - */ -QUmlElement *QUmlPseudostate::owner() const -{ - return reinterpret_cast<QUmlElement *>(_owner); -} - -// OWNED ATTRIBUTES [NamedElement] - -/*! - Indicates the dependencies that reference the client. - */ -const QSet<QUmlDependency *> QUmlPseudostate::clientDependency() const -{ - return *(reinterpret_cast<const QSet<QUmlDependency *> *>(&_clientDependency)); -} - -/*! - The name of the NamedElement. - */ -QString QUmlPseudostate::name() const -{ - return _name; -} - -/*! - The string expression used to define the name of this named element. - */ -QUmlStringExpression *QUmlPseudostate::nameExpression() const +QUmlPseudostate::QUmlPseudostate(bool createQObject) : + _kind(QtUml::PseudostateKindInitial), + _state(0), + _stateMachine(0) { - return reinterpret_cast<QUmlStringExpression *>(_nameExpression); + if (createQObject) + _qObject = new QUmlPseudostateObject(this); } -/*! - Specifies the namespace that owns the NamedElement. - */ -QUmlNamespace *QUmlPseudostate::namespace_() const +QUmlPseudostate::~QUmlPseudostate() { - return reinterpret_cast<QUmlNamespace *>(_namespace_); + if (!deletingFromQObject) { + _qObject->setProperty("deletingFromModelingObject", true); + delete _qObject; + } } -/*! - 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 QUmlPseudostate::qualifiedName() const -{ - return UmlNamedElement::qualifiedName(); -} - -/*! - Determines where the NamedElement appears within different Namespaces within the overall model, and its accessibility. - */ -QtUml::VisibilityKind QUmlPseudostate::visibility() const -{ - return _visibility; -} - -// OWNED ATTRIBUTES [Vertex] - -/*! - The region that contains this vertex. - */ -QUmlRegion *QUmlPseudostate::container() const -{ - return reinterpret_cast<QUmlRegion *>(_container); -} - -/*! - Specifies the transitions entering this vertex. - */ -const QSet<QUmlTransition *> QUmlPseudostate::incoming() const -{ - QSet<QUmlTransition *> r; - foreach (UmlTransition *element, UmlVertex::incoming()) - r.insert(reinterpret_cast<QUmlTransition *>(element)); - return r; -} - -/*! - Specifies the transitions departing from this vertex. - */ -const QSet<QUmlTransition *> QUmlPseudostate::outgoing() const -{ - QSet<QUmlTransition *> r; - foreach (UmlTransition *element, UmlVertex::outgoing()) - r.insert(reinterpret_cast<QUmlTransition *>(element)); - return r; -} - -// OWNED ATTRIBUTES [Pseudostate] +// OWNED ATTRIBUTES /*! Determines the precise type of the Pseudostate and can be one of: entryPoint, exitPoint, initial, deepHistory, shallowHistory, join, fork, junction, terminate or choice. */ -QtUml::PseudostateKind QUmlPseudostate::kind() const +QtUml::PseudostateKind +QUmlPseudostate::kind() const { + // This is a read-write property + return _kind; } -/*! - The State that owns this pseudostate and in which it appears. - */ -QUmlState *QUmlPseudostate::state() const +void QUmlPseudostate::setKind(QtUml::PseudostateKind kind) { - return reinterpret_cast<QUmlState *>(_state); -} + // This is a read-write property -/*! - The StateMachine in which this Pseudostate is defined. This only applies to Pseudostates of the kind entryPoint or exitPoint. - */ -QUmlStateMachine *QUmlPseudostate::stateMachine() const -{ - return reinterpret_cast<QUmlStateMachine *>(_stateMachine); + if (_kind != kind) { + _kind = kind; + } } -// OPERATIONS [Element] - /*! - The query allOwnedElements() gives all of the direct and indirect owned elements of an element. + The State that owns this pseudostate and in which it appears. */ -QSet<QUmlElement *> QUmlPseudostate::allOwnedElements() const +QUmlState * +QUmlPseudostate::state() const { - QSet<QUmlElement *> r; - foreach (UmlElement *element, UmlElement::allOwnedElements()) - r.insert(reinterpret_cast<QUmlElement *>(element)); - return r; -} + // This is a read-write association end -/*! - 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 QUmlPseudostate::mustBeOwned() const -{ - return UmlElement::mustBeOwned(); + return _state; } -// OPERATIONS [NamedElement] - -/*! - The query allNamespaces() gives the sequence of namespaces in which the NamedElement is nested, working outwards. - */ -QList<QUmlNamespace *> QUmlPseudostate::allNamespaces() const +void QUmlPseudostate::setState(QUmlState *state) { - 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 *> QUmlPseudostate::allOwningPackages() const -{ - QSet<QUmlPackage *> r; - foreach (UmlPackage *element, UmlNamedElement::allOwningPackages()) - r.insert(reinterpret_cast<QUmlPackage *>(element)); - return r; -} + if (_state != state) { + // Adjust subsetted properties -/*! - 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 QUmlPseudostate::isDistinguishableFrom(QUmlNamedElement *n, QUmlNamespace *ns) const -{ - return UmlNamedElement::isDistinguishableFrom(n, ns); -} + _state = state; + if (state->asQObject() && this->asQObject()) + QObject::connect(state->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setState())); -/*! - The query separator() gives the string that is used to separate names when constructing a qualified name. - */ -QString QUmlPseudostate::separator() const -{ - return UmlNamedElement::separator(); + // Adjust subsetted properties + setNamespace(state); + } } -// OPERATIONS [Vertex] - /*! - The operation containingStateMachine() returns the state machine in which this Vertex is defined + The StateMachine in which this Pseudostate is defined. This only applies to Pseudostates of the kind entryPoint or exitPoint. */ -QUmlStateMachine *QUmlPseudostate::containingStateMachine() const -{ - return reinterpret_cast<QUmlStateMachine *>(UmlVertex::containingStateMachine()); -} - -// SLOTS FOR OWNED ATTRIBUTES [Element] - -void QUmlPseudostate::addOwnedComment(UmlComment *ownedComment) +QUmlStateMachine * +QUmlPseudostate::stateMachine() const { - UmlElement::addOwnedComment(ownedComment); -} + // This is a read-write association end -void QUmlPseudostate::removeOwnedComment(UmlComment *ownedComment) -{ - UmlElement::removeOwnedComment(ownedComment); -} - -// SLOTS FOR OWNED ATTRIBUTES [NamedElement] - -void QUmlPseudostate::addClientDependency(UmlDependency *clientDependency) -{ - UmlNamedElement::addClientDependency(clientDependency); -} - -void QUmlPseudostate::removeClientDependency(UmlDependency *clientDependency) -{ - UmlNamedElement::removeClientDependency(clientDependency); -} - -void QUmlPseudostate::setName(QString name) -{ - UmlNamedElement::setName(name); -} - -void QUmlPseudostate::setNameExpression(QUmlStringExpression *nameExpression) -{ - UmlNamedElement::setNameExpression(nameExpression); + return _stateMachine; } -void QUmlPseudostate::setVisibility(QtUml::VisibilityKind visibility) -{ - UmlNamedElement::setVisibility(visibility); -} - -// SLOTS FOR OWNED ATTRIBUTES [Vertex] - -void QUmlPseudostate::setContainer(QUmlRegion *container) +void QUmlPseudostate::setStateMachine(QUmlStateMachine *stateMachine) { - UmlVertex::setContainer(container); -} + // This is a read-write association end -// SLOTS FOR OWNED ATTRIBUTES [Pseudostate] - -void QUmlPseudostate::setKind(QtUml::PseudostateKind kind) -{ - UmlPseudostate::setKind(kind); -} + if (_stateMachine != stateMachine) { + // Adjust subsetted properties -void QUmlPseudostate::setState(QUmlState *state) -{ - UmlPseudostate::setState(state); -} + _stateMachine = stateMachine; + if (stateMachine->asQObject() && this->asQObject()) + QObject::connect(stateMachine->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setStateMachine())); -void QUmlPseudostate::setStateMachine(QUmlStateMachine *stateMachine) -{ - UmlPseudostate::setStateMachine(stateMachine); + // Adjust subsetted properties + setNamespace(stateMachine); + } } -QT_END_NAMESPACE - |