UmlClass * UmlClass::addMetaclass(WrapperStr mclname, const char * mclpath) { UmlPackage * pack = (UmlPackage *) parent()->parent(); // is a package const Q3PtrVector<UmlItem> ch = pack->children(); unsigned n = ch.size(); UmlClass * r = 0; for (unsigned i = 0; i != n; i += 1) { UmlItem * x = ch[i]; if ((x->kind() == aClassView) && !strncmp(x->name(), "meta classes", 12) && ((r = UmlClass::create(x, mclname)) != 0)) break; } if (r == 0) { WrapperStr s = "meta classes"; UmlItem * v = 0; while ((v = UmlClassView::create(pack, s)) == 0) s += "_"; r = UmlClass::create(v, mclname); } r->set_Stereotype("metaclass"); if (mclpath != 0) r->set_PropertyValue("metaclassPath", mclpath); return r; }
void UmlExtraClassMember::add_init(UmlClass * cl, WrapperStr def, bool roundtrip, QList<UmlItem *> & expected_order) { if (roundtrip) { const QVector<UmlItem*> & ch = cl->children(); UmlItem *const* v = ch.data(); UmlItem *const* vsup = v + ch.size(); UmlItem * x; for (; v != vsup; v += 1) { if (((x = *v)->kind() == anExtraClassMember) && ((UmlExtraClassMember *) x)->is_useless() && (x->name() == "initialization")) { expected_order.append(x); if (neq(((UmlExtraClassMember *) x)->javaDecl(), def)) { ((UmlExtraClassMember *) x)->set_JavaDecl(def); cl->get_class()->set_updated(); } ((UmlExtraClassMember *) x)->set_usefull(); return; } } } UmlExtraClassMember * x = UmlExtraClassMember::create(cl, "initialization"); x->set_JavaDecl(def); expected_order.append(x); }
void UmlClass::import(QTextOStream & f, const QCString & indent) { QCString s; if (!isJavaExternal()) { UmlArtifact * cp = associatedArtifact(); UmlPackage * pack = (UmlPackage *) ((cp != 0) ? (UmlItem *) cp : (UmlItem *) this)->package(); if ((s = pack->javaPackage()).isEmpty()) return; QCString s2 = name(); UmlItem * p = this; while ((p = p->parent())->kind() == aClass) s2 = p->name() + dot + s2; s += dot + s2; } else if ((s = package()->javaPackage()).isEmpty()) return; else s += dot + name(); if (! UmlArtifact::generated_one()->is_imported(s)) { f << indent << "import " << s << ";\n"; UmlArtifact::generated_one()->imported(s); } }
UmlItem * UmlClass::search_for_att_rel(const WrapperStr & name) { const QVector<UmlItem*> & ch = UmlItem::children(); QVectorIterator<UmlItem*> it(ch); while(it.hasNext()) { UmlItem* item = it.next(); switch (item->kind()) { case anAttribute: if (item->name() == name) return item; break; case aRelation: if (((UmlRelation *) item)->roleName() == name) return item; break; default: break; } } return 0; }
void Package::update_class_list(WrapperStr pack, UmlItem * container) { const Q3PtrVector<UmlItem> & ch = container->children(); for (unsigned i = 0; i != ch.size(); i += 1) { UmlItem * it = ch[i]; switch (it->kind()) { case aClass: user_classes.replace(pack + it->name(), (UmlClass *) it); update_class_list(pack + it->name() + ".", (UmlClass *) it); break; case aClassView: update_class_list(pack, it); default: break; } } }
UmlExtraClassMember * UmlClass::search_for_extra(const WrapperStr & name, const WrapperStr & decl) { const QVector<UmlItem*> & ch = UmlItem::children(); QVectorIterator<UmlItem*> it(ch); while(it.hasNext()) { UmlItem* item = it.next(); if ((item->kind() == anExtraClassMember) && (item->name() == name) && !neq(((UmlExtraClassMember *) item)->cppDecl(), decl)) return (UmlExtraClassMember *) item; } return 0; }
void UmlClass::write(QTextOStream & f) { if (isJavaExternal()) { QCString s = javaDecl().stripWhiteSpace(); int index; if ((index = s.find("${name}")) != -1) s.replace(index, 7, name()); else if ((index = s.find("${Name}")) != -1) s.replace(index, 7, capitalize(name())); else if ((index = s.find("${NAME}")) != -1) s.replace(index, 7, name().upper()); else if ((index = s.find("${nAME}")) != -1) s.replace(index, 7, name().lower()); f << s; } else { UmlClass * toplevel = this; UmlItem * p; QCString s2; while ((p = toplevel->parent())->kind() == aClass) { toplevel = (UmlClass *) p; s2 = dot + p->name() + s2; } UmlArtifact * cp = toplevel->associatedArtifact(); UmlPackage * pack = (UmlPackage *) ((cp != 0) ? (UmlItem *) cp : (UmlItem *) toplevel)->package(); if (pack != UmlArtifact::generation_package()) { QCString s = pack->javaPackage(); if (! s.isEmpty() && (s != "java.lang") && (s.left(10) != "java.lang.")) { s += s2; if (JavaSettings::isForcePackagePrefixGeneration() || !UmlArtifact::generated_one()->is_imported(s, name())) f << s << '.'; } } else if (! s2.isEmpty()) f << s2.mid(1) << '.'; f << name(); } }
void UmlArtifact::solveManifestation(WrapperStr s, WrapperStr idref) { QMap<WrapperStr, UmlItem *>::Iterator it = All.find(idref); if (it == All.end()) { if (!FileIn::isBypassedId(idref)) UmlCom::trace("manifestation : unknown utilized element reference '" + idref + "'<br>"); return; } UmlItem * target = *it; if (!FromBouml || (s != "dependency")) { switch (target->kind()) { case aClass: if (s != "source") break; else if (stereotype().isEmpty()) set_Stereotype("source"); else if (stereotype() != "source") break; addAssociatedClass((UmlClass *) target); return; case anArtifact: if (!FromBouml) break; addAssociatedArtifact((UmlArtifact *) target); return; default: break; } } UmlNcRelation * rel = UmlNcRelation::create(aDependency, this, target); if (rel == 0) UmlCom::trace("cannot create manifestation from '" + name() + "' to '" + target->name() + "'"); else rel->set_Stereotype("manifest"); }
void UmlPackage::subArtifacts(QList<UmlArtifact *> &l, QByteArray name, QByteArray deplview_name) { UmlDeploymentView * deplview; foreach (deplview, _deplviews){ if (deplview->baseName() == deplview_name) { const QVector<UmlItem*> ch = deplview->children(); int i; for (i = 0; i != ch.size(); i += 1) { UmlItem * it = ch[i]; if ((it->kind() == anArtifact) && (it->name() == name)) l.append((UmlArtifact *) it); } } } }
void UmlItem::solveGeneralizationDependencyRealization(int context, WrapperStr idref, WrapperStr label, WrapperStr) { QMap<QString, UmlItem *>::Iterator it = All.find(idref); if (it != All.end()) { static const struct { aRelationKind rk; const char * err; } r[] = { { aGeneralisation, "cannot create generalization from '" }, { aDependency, "cannot create dependency from '" }, { aRealization, "cannot create realization from '" }, { aDependency, "cannot create usage from '" }, { aDependency, "cannot create import from '" } }; UmlItem * target = *it; UmlItem * rel = UmlNcRelation::create(r[context].rk, this, target); if (rel == 0) UmlCom::trace(r[context].err + name() + "' to '" + target->name() + "'<br>"); else { if (! label.isEmpty()) rel->set_Name(label); switch (context) { case 3: rel->set_Stereotype("use"); break; case 4: rel->set_Stereotype("import"); break; default: break; } } } else if (!FileIn::isBypassedId(idref)) UmlCom::trace("relation : unknown target reference '" + idref + "'<br>"); }
UmlPackage * Package::get_uml(bool mandatory) { if (uml == 0) { const char * name = text(0); Package * pa = (Package *) parent(); UmlPackage * uml_pa = pa->get_uml(); // will end on project Q3PtrVector<UmlItem> ch = uml_pa->children(); for (unsigned index = 0; index != ch.size(); index += 1) { UmlItem * it = ch[index]; if ((it->kind() == aPackage) && (it->name() == name)) return uml = (UmlPackage *) it; } if ((uml = UmlBasePackage::create(uml_pa, name)) == 0) { if (!mandatory) return 0; #ifdef REVERSE UmlCom::trace(WrapperStr("<font face=helvetica><b>cannot create package <i>") + name + "</i> under package <i>" + uml_pa->name() + "</b></font><br>"); UmlCom::message(""); throw 0; #else QMessageBox::critical(0, "Fatal Error", QString("<font face=helvetica><b>cannot create package <i>") + name + "</i> under package <i>" + ((const char *) uml_pa->name()) + "</b></font><br>"); QApplication::exit(1); #endif } } return uml; }
Class::Class(Package * p, const char * n, char st) : BrowserNode(p, n), uml(0), stereotype(st), abstractp(FALSE), reversedp(FALSE), #ifdef REVERSE from_lib(FALSE) #else description_updatedp(FALSE) #endif { p->new_class(this); } UmlClass * Class::get_uml() { if (uml != 0) return uml; UmlItem * p = // no nested classe in php (UmlItem *)((Package *) parent())->get_uml()->get_classview(get_namespace()); WrapperStr str = WrapperStr(text(0).toLatin1().constData()); uml = UmlBaseClass::create(p, str); if (uml == 0) { // probably already exist QVector<UmlItem*> ch = p->children(); UmlItem * x; for (int chindex = 0; chindex != ch.size(); chindex += 1) { if (((x = ch[chindex])->kind() == aClass) && (x->name() == str)) { uml = (UmlClass *) x; break; } } if (uml == 0) { #ifdef REVERSE UmlCom::message(""); UmlCom::trace(QString(QString("<font face=helvetica><b>cannot create class <i>") + text(0) + "</i> under <i>" + parent()->text(0) + "</b></font><br>").toLatin1().constData()); throw 0; #else QMessageBox::critical(0, "Fatal Error", QString("<font face=helvetica><b>cannot create class <i>") + text(0) + "</i> under <i>" + parent()->text(0) + "</b></font><br>"); QApplication::exit(1); #endif } } switch (stereotype) { case 'i': uml->set_Stereotype("interface"); uml->set_PhpDecl(PhpSettings::interfaceDecl()); break; default: // class break; } if (abstractp) uml->set_isAbstract(TRUE); return uml; } bool Class::already_in_bouml() { QVector<UmlItem*> ch = get_uml()->children(); for (int index = 0; index != ch.size(); index += 1) if (ch[index]->kind() != aClass) return TRUE; return FALSE; }