summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2016-10-20 22:47:01 (GMT)
committerRalf Habacker <ralf.habacker@freenet.de>2016-10-21 07:57:54 (GMT)
commit828f7dac7316cf8b0b13e290b51fcd114b3e06d1 (patch)
tree265eb54db5fb2a34768e632e66f2f2f8126a6d1a
parent652c076039a9b1db2151c820918b955347da9a0a (diff)
Introduce class UMLDatatype.
CCBUG:371274
-rw-r--r--umbrello/CMakeLists.txt1
-rw-r--r--umbrello/codegenerators/ada/adawriter.cpp4
-rw-r--r--umbrello/codegenerators/codegenerator.cpp8
-rw-r--r--umbrello/codegenerators/cpp/cppheadercodedocument.cpp2
-rw-r--r--umbrello/codegenerators/d/dclassifiercodedocument.cpp2
-rw-r--r--umbrello/codegenerators/d/dwriter.cpp2
-rw-r--r--umbrello/codegenerators/idl/idlwriter.cpp2
-rw-r--r--umbrello/codegenerators/java/javaclassifiercodedocument.cpp2
-rw-r--r--umbrello/codegenerators/java/javawriter.cpp2
-rw-r--r--umbrello/codegenerators/pascal/pascalwriter.cpp2
-rw-r--r--umbrello/codegenerators/perl/perlwriter.cpp2
-rw-r--r--umbrello/codeimport/import_utils.cpp7
-rw-r--r--umbrello/codeimport/kdevcppparser/cpptree2uml.cpp3
-rw-r--r--umbrello/dialogs/pages/classgeneralpage.cpp17
-rw-r--r--umbrello/object_factory.cpp7
-rw-r--r--umbrello/umldoc.cpp2
-rw-r--r--umbrello/umlmodel/classifier.cpp60
-rw-r--r--umbrello/umlmodel/classifier.h10
-rw-r--r--umbrello/umlmodel/datatype.cpp101
-rw-r--r--umbrello/umlmodel/datatype.h45
-rw-r--r--umbrello/umlmodel/umlobject.cpp2
-rw-r--r--umbrello/umlmodel/umlobject.h3
-rw-r--r--umbrello/umlscene.cpp13
23 files changed, 195 insertions, 104 deletions
diff --git a/umbrello/CMakeLists.txt b/umbrello/CMakeLists.txt
index 81b25ab..b389063 100644
--- a/umbrello/CMakeLists.txt
+++ b/umbrello/CMakeLists.txt
@@ -408,6 +408,7 @@ set(libuml_SRCS
umlmodel/classifier.cpp
umlmodel/classifierlistitem.cpp
umlmodel/component.cpp
+ umlmodel/datatype.cpp
umlmodel/entity.cpp
umlmodel/entityattribute.cpp
umlmodel/entityconstraint.cpp
diff --git a/umbrello/codegenerators/ada/adawriter.cpp b/umbrello/codegenerators/ada/adawriter.cpp
index ae3d163..06b4564 100644
--- a/umbrello/codegenerators/ada/adawriter.cpp
+++ b/umbrello/codegenerators/ada/adawriter.cpp
@@ -264,7 +264,7 @@ void AdaWriter::writeClass(UMLClassifier *c)
findObjectsRelated(c, imports);
if (imports.count()) {
foreach (UMLPackage* con, imports) {
- if (con->baseType() == UMLObject::ot_Datatype)
+ if (con->isUMLDatatype())
continue;
QString pkgDep = packageName(con);
if (pkgDep != pkg)
@@ -292,7 +292,7 @@ void AdaWriter::writeClass(UMLClassifier *c)
ada << indent() << "type " << formalName << " is new " << typeName
<< " with private; -- CHECK: codegen error"
<< m_endl;
- } else if (typeObj->baseType() == UMLObject::ot_Datatype) {
+ } else if (typeObj->isUMLDatatype()) {
ada << indent() << formalName << " : " << typeName << ";"
<< m_endl;
} else {
diff --git a/umbrello/codegenerators/codegenerator.cpp b/umbrello/codegenerators/codegenerator.cpp
index 9414a6e..a8c4a12 100644
--- a/umbrello/codegenerators/codegenerator.cpp
+++ b/umbrello/codegenerators/codegenerator.cpp
@@ -652,7 +652,7 @@ void CodeGenerator::findObjectsRelated(UMLClassifier *c, UMLPackageList &cList)
{
UMLObject *objA = a->getObject(Uml::RoleType::A);
UMLObject *objB = a->getObject(Uml::RoleType::B);
- if (objA == c && objB->baseType() != UMLObject::ot_Datatype) {
+ if (objA == c && !objB->isUMLDatatype()) {
temp = objB->asUMLPackage();
}
}
@@ -673,14 +673,14 @@ void CodeGenerator::findObjectsRelated(UMLClassifier *c, UMLPackageList &cList)
temp = 0;
//check return value
temp = (UMLClassifier*) op->getType();
- if (temp && temp->baseType() != UMLObject::ot_Datatype && !cList.count(temp)) {
+ if (temp && !temp->isUMLDatatype() && !cList.count(temp)) {
cList.append(temp);
}
//check parameters
UMLAttributeList atl = op->getParmList();
foreach(UMLAttribute *at, atl) {
temp = (UMLClassifier*)at->getType();
- if (temp && temp->baseType() != UMLObject::ot_Datatype && !cList.count(temp)) {
+ if (temp && !temp->isUMLDatatype() && !cList.count(temp)) {
cList.append(temp);
}
}
@@ -692,7 +692,7 @@ void CodeGenerator::findObjectsRelated(UMLClassifier *c, UMLPackageList &cList)
foreach (UMLAttribute *at, atl) {
temp=0;
temp = (UMLClassifier*) at->getType();
- if (temp && temp->baseType() != UMLObject::ot_Datatype && !cList.count(temp)) {
+ if (temp && !temp->isUMLDatatype() && !cList.count(temp)) {
cList.append(temp);
}
}
diff --git a/umbrello/codegenerators/cpp/cppheadercodedocument.cpp b/umbrello/codegenerators/cpp/cppheadercodedocument.cpp
index 58b1e35..6cfb48e 100644
--- a/umbrello/codegenerators/cpp/cppheadercodedocument.cpp
+++ b/umbrello/codegenerators/cpp/cppheadercodedocument.cpp
@@ -419,7 +419,7 @@ void CPPHeaderCodeDocument::updateContent()
CodeGenerator::findObjectsRelated(c, includes);
foreach(UMLPackage* con, includes) {
- if (con->baseType() != UMLObject::ot_Datatype && !packageMap.contains(con)) {
+ if (!con->isUMLDatatype() && !packageMap.contains(con)) {
packageMap.insert(con, con->package());
if(con != getParentClassifier())
includeStatement.append(QLatin1String("#include \"") + CodeGenerator::cleanName(con->name().toLower()) + QLatin1String(".h\"") + endLine);
diff --git a/umbrello/codegenerators/d/dclassifiercodedocument.cpp b/umbrello/codegenerators/d/dclassifiercodedocument.cpp
index fd8af7c..5739bb2 100644
--- a/umbrello/codegenerators/d/dclassifiercodedocument.cpp
+++ b/umbrello/codegenerators/d/dclassifiercodedocument.cpp
@@ -351,7 +351,7 @@ void DClassifierCodeDocument::updateContent()
// NO (default) datatypes in the import statement.. use defined
// ones whould be possible, but no idea how to do that...at least for now.
// Dynamic casting is slow..not an optimal way to do this.
- if (!packageMap.contains(con) && con->baseType() != UMLObject::ot_Datatype)
+ if (!packageMap.contains(con) && !con->isUMLDatatype())
{
packageMap.insert(con, con->package());
diff --git a/umbrello/codegenerators/d/dwriter.cpp b/umbrello/codegenerators/d/dwriter.cpp
index dba830e..816252c 100644
--- a/umbrello/codegenerators/d/dwriter.cpp
+++ b/umbrello/codegenerators/d/dwriter.cpp
@@ -83,7 +83,7 @@ void DWriter::writeModuleImports(UMLClassifier *c, QTextStream &d)
UMLPackageList imports;
findObjectsRelated(c, imports);
foreach (UMLPackage* con, imports) {
- if (con->baseType() == UMLObject::ot_Datatype)
+ if (con->isUMLDatatype())
continue;
QString pkg = con->package();
if (!pkg.isEmpty() && pkg != c->package())
diff --git a/umbrello/codegenerators/idl/idlwriter.cpp b/umbrello/codegenerators/idl/idlwriter.cpp
index 7e9e031..70be37c 100644
--- a/umbrello/codegenerators/idl/idlwriter.cpp
+++ b/umbrello/codegenerators/idl/idlwriter.cpp
@@ -149,7 +149,7 @@ void IDLWriter::writeClass(UMLClassifier *c)
findObjectsRelated(c, includes);
if (includes.count()) {
foreach (UMLPackage* conc, includes) {
- if (conc->baseType() == UMLObject::ot_Datatype)
+ if (conc->isUMLDatatype())
continue;
QString incName = findFileName(conc, QLatin1String(".idl"));
if (!incName.isEmpty())
diff --git a/umbrello/codegenerators/java/javaclassifiercodedocument.cpp b/umbrello/codegenerators/java/javaclassifiercodedocument.cpp
index 27a168c..b28d294 100644
--- a/umbrello/codegenerators/java/javaclassifiercodedocument.cpp
+++ b/umbrello/codegenerators/java/javaclassifiercodedocument.cpp
@@ -344,7 +344,7 @@ void JavaClassifierCodeDocument::updateContent()
// NO (default) datatypes in the import statement.. use defined
// ones whould be possible, but no idea how to do that...at least for now.
// Dynamic casting is slow..not an optimal way to do this.
- if (!packageMap.contains(con) && con->baseType() != UMLObject::ot_Datatype)
+ if (!packageMap.contains(con) && !con->isUMLDatatype())
{
packageMap.insert(con, con->package());
diff --git a/umbrello/codegenerators/java/javawriter.cpp b/umbrello/codegenerators/java/javawriter.cpp
index 901da84..2e07891 100644
--- a/umbrello/codegenerators/java/javawriter.cpp
+++ b/umbrello/codegenerators/java/javawriter.cpp
@@ -164,7 +164,7 @@ void JavaWriter::writeClass(UMLClassifier *c)
UMLPackageList imports;
findObjectsRelated(c, imports);
foreach (UMLPackage* con, imports) {
- if (con->baseType() == UMLObject::ot_Datatype)
+ if (con->isUMLDatatype())
continue;
QString pkg = con->package();
if (!pkg.isEmpty() && pkg != c->package())
diff --git a/umbrello/codegenerators/pascal/pascalwriter.cpp b/umbrello/codegenerators/pascal/pascalwriter.cpp
index ad65481..f9089e6 100644
--- a/umbrello/codegenerators/pascal/pascalwriter.cpp
+++ b/umbrello/codegenerators/pascal/pascalwriter.cpp
@@ -186,7 +186,7 @@ void PascalWriter::writeClass(UMLClassifier *c)
pas << "uses" << m_endl;
bool first = true;
foreach (UMLPackage* con, imports) {
- if (con->baseType() != UMLObject::ot_Datatype) {
+ if (!con->isUMLDatatype()) {
if (first)
first = false;
else
diff --git a/umbrello/codegenerators/perl/perlwriter.cpp b/umbrello/codegenerators/perl/perlwriter.cpp
index 4815c7d..6d70364 100644
--- a/umbrello/codegenerators/perl/perlwriter.cpp
+++ b/umbrello/codegenerators/perl/perlwriter.cpp
@@ -290,7 +290,7 @@ bool PerlWriter::GetUseStatements(UMLClassifier *c, QString &Ret,
QString SV = QChar(QLatin1Char('$'));
QString HV = QChar(QLatin1Char('%'));
foreach (UMLPackage* conc, includes) {
- if (conc->baseType() == UMLObject::ot_Datatype)
+ if (conc->isUMLDatatype())
continue;
QString neatName = cleanName(conc->name());
if (neatName != AV && neatName != SV && neatName != HV) {
diff --git a/umbrello/codeimport/import_utils.cpp b/umbrello/codeimport/import_utils.cpp
index 1a6b28b..e28832d 100644
--- a/umbrello/codeimport/import_utils.cpp
+++ b/umbrello/codeimport/import_utils.cpp
@@ -16,6 +16,7 @@
#include "artifact.h"
#include "attribute.h"
#include "classifier.h"
+#include "datatype.h"
#include "debug_utils.h"
#include "folder.h"
#include "enum.h"
@@ -275,9 +276,9 @@ UMLObject *createUMLObject(UMLObject::ObjectType type,
o = Object_Factory::createUMLObject(UMLObject::ot_Datatype, name,
umldoc->datatypeFolder(),
false); //solicitNewName
- UMLClassifier *dt = o->asUMLClassifier();
+ UMLDatatype *dt = o ? o->asUMLDatatype() : NULL;
UMLClassifier *c = origType->asUMLClassifier();
- if (c)
+ if (dt && c)
dt->setOriginType(c);
else
uError() << "createUMLObject(" << name << "): "
@@ -328,7 +329,7 @@ UMLObject *createUMLObject(UMLObject::ObjectType type,
QStringList::ConstIterator end(params.end());
for (QStringList::ConstIterator it(params.begin()); it != end; ++it) {
UMLObject *p = umldoc->findUMLObject(*it, UMLObject::ot_UMLObject, parentPkg);
- if (p == NULL || p->baseType() == UMLObject::ot_Datatype)
+ if (p == NULL || p->isUMLDatatype())
continue;
const Uml::AssociationType::Enum at = Uml::AssociationType::Dependency;
UMLAssociation *assoc = umldoc->findAssociation(at, gRelatedClassifier, p);
diff --git a/umbrello/codeimport/kdevcppparser/cpptree2uml.cpp b/umbrello/codeimport/kdevcppparser/cpptree2uml.cpp
index 6a2a3be..446af76 100644
--- a/umbrello/codeimport/kdevcppparser/cpptree2uml.cpp
+++ b/umbrello/codeimport/kdevcppparser/cpptree2uml.cpp
@@ -17,6 +17,7 @@
#include "uml.h"
#include "umldoc.h"
#include "umllistview.h"
+#include "datatype.h"
#include "operation.h"
#include "debug_utils.h"
#include "ast_utils.h"
@@ -168,7 +169,7 @@ void CppTree2Uml::parseTypedef(TypedefAST* ast)
UMLObject *typedefObj =
Import_Utils::createUMLObject(UMLObject::ot_Datatype, id,
m_currentNamespace[m_nsCnt]);
- UMLClassifier *dt = typedefObj->asUMLClassifier();
+ UMLDatatype *dt = typedefObj->asUMLDatatype();
dt->setIsReference();
dt->setOriginType(inner->asUMLClassifier());
} else {
diff --git a/umbrello/dialogs/pages/classgeneralpage.cpp b/umbrello/dialogs/pages/classgeneralpage.cpp
index 097a53f..8ec7acf 100644
--- a/umbrello/dialogs/pages/classgeneralpage.cpp
+++ b/umbrello/dialogs/pages/classgeneralpage.cpp
@@ -16,6 +16,7 @@
#include "documentationwidget.h"
#include "dialog_utils.h"
#include "classifier.h"
+#include "datatype.h"
#include "umlobject.h"
#include "objectwidget.h"
#include "uml.h"
@@ -101,13 +102,15 @@ ClassGeneralPage::ClassGeneralPage(UMLDoc* d, QWidget* parent, UMLObject* o)
}
int row = 2;
- UMLClassifier *c = m_pObject->asUMLClassifier();
- if (c && c->isReference() && c->originType()) {
- QLabel *label = new QLabel(i18n("Reference:"), this);
- m_pNameLayout->addWidget(label, row, 0);
- QLabel *reference = new QLabel(c->originType()->name(), this);
- m_pNameLayout->addWidget(reference, row, 1);
- ++row;
+ if (m_pObject->isUMLDatatype()) {
+ UMLDatatype *d = m_pObject->asUMLDatatype();
+ if (d && d->isReference() && d->originType()) {
+ QLabel *label = new QLabel(i18n("Reference:"), this);
+ m_pNameLayout->addWidget(label, row, 0);
+ QLabel *reference = new QLabel(d->originType()->name(), this);
+ m_pNameLayout->addWidget(reference, row, 1);
+ ++row;
+ }
}
if (t == UMLObject::ot_Class || t == UMLObject::ot_Interface || t == UMLObject::ot_Enum) {
diff --git a/umbrello/object_factory.cpp b/umbrello/object_factory.cpp
index 62a50cf..173063d 100644
--- a/umbrello/object_factory.cpp
+++ b/umbrello/object_factory.cpp
@@ -22,6 +22,7 @@
#include "cmds.h"
#include "codegenerator.h"
#include "component.h"
+#include "datatype.h"
#include "debug_utils.h"
#include "enum.h"
#include "entity.h"
@@ -135,8 +136,7 @@ UMLObject* createNewUMLObject(UMLObject::ObjectType type, const QString &name,
break;
}
case UMLObject::ot_Datatype: {
- UMLClassifier *c = new UMLClassifier(name, g_predefinedId);
- c->setBaseType(UMLObject::ot_Datatype);
+ UMLDatatype *c = new UMLDatatype(name, g_predefinedId);
o = c;
break;
}
@@ -401,8 +401,7 @@ UMLObject* makeObjectFromXMI(const QString& xmiTag,
|| UMLDoc::tagEq(xmiTag, QLatin1String("Datatype")) // for bkwd compat.
|| UMLDoc::tagEq(xmiTag, QLatin1String("Primitive"))
|| UMLDoc::tagEq(xmiTag, QLatin1String("PrimitiveType"))) {
- UMLClassifier *c = new UMLClassifier();
- c->setBaseType(UMLObject::ot_Datatype);
+ UMLDatatype *c = new UMLDatatype();
pObject = c;
} else if (UMLDoc::tagEq(xmiTag, QLatin1String("Enumeration")) ||
UMLDoc::tagEq(xmiTag, QLatin1String("Enum"))) { // for bkwd compat.
diff --git a/umbrello/umldoc.cpp b/umbrello/umldoc.cpp
index 2049455..91540b7 100644
--- a/umbrello/umldoc.cpp
+++ b/umbrello/umldoc.cpp
@@ -2888,7 +2888,7 @@ UMLClassifierList UMLDoc::datatypes()
UMLClassifierList datatypeList;
foreach (UMLObject *obj, objects) {
uIgnoreZeroPointer(obj);
- if (obj->baseType() == UMLObject::ot_Datatype) {
+ if (obj->isUMLDatatype()) {
datatypeList.append(obj->asUMLClassifier());
}
}
diff --git a/umbrello/umlmodel/classifier.cpp b/umbrello/umlmodel/classifier.cpp
index 8ec2c7c..9464b53 100644
--- a/umbrello/umlmodel/classifier.cpp
+++ b/umbrello/umlmodel/classifier.cpp
@@ -64,7 +64,6 @@ UMLClassifier::UMLClassifier(const QString & name, Uml::ID::Type id)
{
m_BaseType = UMLObject::ot_Class; // default value
m_pClassAssoc = NULL;
- m_isRef = false;
}
/**
@@ -120,14 +119,6 @@ bool UMLClassifier::isInterface() const
}
/**
- * Returns true if this classifier represents a datatype.
- */
-bool UMLClassifier::isDatatype() const
-{
- return (m_BaseType == ot_Datatype);
-}
-
-/**
* Checks whether an operation is valid based on its signature -
* An operation is "valid" if the operation's name and parameter list
* are unique in the classifier.
@@ -1260,42 +1251,6 @@ int UMLClassifier::takeItem(UMLClassifierListItem *item)
}
/**
- * Set the origin type (in case of e.g. typedef)
- * @param origType the origin type to set
- */
-void UMLClassifier::setOriginType(UMLClassifier *origType)
-{
- m_pSecondary = origType;
-}
-
-/**
- * Get the origin type (in case of e.g. typedef)
- * @return the origin type
- */
-UMLClassifier * UMLClassifier::originType() const
-{
- return m_pSecondary->asUMLClassifier();
-}
-
-/**
- * Set the m_isRef flag (true when dealing with a pointer type)
- * @param isRef the flag to set
- */
-void UMLClassifier::setIsReference(bool isRef)
-{
- m_isRef = isRef;
-}
-
-/**
- * Get the m_isRef flag.
- * @return true if is reference, otherwise false
- */
-bool UMLClassifier::isReference() const
-{
- return m_isRef;
-}
-
-/**
* Return true if this classifier has associations.
* @return true if classifier has associations
*/
@@ -1415,9 +1370,6 @@ void UMLClassifier::saveToXMI(QDomDocument & qDoc, QDomElement & qElement)
case UMLObject::ot_Interface:
tag = QLatin1String("UML:Interface");
break;
- case UMLObject::ot_Datatype:
- tag = QLatin1String("UML:DataType");
- break;
case UMLObject::ot_Package:
UMLPackage::saveToXMI(qDoc, qElement);
return;
@@ -1427,9 +1379,6 @@ void UMLClassifier::saveToXMI(QDomDocument & qDoc, QDomElement & qElement)
return;
}
QDomElement classifierElement = UMLObject::save(tag, qDoc);
- if (m_BaseType == UMLObject::ot_Datatype && m_pSecondary != NULL)
- classifierElement.setAttribute(QLatin1String("elementReference"),
- Uml::ID::toString(m_pSecondary->id()));
//save templates
UMLClassifierListItemList list = getFilteredList(UMLObject::ot_Template);
@@ -1514,18 +1463,13 @@ UMLClassifierListItem* UMLClassifier::makeChildObject(const QString& xmiTag)
/**
* Auxiliary to loadFromXMI:
* The loading of operations is implemented here.
- * Calls loadSpecialized() for any other tag.
- * Child classes can override the loadSpecialized method
+ * Calls loadFromXMI() for any other tag.
+ * Child classes can override the loadFromXMI() method
* to load its additional tags.
*/
bool UMLClassifier::load(QDomElement& element)
{
UMLClassifierListItem *child = NULL;
- m_SecondaryId = element.attribute(QLatin1String("elementReference"));
- if (!m_SecondaryId.isEmpty()) {
- // @todo We do not currently support composition.
- m_isRef = true;
- }
bool totalSuccess = true;
for (QDomNode node = element.firstChild(); !node.isNull();
node = node.nextSibling()) {
diff --git a/umbrello/umlmodel/classifier.h b/umbrello/umlmodel/classifier.h
index 1f0f7d6..d6a6026 100644
--- a/umbrello/umlmodel/classifier.h
+++ b/umbrello/umlmodel/classifier.h
@@ -132,14 +132,6 @@ public:
bool isInterface() const;
- bool isDatatype() const;
-
- void setOriginType(UMLClassifier *origType);
- UMLClassifier * originType() const;
-
- void setIsReference(bool isRef = true);
- bool isReference() const;
-
bool hasAbstractOps();
bool hasAssociations();
bool hasAttributes();
@@ -178,8 +170,6 @@ private:
UMLAssociation *m_pClassAssoc;
- bool m_isRef;
-
/**
* Utility method called by "get*ChildClassfierList()" methods. It basically
* finds all the classifiers named in each association in the given association list
diff --git a/umbrello/umlmodel/datatype.cpp b/umbrello/umlmodel/datatype.cpp
new file mode 100644
index 0000000..5eb6054
--- /dev/null
+++ b/umbrello/umlmodel/datatype.cpp
@@ -0,0 +1,101 @@
+/***************************************************************************
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2016 *
+ * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
+ ***************************************************************************/
+
+// own header
+#include "datatype.h"
+
+/**
+ * Sets up a Datatype.
+ * @param name The name of the Datatype.
+ * @param id The unique id of the Concept.
+ */
+UMLDatatype::UMLDatatype(const QString & name, Uml::ID::Type id)
+ : UMLClassifier(name, id),
+ m_isRef(false)
+{
+ m_BaseType = UMLObject::ot_Datatype;
+}
+
+/**
+ * Destructor.
+ */
+UMLDatatype::~UMLDatatype()
+{
+}
+
+/**
+ * Set the origin type (in case of e.g. typedef)
+ * @param origType the origin type to set
+ */
+void UMLDatatype::setOriginType(UMLClassifier *origType)
+{
+ m_pSecondary = origType;
+}
+
+/**
+ * Get the origin type (in case of e.g. typedef)
+ * @return the origin type
+ */
+UMLClassifier * UMLDatatype::originType() const
+{
+ return m_pSecondary->asUMLClassifier();
+}
+
+/**
+ * Set the m_isRef flag (true when dealing with a pointer type)
+ * @param isRef the flag to set
+ */
+void UMLDatatype::setIsReference(bool isRef)
+{
+ m_isRef = isRef;
+}
+
+/**
+ * Get the m_isRef flag.
+ * @return true if is reference, otherwise false
+ */
+bool UMLDatatype::isReference() const
+{
+ return m_isRef;
+}
+
+/**
+ * Loads object from QDomElement.
+ *
+ * @param qElement A QDomElement which contains xml info for this object.
+ */
+bool UMLDatatype::loadFromXMI(QDomElement & element)
+{
+ if (!UMLObject::loadFromXMI(element))
+ return false;
+
+ m_SecondaryId = element.attribute(QLatin1String("elementReference"));
+ if (!m_SecondaryId.isEmpty()) {
+ // @todo We do not currently support composition.
+ m_isRef = true;
+ }
+ return true;
+}
+
+/**
+ * Creates the UML:Datatype element.
+ *
+ * @param qDoc the xml document
+ * @param qElement the xml element
+ */
+void UMLDatatype::saveToXMI(QDomDocument & qDoc, QDomElement & qElement)
+{
+ QDomElement classifierElement = UMLObject::save(QLatin1String("UML:DataType"), qDoc);
+
+ if (m_pSecondary != NULL)
+ classifierElement.setAttribute(QLatin1String("elementReference"),
+ Uml::ID::toString(m_pSecondary->id()));
+ qElement.appendChild(classifierElement);
+}
diff --git a/umbrello/umlmodel/datatype.h b/umbrello/umlmodel/datatype.h
new file mode 100644
index 0000000..e70d736
--- /dev/null
+++ b/umbrello/umlmodel/datatype.h
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * copyright (C) 2003-2016 *
+ * Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
+ ***************************************************************************/
+
+#ifndef DATATYPE_H
+#define DATATYPE_H
+
+#include "classifier.h"
+
+/**
+ * This class contains the non-graphical information required for a UML Datatype.
+ * This class inherits from @ref UMLClassifier which contains most
+ * of the information.
+ *
+ * @short Non-graphical information for a Datatype.
+ * @see UMLClassifier
+ * Bugs and comments to umbrello-devel@kde.org or http://bugs.kde.org
+ */
+class UMLDatatype : public UMLClassifier
+{
+ Q_OBJECT
+public:
+ UMLDatatype(const QString &name=QString(), Uml::ID::Type id=Uml::ID::None);
+ virtual ~UMLDatatype();
+
+ void setOriginType(UMLClassifier *origType);
+ UMLClassifier * originType() const;
+
+ void setIsReference(bool isRef = true);
+ bool isReference() const;
+
+ virtual bool loadFromXMI(QDomElement & element);
+ virtual void saveToXMI(QDomDocument & qDoc, QDomElement & qElement);
+
+protected:
+ bool m_isRef;
+};
+
+#endif
diff --git a/umbrello/umlmodel/umlobject.cpp b/umbrello/umlmodel/umlobject.cpp
index 8148b21..2c76224 100644
--- a/umbrello/umlmodel/umlobject.cpp
+++ b/umbrello/umlmodel/umlobject.cpp
@@ -1208,6 +1208,7 @@ QDebug operator<<(QDebug out, const UMLObject& obj)
#include "checkconstraint.h"
#include "classifier.h"
#include "component.h"
+#include "datatype.h"
#include "entity.h"
#include "entityattribute.h"
#include "entityconstraint.h"
@@ -1235,6 +1236,7 @@ UMLCheckConstraint* UMLObject::asUMLCheckConstraint() { return dynamic_cast<UMLC
UMLClassifier* UMLObject::asUMLClassifier() { return dynamic_cast<UMLClassifier*>(this); }
UMLClassifierListItem *UMLObject::asUMLClassifierListItem() { return dynamic_cast<UMLClassifierListItem*>(this); }
UMLComponent* UMLObject::asUMLComponent() { return dynamic_cast<UMLComponent*>(this); }
+UMLDatatype *UMLObject::asUMLDatatype() { return dynamic_cast<UMLDatatype*>(this); }
UMLEntity* UMLObject::asUMLEntity() { return dynamic_cast<UMLEntity*>(this); }
UMLEntityAttribute* UMLObject::asUMLEntityAttribute() { return dynamic_cast<UMLEntityAttribute*>(this); }
UMLEntityConstraint* UMLObject::asUMLEntityConstraint() { return dynamic_cast<UMLEntityConstraint*>(this); }
diff --git a/umbrello/umlmodel/umlobject.h b/umbrello/umlmodel/umlobject.h
index d12d252..4b8a5c3 100644
--- a/umbrello/umlmodel/umlobject.h
+++ b/umbrello/umlmodel/umlobject.h
@@ -32,6 +32,7 @@ class UMLClassifier;
class UMLClassifierListItem;
class UMLClassifierSet;
class UMLComponent;
+class UMLDatatype;
class UMLEntity;
class UMLEntityAttribute;
class UMLEntityConstraint;
@@ -195,6 +196,7 @@ public:
bool isUMLCheckConstraint() { return baseType() == ot_CheckConstraint; }
bool isUMLClassifier() { return baseType() == ot_Class; }
bool isUMLComponent() { return baseType() == ot_Component; }
+ bool isUMLDatatype() { return baseType() == ot_Datatype; }
bool isUMLEntity() { return baseType() == ot_Entity; }
bool isUMLEntityAttribute() { return baseType() == ot_EntityAttribute; }
bool isUMLEntityConstraint() { return baseType() == ot_EntityConstraint; }
@@ -224,6 +226,7 @@ public:
UMLClassifierListItem* asUMLClassifierListItem();
UMLClassifierSet* asUMLClassifierSet();
UMLComponent* asUMLComponent();
+ UMLDatatype* asUMLDatatype();
UMLEntity* asUMLEntity();
UMLEntityAttribute* asUMLEntityAttribute();
UMLEntityConstraint* asUMLEntityConstraint();
diff --git a/umbrello/umlscene.cpp b/umbrello/umlscene.cpp
index 198e3d0..63b348e 100644
--- a/umbrello/umlscene.cpp
+++ b/umbrello/umlscene.cpp
@@ -25,6 +25,7 @@
#include "classoptionspage.h"
#include "cmds.h"
#include "componentwidget.h"
+#include "datatype.h"
#include "pinportbase.h"
#include "datatypewidget.h"
#include "debug_utils.h"
@@ -2406,13 +2407,13 @@ void UMLScene::createAutoAttributeAssociations(UMLWidget *widget)
if (tmpUmlObj == NULL)
return;
// if the underlying model object is really a UMLClassifier then
- if (tmpUmlObj->baseType() == UMLObject::ot_Datatype) {
- UMLClassifier *dt = tmpUmlObj->asUMLClassifier();
+ if (tmpUmlObj->isUMLDatatype()) {
+ UMLDatatype *dt = tmpUmlObj->asUMLDatatype();
while (dt->originType() != NULL) {
tmpUmlObj = dt->originType();
- if (tmpUmlObj->baseType() != UMLObject::ot_Datatype)
+ if (!tmpUmlObj->isUMLDatatype())
break;
- dt = tmpUmlObj->asUMLClassifier();
+ dt = tmpUmlObj->asUMLDatatype();
}
}
if (tmpUmlObj->baseType() != UMLObject::ot_Class)
@@ -2472,8 +2473,8 @@ void UMLScene::createAutoAttributeAssociation(UMLClassifier *type, UMLAttribute
}
}
// if the attribute type is a Datatype then
- if (type->baseType() == UMLObject::ot_Datatype) {
- UMLClassifier *dt = type->asUMLClassifier();
+ if (type->isUMLDatatype()) {
+ UMLDatatype *dt = type->asUMLDatatype();
// if the Datatype is a reference (pointer) type
if (dt->isReference()) {
//Uml::AssociationType::Enum assocType = Uml::AssociationType::Composition;