Commit 3e9f089d authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Complete migration of dynamic_cast to UMLObject::asUML...() wrapper.

CCBUG:368282
parent 120af5d3
......@@ -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";
......
......@@ -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();
......
......@@ -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;
}
......
......@@ -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)
......
......@@ -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;
}
......
......@@ -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)
......
......@@ -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)
......
......@@ -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());
......
......@@ -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 {
......
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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
......
......@@ -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;
}
......
......@@ -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 (?)";
......
......@@ -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.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment