summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2016-09-09 09:16:56 (GMT)
committerRalf Habacker <ralf.habacker@freenet.de>2016-09-09 09:18:30 (GMT)
commit3e9f089d6f90085d3e312f3a06d780d9d1c026ff (patch)
tree86fde0c520a53161e0a464aa32447bfee596c3ab
parent120af5d34c2424c2eb4dd631aea925edb227fded (diff)
Complete migration of dynamic_cast to UMLObject::asUML...() wrapper.
CCBUG:368282
-rw-r--r--umbrello/clipboard/umlclipboard.cpp2
-rw-r--r--umbrello/codegenerators/ada/adawriter.cpp2
-rw-r--r--umbrello/codegenerators/classifiercodedocument.cpp4
-rw-r--r--umbrello/codegenerators/codeclassfield.cpp2
-rw-r--r--umbrello/codegenerators/cpp/cppwriter.cpp4
-rw-r--r--umbrello/codegenerators/d/dcodeclassfielddeclarationblock.cpp2
-rw-r--r--umbrello/codegenerators/java/javacodeclassfielddeclarationblock.cpp2
-rw-r--r--umbrello/codegenerators/pascal/pascalwriter.cpp2
-rw-r--r--umbrello/codegenerators/ruby/rubycodeclassfielddeclarationblock.cpp4
-rw-r--r--umbrello/codegenerators/xml/xmlschemawriter.cpp4
-rw-r--r--umbrello/dialogs/umlattributedialog.cpp4
-rw-r--r--umbrello/dialogs/umlentityattributedialog.cpp4
-rw-r--r--umbrello/dialogs/umlenumliteraldialog.cpp2
-rw-r--r--umbrello/dialogs/umltemplatedialog.cpp2
-rw-r--r--umbrello/umllistview.cpp6
-rw-r--r--umbrello/umlmodel/classifier.cpp6
-rw-r--r--umbrello/umlmodel/umlcanvasobject.cpp4
-rw-r--r--umbrello/umlmodel/umlobject.cpp4
-rw-r--r--umbrello/umlscene.cpp2
-rw-r--r--umbrello/umlwidgets/messagewidget.cpp4
20 files changed, 33 insertions, 33 deletions
diff --git a/umbrello/clipboard/umlclipboard.cpp b/umbrello/clipboard/umlclipboard.cpp
index 9dafe14..58ddc85 100644
--- a/umbrello/clipboard/umlclipboard.cpp
+++ b/umbrello/clipboard/umlclipboard.cpp
@@ -605,7 +605,7 @@ bool UMLClipboard::pasteClip5(const QMimeData* data)
if (!lvitem || !Model_Utils::typeIsClassifier(lvitem->type())) {
return false;
}
- UMLClassifier *parent = dynamic_cast<UMLClassifier*>(lvitem->umlObject());
+ UMLClassifier *parent = lvitem->umlObject()->asUMLClassifier();
if (parent == NULL) {
uError() << "parent is not a UMLClassifier";
diff --git a/umbrello/codegenerators/ada/adawriter.cpp b/umbrello/codegenerators/ada/adawriter.cpp
index 8b981cf..ae3d163 100644
--- a/umbrello/codegenerators/ada/adawriter.cpp
+++ b/umbrello/codegenerators/ada/adawriter.cpp
@@ -145,7 +145,7 @@ void AdaWriter::computeAssocTypeAndRole(UMLClassifier *c,
UMLAssociation *a,
QString& typeName, QString& roleName)
{
- UMLClassifier* assocEnd = dynamic_cast<UMLClassifier*>(a->getObject(Uml::RoleType::B));
+ UMLClassifier* assocEnd = a->getObject(Uml::RoleType::B)->asUMLClassifier();
if (assocEnd == NULL)
return;
const Uml::AssociationType::Enum assocType = a->getAssocType();
diff --git a/umbrello/codegenerators/classifiercodedocument.cpp b/umbrello/codegenerators/classifiercodedocument.cpp
index 28ee42d..59da834 100644
--- a/umbrello/codegenerators/classifiercodedocument.cpp
+++ b/umbrello/codegenerators/classifiercodedocument.cpp
@@ -129,7 +129,7 @@ bool ClassifierCodeDocument::hasObjectVectorClassFields()
{
if((*it)->getClassFieldType() != CodeClassField::Attribute)
{
- UMLRole * role = dynamic_cast<UMLRole*>((*it)->getParentObject());
+ UMLRole * role = (*it)->getParentObject()->asUMLRole();
if (!role) {
uError() << "invalid parent object type";
return false;
@@ -659,7 +659,7 @@ ClassifierCodeDocument::findCodeClassFieldFromParentID (Uml::ID::Type id,
return cf;
} else { // association(role)-based
const Uml::RoleType::Enum r = Uml::RoleType::fromInt(role_id);
- UMLRole * role = dynamic_cast<UMLRole *>(cf->getParentObject());
+ UMLRole * role = cf->getParentObject()->asUMLRole();
if(role && Uml::ID::fromString(cf->ID()) == id && role->role() == r)
return cf;
}
diff --git a/umbrello/codegenerators/codeclassfield.cpp b/umbrello/codegenerators/codeclassfield.cpp
index 48a2a8f..8594d78 100644
--- a/umbrello/codegenerators/codeclassfield.cpp
+++ b/umbrello/codegenerators/codeclassfield.cpp
@@ -442,7 +442,7 @@ CodeAccessorMethod * CodeClassField::findMethodByType (CodeAccessorMethod::Acces
// design.
Q_FOREACH(CodeAccessorMethod *m, m_methodVector)
{
- UMLRole * role = dynamic_cast<UMLRole*>(m->getParentObject());
+ UMLRole * role = m->getParentObject()->asUMLRole();
if(!role)
uError()<<" FindMethodByType() cant create role for method type:"<<m->getType()<<endl;
if(role && m->getType() == type && role->role() == role_id)
diff --git a/umbrello/codegenerators/cpp/cppwriter.cpp b/umbrello/codegenerators/cpp/cppwriter.cpp
index d65cc89..2da9531 100644
--- a/umbrello/codegenerators/cpp/cppwriter.cpp
+++ b/umbrello/codegenerators/cpp/cppwriter.cpp
@@ -1239,9 +1239,9 @@ void CppWriter::printAssociationIncludeDecl(UMLAssociationList list, Uml::ID::Ty
// only use OTHER classes (e.g. we don't need to write includes for ourselves!!
// AND only IF the roleName is defined, otherwise, it is not meant to be noticed.
if (a->getObjectId(Uml::RoleType::A) == myId && !a->getRoleName(Uml::RoleType::B).isEmpty()) {
- current = dynamic_cast<UMLClassifier*>(a->getObject(Uml::RoleType::B));
+ current = a->getObject(Uml::RoleType::B)->asUMLClassifier();
} else if (a->getObjectId(Uml::RoleType::B) == myId && !a->getRoleName(Uml::RoleType::A).isEmpty()) {
- current = dynamic_cast<UMLClassifier*>(a->getObject(Uml::RoleType::A));
+ current = a->getObject(Uml::RoleType::A)->asUMLClassifier();
isFirstClass = false;
}
diff --git a/umbrello/codegenerators/d/dcodeclassfielddeclarationblock.cpp b/umbrello/codegenerators/d/dcodeclassfielddeclarationblock.cpp
index 9f5d7c1..3091c23 100644
--- a/umbrello/codegenerators/d/dcodeclassfielddeclarationblock.cpp
+++ b/umbrello/codegenerators/d/dcodeclassfielddeclarationblock.cpp
@@ -90,7 +90,7 @@ void DCodeClassFieldDeclarationBlock::updateContent()
body.append(QLatin1String(" = ") + initialV);
else if (!cf->parentIsAttribute())
{
- UMLRole * role = dynamic_cast<UMLRole*>(cf->getParentObject());
+ UMLRole * role = cf->getParentObject()->asUMLRole();
// Check for dynamic casting failure!
if (role == NULL)
diff --git a/umbrello/codegenerators/java/javacodeclassfielddeclarationblock.cpp b/umbrello/codegenerators/java/javacodeclassfielddeclarationblock.cpp
index 892d6b5..74e334f 100644
--- a/umbrello/codegenerators/java/javacodeclassfielddeclarationblock.cpp
+++ b/umbrello/codegenerators/java/javacodeclassfielddeclarationblock.cpp
@@ -89,7 +89,7 @@ void JavaCodeClassFieldDeclarationBlock::updateContent()
body.append(QLatin1String(" = ") + initialV);
else if (!cf->parentIsAttribute())
{
- UMLRole * role = dynamic_cast<UMLRole*>(cf->getParentObject());
+ UMLRole * role = cf->getParentObject()->asUMLRole();
// Check for dynamic casting failure
if (role == NULL)
diff --git a/umbrello/codegenerators/pascal/pascalwriter.cpp b/umbrello/codegenerators/pascal/pascalwriter.cpp
index 08be6ef..ad65481 100644
--- a/umbrello/codegenerators/pascal/pascalwriter.cpp
+++ b/umbrello/codegenerators/pascal/pascalwriter.cpp
@@ -127,7 +127,7 @@ void PascalWriter::computeAssocTypeAndRole
roleName.append(QLatin1String("_Vector"));
}
}
- UMLClassifier* c = dynamic_cast<UMLClassifier*>(a->getObject(Uml::RoleType::A));
+ UMLClassifier* c = a->getObject(Uml::RoleType::A)->asUMLClassifier();
if (c == NULL)
return;
typeName = cleanName(c->name());
diff --git a/umbrello/codegenerators/ruby/rubycodeclassfielddeclarationblock.cpp b/umbrello/codegenerators/ruby/rubycodeclassfielddeclarationblock.cpp
index f03f24a..5606cf1 100644
--- a/umbrello/codegenerators/ruby/rubycodeclassfielddeclarationblock.cpp
+++ b/umbrello/codegenerators/ruby/rubycodeclassfielddeclarationblock.cpp
@@ -82,8 +82,8 @@ void RubyCodeClassFieldDeclarationBlock::updateContent()
body.append(QLatin1String(" = ") + initialV);
else if (!cf->parentIsAttribute())
{
- UMLRole * role = dynamic_cast<UMLRole*>(cf->getParentObject());
- if (role->object()->baseType() == UMLObject::ot_Interface)
+ UMLRole * role = cf->getParentObject()->asUMLRole();
+ if (role && role->object()->baseType() == UMLObject::ot_Interface)
{
// do nothing.. can't instantiate an interface
} else {
diff --git a/umbrello/codegenerators/xml/xmlschemawriter.cpp b/umbrello/codegenerators/xml/xmlschemawriter.cpp
index 44a8a26..fd511d0 100644
--- a/umbrello/codegenerators/xml/xmlschemawriter.cpp
+++ b/umbrello/codegenerators/xml/xmlschemawriter.cpp
@@ -623,7 +623,7 @@ bool XMLSchemaWriter::writeAssociationDecls(UMLAssociationList associations,
// between different classes are to be treated
if (printRoleB)
{
- UMLClassifier *classifierB = dynamic_cast<UMLClassifier*>(a->getObjectB());
+ UMLClassifier *classifierB = a->getObjectB()->asUMLClassifier();;
if (classifierB) {
// ONLY write out IF there is a rolename given
// otherwise it is not meant to be declared
@@ -636,7 +636,7 @@ bool XMLSchemaWriter::writeAssociationDecls(UMLAssociationList associations,
// print RoleA decl
if (printRoleA)
{
- UMLClassifier *classifierA = dynamic_cast<UMLClassifier*>(a->getObject(Uml::RoleType::A));
+ UMLClassifier *classifierA = a->getObject(Uml::RoleType::A)->asUMLClassifier();
if (classifierA) {
// ONLY write out IF there is a rolename given
// otherwise it is not meant to be declared
diff --git a/umbrello/dialogs/umlattributedialog.cpp b/umbrello/dialogs/umlattributedialog.cpp
index fea3432..366e5bc 100644
--- a/umbrello/dialogs/umlattributedialog.cpp
+++ b/umbrello/dialogs/umlattributedialog.cpp
@@ -118,8 +118,8 @@ bool UMLAttributeDialog::apply()
m_pNameLE->setText(m_pAttribute->name());
return false;
}
- UMLClassifier * pConcept = dynamic_cast<UMLClassifier *>(m_pAttribute->parent());
- UMLObject *o = pConcept->findChildObject(name);
+ UMLClassifier * pConcept = m_pAttribute->umlParent()->asUMLClassifier();
+ UMLObject *o = pConcept ? pConcept->findChildObject(name) : 0;
if (o && o != m_pAttribute) {
KMessageBox::error(this, i18n("The attribute name you have chosen is already being used in this operation."),
i18n("Attribute Name Not Unique"), 0);
diff --git a/umbrello/dialogs/umlentityattributedialog.cpp b/umbrello/dialogs/umlentityattributedialog.cpp
index 0923c68..c75802a 100644
--- a/umbrello/dialogs/umlentityattributedialog.cpp
+++ b/umbrello/dialogs/umlentityattributedialog.cpp
@@ -172,8 +172,8 @@ bool UMLEntityAttributeDialog::apply()
m_pNameLE->setText(m_pEntityAttribute->name());
return false;
}
- UMLClassifier * pConcept = dynamic_cast<UMLClassifier *>(m_pEntityAttribute->parent());
- UMLObject *o = pConcept->findChildObject(name);
+ UMLClassifier * pConcept = m_pEntityAttribute->umlParent()->asUMLClassifier();
+ UMLObject *o = pConcept ? pConcept->findChildObject(name) : 0;
if (o && o != m_pEntityAttribute) {
KMessageBox::error(this, i18n("The entity attribute name you have chosen is already being used in this operation."),
i18n("Entity Attribute Name Not Unique"), 0);
diff --git a/umbrello/dialogs/umlenumliteraldialog.cpp b/umbrello/dialogs/umlenumliteraldialog.cpp
index 4b37e18..55740e0 100644
--- a/umbrello/dialogs/umlenumliteraldialog.cpp
+++ b/umbrello/dialogs/umlenumliteraldialog.cpp
@@ -89,7 +89,7 @@ bool UMLEnumLiteralDialog::apply()
m_pNameLE->setText(m_pEnumLiteral->name());
return false;
}
- UMLClassifier * pConcept = dynamic_cast<UMLClassifier *>(m_pEnumLiteral->parent());
+ UMLClassifier * pConcept = m_pEnumLiteral->umlParent()->asUMLClassifier();
if (!pConcept) {
uError() << "Could not get parent of enum literal '" << m_pEnumLiteral->name() << "'";
return false;
diff --git a/umbrello/dialogs/umltemplatedialog.cpp b/umbrello/dialogs/umltemplatedialog.cpp
index 7665737..d98b944 100644
--- a/umbrello/dialogs/umltemplatedialog.cpp
+++ b/umbrello/dialogs/umltemplatedialog.cpp
@@ -96,7 +96,7 @@ bool UMLTemplateDialog::apply()
return false;
}
- UMLClassifier * pClass = dynamic_cast<UMLClassifier *>(m_pTemplate->parent());
+ UMLClassifier * pClass = m_pTemplate->umlParent()->asUMLClassifier();
if (pClass) {
UMLObject *o = pClass->findChildObject(name);
if (o && o != m_pTemplate) {
diff --git a/umbrello/umllistview.cpp b/umbrello/umllistview.cpp
index 33621a8..57011b7 100644
--- a/umbrello/umllistview.cpp
+++ b/umbrello/umllistview.cpp
@@ -522,7 +522,7 @@ void UMLListView::slotMenuSelection(QAction* action, const QPoint &position)
case ListPopupMenu::mt_Externalize_Folder:
{
UMLListViewItem *current = static_cast<UMLListViewItem*>(currentItem());
- UMLFolder *modelFolder = dynamic_cast<UMLFolder*>(current->umlObject());
+ UMLFolder *modelFolder = current->umlObject()->asUMLFolder();
if (modelFolder == 0) {
uError() << "modelFolder is 0";
return;
@@ -1639,7 +1639,7 @@ UMLListViewItem * UMLListView::moveObject(Uml::ID::Type srcId, UMLListViewItem::
}
else if (Model_Utils::typeIsDiagram(srcType)) {
UMLView *v = m_doc->findView(srcId);
- UMLFolder *newParentObj = dynamic_cast<UMLFolder*>(newParent->umlObject());
+ UMLFolder *newParentObj = newParent->umlObject()->asUMLFolder();
if (v) {
UMLFolder *srcPkg = v->umlScene()->folder();
if (srcPkg) {
@@ -2214,7 +2214,7 @@ void UMLListView::addNewItem(UMLListViewItem *parentItem, UMLListViewItem::ListV
// creation was cancelled by the user
return;
}
- UMLFolder* parent = dynamic_cast<UMLFolder*>(parentItem->umlObject());
+ UMLFolder* parent = parentItem->umlObject()->asUMLFolder();
UMLApp::app()->executeCommand(new Uml::CmdCreateDiagram(m_doc, diagramType, diagramName, parent));
return;
}
diff --git a/umbrello/umlmodel/classifier.cpp b/umbrello/umlmodel/classifier.cpp
index 2b7342d..8ec2c7c 100644
--- a/umbrello/umlmodel/classifier.cpp
+++ b/umbrello/umlmodel/classifier.cpp
@@ -203,7 +203,7 @@ UMLOperation* UMLClassifier::findOperation(const QString& name,
int i = 0;
for (; i < pCount; ++i) {
Model_Utils::NameAndType_ListIt nt(params.begin() + i);
- UMLClassifier *type = dynamic_cast<UMLClassifier*>((*nt).m_type);
+ UMLClassifier *type = (*nt).m_type->asUMLClassifier();
UMLClassifier *testType = testParams.at(i)->getType();
if (type == NULL && testType == NULL) { //no parameter type
continue;
@@ -1616,11 +1616,11 @@ UMLClassifierList UMLClassifier::findAssocClassifierObjsInRoles (UMLAssociationL
// We also ignore classifiers which are the same as the current one
// (e.g. id matches), we only want the "other" classifiers
if (a->getObjectId(RoleType::A) == id() && !a->getRoleName(RoleType::B).isEmpty()) {
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(a->getObject(RoleType::B));
+ UMLClassifier *c = a->getObject(RoleType::B)->asUMLClassifier();
if(c)
classifiers.append(c);
} else if (a->getObjectId(RoleType::B) == id() && !a->getRoleName(RoleType::A).isEmpty()) {
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(a->getObject(RoleType::A));
+ UMLClassifier *c = a->getObject(RoleType::A)->asUMLClassifier();
if(c)
classifiers.append(c);
}
diff --git a/umbrello/umlmodel/umlcanvasobject.cpp b/umbrello/umlmodel/umlcanvasobject.cpp
index 87f9997..5c67118 100644
--- a/umbrello/umlmodel/umlcanvasobject.cpp
+++ b/umbrello/umlmodel/umlcanvasobject.cpp
@@ -368,7 +368,7 @@ UMLClassifierList UMLCanvasObject::getSuperClasses(bool withRealizations)
(!withRealizations && a->getAssocType() == Uml::AssociationType::Realization) ||
a->getObjectId(Uml::RoleType::A) != id())
continue;
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(a->getObject(Uml::RoleType::B));
+ UMLClassifier *c = a->getObject(Uml::RoleType::B)->asUMLClassifier();
if (c)
list.append(c);
else
@@ -395,7 +395,7 @@ UMLClassifierList UMLCanvasObject::getSubClasses()
a->getAssocType() != Uml::AssociationType::Realization) ||
a->getObjectId(Uml::RoleType::B) != id())
continue;
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(a->getObject(Uml::RoleType::A));
+ UMLClassifier *c = a->getObject(Uml::RoleType::A)->asUMLClassifier();
if (c)
list.append(c);
else
diff --git a/umbrello/umlmodel/umlobject.cpp b/umbrello/umlmodel/umlobject.cpp
index 8ce07b4..4492fb2 100644
--- a/umbrello/umlmodel/umlobject.cpp
+++ b/umbrello/umlmodel/umlobject.cpp
@@ -112,7 +112,7 @@ UMLObject::~UMLObject()
// unref stereotype
setUMLStereotype(0);
if (m_pSecondary && m_pSecondary->baseType() == ot_Stereotype) {
- UMLStereotype* stereotype = dynamic_cast<UMLStereotype*>(m_pSecondary.data());
+ UMLStereotype* stereotype = m_pSecondary->asUMLStereotype();
if (stereotype)
stereotype->decrRefCount();
}
@@ -753,7 +753,7 @@ bool UMLObject::resolveRef()
if (m_pSecondary->baseType() == ot_Stereotype) {
if (m_pStereotype)
m_pStereotype->decrRefCount();
- m_pStereotype = dynamic_cast<UMLStereotype*>(m_pSecondary.data());
+ m_pStereotype = m_pSecondary->asUMLStereotype();
m_pStereotype->incrRefCount();
m_pSecondary = NULL;
}
diff --git a/umbrello/umlscene.cpp b/umbrello/umlscene.cpp
index 0295abe..e0d72e1 100644
--- a/umbrello/umlscene.cpp
+++ b/umbrello/umlscene.cpp
@@ -1488,7 +1488,7 @@ bool UMLScene::isSavedInSeparateFile()
const UMLListViewItem::ListViewType lvt = parentItem->type();
if (! Model_Utils::typeIsFolder(lvt))
return false;
- UMLFolder *modelFolder = dynamic_cast<UMLFolder*>(parentItem->umlObject());
+ UMLFolder *modelFolder = parentItem->umlObject()->asUMLFolder();
if (modelFolder == NULL) {
uError() << msgPrefix
<< "parent model object is not a UMLFolder (?)";
diff --git a/umbrello/umlwidgets/messagewidget.cpp b/umbrello/umlwidgets/messagewidget.cpp
index fb103d8..c2ae205 100644
--- a/umbrello/umlwidgets/messagewidget.cpp
+++ b/umbrello/umlwidgets/messagewidget.cpp
@@ -812,11 +812,11 @@ bool MessageWidget::activate(IDChangeLog * /*Log = 0*/)
}
updateResizability();
- UMLClassifier *c = dynamic_cast<UMLClassifier*>(m_pOw[Uml::RoleType::B]->umlObject());
+ UMLClassifier *c = m_pOw[Uml::RoleType::B]->umlObject()->asUMLClassifier();
UMLOperation *op = NULL;
if (c && !m_CustomOp.isEmpty()) {
Uml::ID::Type opId = Uml::ID::fromString(m_CustomOp);
- op = dynamic_cast<UMLOperation*>(c->findChildObjectById(opId, true));
+ op = c->findChildObjectById(opId, true)->asUMLOperation();
if (op) {
// If the UMLOperation is set, m_CustomOp isn't used anyway.
// Just setting it empty for the sake of sanity.