summaryrefslogtreecommitdiffstats
path: root/src/uml/qumlparameter.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/qumlparameter.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/qumlparameter.cpp')
-rw-r--r--src/uml/qumlparameter.cpp558
1 files changed, 125 insertions, 433 deletions
diff --git a/src/uml/qumlparameter.cpp b/src/uml/qumlparameter.cpp
index 96f95cae..c0a0513d 100644
--- a/src/uml/qumlparameter.cpp
+++ b/src/uml/qumlparameter.cpp
@@ -40,544 +40,236 @@
****************************************************************************/
#include "qumlparameter.h"
-#include <QtUml/QUmlComment>
-#include <QtUml/QUmlConnectableElementTemplateParameter>
-#include <QtUml/QUmlConnectorEnd>
-#include <QtUml/QUmlDependency>
-#include <QtUml/QUmlElement>
-#include <QtUml/QUmlMultiplicityElement>
-#include <QtUml/QUmlNamedElement>
-#include <QtUml/QUmlNamespace>
+#include "private/qumlparameterobject_p.h"
+
#include <QtUml/QUmlOperation>
-#include <QtUml/QUmlPackage>
-#include <QtUml/QUmlParameterableElement>
#include <QtUml/QUmlParameterSet>
-#include <QtUml/QUmlStringExpression>
-#include <QtUml/QUmlTemplateParameter>
-#include <QtUml/QUmlType>
#include <QtUml/QUmlValueSpecification>
-QT_BEGIN_NAMESPACE
-
/*!
- \class UmlParameter
+ \class QUmlParameter
\inmodule QtUml
\brief Parameters are allowed to be treated as connectable elements.A parameter is a specification of an argument used to pass information into or out of an invocation of a behavioral feature.Parameters have support for streaming, exceptions, and parameter sets.
*/
-
-QUmlParameter::QUmlParameter(QObject *parent) :
- QObject(parent)
-{
-}
-
-// OWNED ATTRIBUTES [Element]
-
-/*!
- The Comments owned by this element.
- */
-const QSet<QUmlComment *> QUmlParameter::ownedComment() const
-{
- return *(reinterpret_cast<const QSet<QUmlComment *> *>(&_ownedComment));
-}
-
-/*!
- The Elements owned by this element.
- */
-const QSet<QUmlElement *> QUmlParameter::ownedElement() const
-{
- return *(reinterpret_cast<const QSet<QUmlElement *> *>(&_ownedElement));
-}
-
-/*!
- The Element that owns this element.
- */
-QUmlElement *QUmlParameter::owner() const
-{
- return reinterpret_cast<QUmlElement *>(_owner);
-}
-
-// OWNED ATTRIBUTES [MultiplicityElement]
-
-/*!
- For a multivalued multiplicity, this attribute specifies whether the values in an instantiation of this element are sequentially ordered.
- */
-bool QUmlParameter::isOrdered() const
-{
- return _isOrdered;
-}
-
-/*!
- For a multivalued multiplicity, this attributes specifies whether the values in an instantiation of this element are unique.
- */
-bool QUmlParameter::isUnique() const
-{
- return _isUnique;
-}
-
-/*!
- Specifies the lower bound of the multiplicity interval.
- */
-int QUmlParameter::lower() const
-{
- return UmlMultiplicityElement::lower();
-}
-
-/*!
- The specification of the lower bound for this multiplicity.
- */
-QUmlValueSpecification *QUmlParameter::lowerValue() const
-{
- return reinterpret_cast<QUmlValueSpecification *>(_lowerValue);
-}
-
-/*!
- Specifies the upper bound of the multiplicity interval.
- */
-int QUmlParameter::upper() const
+QUmlParameter::QUmlParameter(bool createQObject) :
+ _defaultValue(0),
+ _direction(QtUml::ParameterDirectionKindIn),
+ _isException(false),
+ _isStream(false),
+ _operation(0)
{
- return UmlMultiplicityElement::upper();
+ if (createQObject)
+ _qObject = new QUmlParameterObject(this);
}
-/*!
- The specification of the upper bound for this multiplicity.
- */
-QUmlValueSpecification *QUmlParameter::upperValue() const
+QUmlParameter::~QUmlParameter()
{
- return reinterpret_cast<QUmlValueSpecification *>(_upperValue);
+ if (!deletingFromQObject) {
+ _qObject->setProperty("deletingFromModelingObject", true);
+ delete _qObject;
+ }
}
-// OWNED ATTRIBUTES [NamedElement]
+// OWNED ATTRIBUTES
/*!
- Indicates the dependencies that reference the client.
- */
-const QSet<QUmlDependency *> QUmlParameter::clientDependency() const
-{
- return *(reinterpret_cast<const QSet<QUmlDependency *> *>(&_clientDependency));
-}
-
-/*!
- The name of the NamedElement.
- */
-QString QUmlParameter::name() const
-{
- return _name;
-}
-
-/*!
- The string expression used to define the name of this named element.
+ Specifies a String that represents a value to be used when no argument is supplied for the Parameter.
*/
-QUmlStringExpression *QUmlParameter::nameExpression() const
+QString
+QUmlParameter::default_() const
{
- return reinterpret_cast<QUmlStringExpression *>(_nameExpression);
-}
+ // This is a read-write derived property
-/*!
- Specifies the namespace that owns the NamedElement.
- */
-QUmlNamespace *QUmlParameter::namespace_() const
-{
- return reinterpret_cast<QUmlNamespace *>(_namespace_);
-}
+ qWarning("UmlParameter::default_(): to be implemented (this is a derived property)");
-/*!
- 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 QUmlParameter::qualifiedName() const
-{
- return UmlNamedElement::qualifiedName();
+ return QString();
}
-/*!
- Determines where the NamedElement appears within different Namespaces within the overall model, and its accessibility.
- */
-QtUml::VisibilityKind QUmlParameter::visibility() const
+void QUmlParameter::setDefault(QString default_)
{
- return _visibility;
-}
+ // This is a read-write derived property
-// OWNED ATTRIBUTES [TypedElement]
+ qWarning("UmlParameter::default_(): to be implemented (this is a derived property)");
+ Q_UNUSED(default_);
-/*!
- This information is derived from the return result for this Operation.The type of the TypedElement.
- */
-QUmlType *QUmlParameter::type() const
-{
- return reinterpret_cast<QUmlType *>(_type);
+ if (false /* <derivedexclusion-criteria> */) {
+ // <derived-code>
+ }
}
-// OWNED ATTRIBUTES [ParameterableElement]
-
/*!
- The formal template parameter that owns this element.
+ Specifies a ValueSpecification that represents a value to be used when no argument is supplied for the Parameter.
*/
-QUmlTemplateParameter *QUmlParameter::owningTemplateParameter() const
+QUmlValueSpecification *
+QUmlParameter::defaultValue() const
{
- return reinterpret_cast<QUmlTemplateParameter *>(_owningTemplateParameter);
-}
-// OWNED ATTRIBUTES [ConnectableElement]
+ // This is a read-write association end
-/*!
- Denotes a set of connector ends that attaches to this connectable element.
- */
-const QList<QUmlConnectorEnd *> QUmlParameter::end() const
-{
- QList<QUmlConnectorEnd *> r;
- foreach (UmlConnectorEnd *element, UmlConnectableElement::end())
- r.append(reinterpret_cast<QUmlConnectorEnd *>(element));
- return r;
+ return _defaultValue;
}
-/*!
- The ConnectableElementTemplateParameter for this ConnectableElement parameter.
- */
-QUmlConnectableElementTemplateParameter *QUmlParameter::templateParameter() const
+void QUmlParameter::setDefaultValue(QUmlValueSpecification *defaultValue)
{
- return reinterpret_cast<QUmlConnectableElementTemplateParameter *>(_templateParameter);
-}
+ // This is a read-write association end
-// OWNED ATTRIBUTES [Parameter]
+ if (_defaultValue != defaultValue) {
+ // Adjust subsetted properties
+ removeOwnedElement(_defaultValue);
-/*!
- Specifies a String that represents a value to be used when no argument is supplied for the Parameter.
- */
-QString QUmlParameter::default_() const
-{
- return UmlParameter::default_();
-}
+ _defaultValue = defaultValue;
+ if (defaultValue->asQObject() && this->asQObject())
+ QObject::connect(defaultValue->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setDefaultValue()));
+ defaultValue->asQObject()->setParent(this->asQObject());
-/*!
- Specifies a ValueSpecification that represents a value to be used when no argument is supplied for the Parameter.
- */
-QUmlValueSpecification *QUmlParameter::defaultValue() const
-{
- return reinterpret_cast<QUmlValueSpecification *>(_defaultValue);
+ // Adjust subsetted properties
+ if (defaultValue) {
+ addOwnedElement(defaultValue);
+ }
+ }
}
/*!
Indicates whether a parameter is being sent into or out of a behavioral element.
*/
-QtUml::ParameterDirectionKind QUmlParameter::direction() const
+QtUml::ParameterDirectionKind
+QUmlParameter::direction() const
{
+ // This is a read-write property
+
return _direction;
}
-/*!
- Specifies the effect that the owner of the parameter has on values passed in or out of the parameter.
- */
-QtUml::ParameterEffectKind QUmlParameter::effect() const
+void QUmlParameter::setDirection(QtUml::ParameterDirectionKind direction)
{
- return _effect;
-}
+ // This is a read-write property
-/*!
- Tells whether an output parameter may emit a value to the exclusion of the other outputs.
- */
-bool QUmlParameter::isException() const
-{
- return _isException;
+ if (_direction != direction) {
+ _direction = direction;
+ }
}
/*!
- Tells whether an input parameter may accept values while its behavior is executing, or whether an output parameter post values while the behavior is executing.
+ Specifies the effect that the owner of the parameter has on values passed in or out of the parameter.
*/
-bool QUmlParameter::isStream() const
+QtUml::ParameterEffectKind
+QUmlParameter::effect() const
{
- return _isStream;
-}
+ // This is a read-write property
-/*!
- References the Operation owning this parameter.
- */
-QUmlOperation *QUmlParameter::operation() const
-{
- return reinterpret_cast<QUmlOperation *>(_operation);
+ return _effect;
}
-/*!
- The parameter sets containing the parameter. See ParameterSet.
- */
-const QSet<QUmlParameterSet *> QUmlParameter::parameterSet() const
+void QUmlParameter::setEffect(QtUml::ParameterEffectKind effect)
{
- return *(reinterpret_cast<const QSet<QUmlParameterSet *> *>(&_parameterSet));
-}
-
-// OPERATIONS [Element]
+ // This is a read-write property
-/*!
- The query allOwnedElements() gives all of the direct and indirect owned elements of an element.
- */
-QSet<QUmlElement *> QUmlParameter::allOwnedElements() const
-{
- QSet<QUmlElement *> r;
- foreach (UmlElement *element, UmlElement::allOwnedElements())
- r.insert(reinterpret_cast<QUmlElement *>(element));
- return r;
+ if (_effect != effect) {
+ _effect = effect;
+ }
}
/*!
- 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 QUmlParameter::mustBeOwned() const
-{
- return UmlElement::mustBeOwned();
-}
-
-// OPERATIONS [MultiplicityElement]
-
-/*!
- The operation compatibleWith takes another multiplicity as input. It checks if one multiplicity is compatible with another.
+ Tells whether an output parameter may emit a value to the exclusion of the other outputs.
*/
-bool QUmlParameter::compatibleWith(QUmlMultiplicityElement *other) const
+bool
+QUmlParameter::isException() const
{
- return UmlMultiplicityElement::compatibleWith(other);
-}
+ // This is a read-write property
-/*!
- The query includesCardinality() checks whether the specified cardinality is valid for this multiplicity.
- */
-bool QUmlParameter::includesCardinality(int C) const
-{
- return UmlMultiplicityElement::includesCardinality(C);
+ return _isException;
}
-/*!
- The query includesMultiplicity() checks whether this multiplicity includes all the cardinalities allowed by the specified multiplicity.
- */
-bool QUmlParameter::includesMultiplicity(QUmlMultiplicityElement *M) const
+void QUmlParameter::setException(bool isException)
{
- return UmlMultiplicityElement::includesMultiplicity(M);
-}
+ // This is a read-write property
-/*!
- The operation is determines if the upper and lower bound of the ranges are the ones given.
- */
-bool QUmlParameter::is(int lowerbound, int upperbound) const
-{
- return UmlMultiplicityElement::is(lowerbound, upperbound);
+ if (_isException != isException) {
+ _isException = isException;
+ }
}
/*!
- The query isMultivalued() checks whether this multiplicity has an upper bound greater than one.
+ Tells whether an input parameter may accept values while its behavior is executing, or whether an output parameter post values while the behavior is executing.
*/
-bool QUmlParameter::isMultivalued() const
+bool
+QUmlParameter::isStream() const
{
- return UmlMultiplicityElement::isMultivalued();
-}
+ // This is a read-write property
-/*!
- The query lowerBound() returns the lower bound of the multiplicity as an integer.
- */
-int QUmlParameter::lowerBound() const
-{
- return UmlMultiplicityElement::lowerBound();
+ return _isStream;
}
-/*!
- The query upperBound() returns the upper bound of the multiplicity for a bounded multiplicity as an unlimited natural.
- */
-int QUmlParameter::upperBound() const
+void QUmlParameter::setStream(bool isStream)
{
- return UmlMultiplicityElement::upperBound();
-}
-
-// OPERATIONS [NamedElement]
+ // This is a read-write property
-/*!
- The query allNamespaces() gives the sequence of namespaces in which the NamedElement is nested, working outwards.
- */
-QList<QUmlNamespace *> QUmlParameter::allNamespaces() const
-{
- QList<QUmlNamespace *> r;
- foreach (UmlNamespace *element, UmlNamedElement::allNamespaces())
- r.append(reinterpret_cast<QUmlNamespace *>(element));
- return r;
+ if (_isStream != isStream) {
+ _isStream = isStream;
+ }
}
/*!
- The query allOwningPackages() returns all the directly or indirectly owning packages.
+ References the Operation owning this parameter.
*/
-QSet<QUmlPackage *> QUmlParameter::allOwningPackages() const
+QUmlOperation *
+QUmlParameter::operation() const
{
- QSet<QUmlPackage *> r;
- foreach (UmlPackage *element, UmlNamedElement::allOwningPackages())
- r.insert(reinterpret_cast<QUmlPackage *>(element));
- return r;
-}
+ // This is a read-write association end
-/*!
- 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 QUmlParameter::isDistinguishableFrom(QUmlNamedElement *n, QUmlNamespace *ns) const
-{
- return UmlNamedElement::isDistinguishableFrom(n, ns);
+ return _operation;
}
-/*!
- The query separator() gives the string that is used to separate names when constructing a qualified name.
- */
-QString QUmlParameter::separator() const
+void QUmlParameter::setOperation(QUmlOperation *operation)
{
- return UmlNamedElement::separator();
-}
-
-// 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 QUmlParameter::isCompatibleWith(QUmlParameterableElement *p) const
-{
- return UmlParameterableElement::isCompatibleWith(p);
+ if (_operation != operation) {
+ _operation = operation;
+ if (operation->asQObject() && this->asQObject())
+ QObject::connect(operation->asQObject(), SIGNAL(destroyed()), this->asQObject(), SLOT(setOperation()));
+ }
}
/*!
- The query isTemplateParameter() determines if this parameterable element is exposed as a formal template parameter.
+ The parameter sets containing the parameter. See ParameterSet.
*/
-bool QUmlParameter::isTemplateParameter() const
+const QSet<QUmlParameterSet *>
+QUmlParameter::parameterSet() const
{
- return UmlParameterableElement::isTemplateParameter();
-}
-
-// SLOTS FOR OWNED ATTRIBUTES [Element]
+ // This is a read-write association end
-void QUmlParameter::addOwnedComment(UmlComment *ownedComment)
-{
- UmlElement::addOwnedComment(ownedComment);
+ return _parameterSet;
}
-void QUmlParameter::removeOwnedComment(UmlComment *ownedComment)
+void QUmlParameter::addParameterSet(QUmlParameterSet *parameterSet)
{
- UmlElement::removeOwnedComment(ownedComment);
-}
+ // This is a read-write association end
-// SLOTS FOR OWNED ATTRIBUTES [MultiplicityElement]
+ if (!_parameterSet.contains(parameterSet)) {
+ _parameterSet.insert(parameterSet);
+ if (parameterSet->asQObject() && this->asQObject())
+ QObject::connect(parameterSet->asQObject(), SIGNAL(destroyed(QObject*)), this->asQObject(), SLOT(removeParameterSet(QObject *)));
-void QUmlParameter::setOrdered(bool isOrdered)
-{
- UmlMultiplicityElement::setOrdered(isOrdered);
+ // Adjust opposite properties
+ if (parameterSet) {
+ parameterSet->addParameter(this);
+ }
+ }
}
-void QUmlParameter::setUnique(bool isUnique)
+void QUmlParameter::removeParameterSet(QUmlParameterSet *parameterSet)
{
- UmlMultiplicityElement::setUnique(isUnique);
-}
+ // This is a read-write association end
-void QUmlParameter::setLower(int lower)
-{
- UmlMultiplicityElement::setLower(lower);
-}
+ if (_parameterSet.contains(parameterSet)) {
+ _parameterSet.remove(parameterSet);
-void QUmlParameter::setLowerValue(QUmlValueSpecification *lowerValue)
-{
- UmlMultiplicityElement::setLowerValue(lowerValue);
+ // Adjust opposite properties
+ if (parameterSet) {
+ parameterSet->removeParameter(this);
+ }
+ }
}
-void QUmlParameter::setUpper(int upper)
-{
- UmlMultiplicityElement::setUpper(upper);
-}
-
-void QUmlParameter::setUpperValue(QUmlValueSpecification *upperValue)
-{
- UmlMultiplicityElement::setUpperValue(upperValue);
-}
-
-// SLOTS FOR OWNED ATTRIBUTES [NamedElement]
-
-void QUmlParameter::addClientDependency(UmlDependency *clientDependency)
-{
- UmlNamedElement::addClientDependency(clientDependency);
-}
-
-void QUmlParameter::removeClientDependency(UmlDependency *clientDependency)
-{
- UmlNamedElement::removeClientDependency(clientDependency);
-}
-
-void QUmlParameter::setName(QString name)
-{
- UmlNamedElement::setName(name);
-}
-
-void QUmlParameter::setNameExpression(QUmlStringExpression *nameExpression)
-{
- UmlNamedElement::setNameExpression(nameExpression);
-}
-
-void QUmlParameter::setVisibility(QtUml::VisibilityKind visibility)
-{
- UmlNamedElement::setVisibility(visibility);
-}
-
-// SLOTS FOR OWNED ATTRIBUTES [TypedElement]
-
-void QUmlParameter::setType(QUmlType *type)
-{
- UmlTypedElement::setType(type);
-}
-
-// SLOTS FOR OWNED ATTRIBUTES [ParameterableElement]
-
-void QUmlParameter::setOwningTemplateParameter(QUmlTemplateParameter *owningTemplateParameter)
-{
- UmlParameterableElement::setOwningTemplateParameter(owningTemplateParameter);
-}
-// SLOTS FOR OWNED ATTRIBUTES [ConnectableElement]
-
-void QUmlParameter::setTemplateParameter(QUmlConnectableElementTemplateParameter *templateParameter)
-{
- UmlConnectableElement::setTemplateParameter(templateParameter);
-}
-
-// SLOTS FOR OWNED ATTRIBUTES [Parameter]
-
-void QUmlParameter::setDefault(QString default_)
-{
- UmlParameter::setDefault(default_);
-}
-
-void QUmlParameter::setDefaultValue(QUmlValueSpecification *defaultValue)
-{
- UmlParameter::setDefaultValue(defaultValue);
-}
-
-void QUmlParameter::setDirection(QtUml::ParameterDirectionKind direction)
-{
- UmlParameter::setDirection(direction);
-}
-
-void QUmlParameter::setEffect(QtUml::ParameterEffectKind effect)
-{
- UmlParameter::setEffect(effect);
-}
-
-void QUmlParameter::setException(bool isException)
-{
- UmlParameter::setException(isException);
-}
-
-void QUmlParameter::setStream(bool isStream)
-{
- UmlParameter::setStream(isStream);
-}
-
-void QUmlParameter::setOperation(QUmlOperation *operation)
-{
- UmlParameter::setOperation(operation);
-}
-
-void QUmlParameter::addParameterSet(UmlParameterSet *parameterSet)
-{
- UmlParameter::addParameterSet(parameterSet);
-}
-
-void QUmlParameter::removeParameterSet(UmlParameterSet *parameterSet)
-{
- UmlParameter::removeParameterSet(parameterSet);
-}
-
-QT_END_NAMESPACE
-