UmlArtifact * UmlClass::artifact() { // note : class is not nested UmlArtifact * art = associatedArtifact(); if (art == 0) { UmlDeploymentView * depl = ((UmlClassView *) parent())->deploymentView(); art = UmlArtifact::create(depl, name()); if (art == 0) { UmlCom::trace("<b>cannot create artifact '" + name() + "' in deployment view '" + depl->name() + "'</b><br>"); throw 0; } art->set_Stereotype("source"); art->addAssociatedClass(this); } return art; }
void UmlClass::need_artifact(const WrapperStr & nmsp) { if (parent()->kind() == aClassView) { UmlArtifact * cp; if ((cp = associatedArtifact()) == 0) { // search artifact #ifdef ROUNDTRIP if ((cp = Package::get_artifact()) != 0) { cp->addAssociatedClass(this); return; } #endif WrapperStr name = Package::get_fname(); int index; if (name.isEmpty()) { // defined in a source rather than a header // will create it own artifact name = this->name(); index = name.find('<'); if (index != -1) name = name.left(index); } UmlDeploymentView * cpv = ((UmlPackage *) parent()->parent())->get_deploymentview(nmsp); const QVector<UmlItem*> & children = cpv->children(); int n = (int) children.count(); for (index = 0; index != n; index += 1) { if ((children[index]->name() == name) && (children[index]->kind() == anArtifact)) { cp = (UmlArtifact *) children[index]; break; } } if (cp == 0) { // does not exist, create associated artifact if ((cp = UmlBaseArtifact::create(cpv, name)) == 0) { #ifdef REVERSE UmlCom::trace(WrapperStr("<font face=helvetica><b>cannot create artifact <i>") + Lex::quote(name) + "</i> under <i>" + Lex::quote(cpv->name()) + "</b></font><br>"); UmlCom::message(""); throw 0; #else QMessageBox::critical(0, "Fatal Error", WrapperStr("<font face=helvetica><b>cannot create artifact <i>") + Lex::quote(name) + "</i> under <i>" + Lex::quote(cpv->Name()) + "</b></font><br>"); QApplication::exit(1); #endif } cp->set_Stereotype("source"); cp->set_CppHeader(CppSettings::headerContent()); } cp->addAssociatedClass(this); } // source needed ? if (need_source() && cp->cppSource().isEmpty()) cp->set_CppSource(CppSettings::sourceContent()); } }