void UmlRelation::write_extension(FileOut & out) { if ((side(TRUE) == this) && (parent()->stereotype() == "stereotype") && (roleType()->stereotype() == "metaclass")) { const char * k = (_uml_20) ? "ownedMember" : "packagedElement"; out.indent(); out << "<" << k << " xmi:type=\"uml:Extension\" name=\"A_"; out.quote((const char*)roleType()->name());//[jasa] ambiguous call out << '_'; out.quote((const char*)parent()->name());//[jasa] ambiguous call out << '"'; out.id_prefix(this, "EXT_"); out.ref(this, "memberEnd", "BASE_"); out << ">\n"; out.indent(); out << "\t<ownedEnd xmi:type=\"uml:ExtensionEnd\" name=\"extension_"; out.quote((const char*)parent()->name());//[jasa] ambiguous call out << '"'; out.id_prefix(this, "EXTEND_"); out.ref(this, "type"); out << " aggregation=\"composite\"/>\n"; out.indent(); out << "</" << k << ">\n"; } unload(); }
void UmlRelation::compute_dependency(Q3PtrList<CppRefType> & dependencies, const Q3CString & cl_stereotype, bool all_in_h) { if (cl_stereotype == "enum") return; switch (relationKind()) { case aDependency: if (stereotype() == "friend") break; CppRefType::add(roleType(), dependencies, cppDecl() != "#include in source", roleType()->isCppExternal()); break; case aGeneralisation: case aRealization: CppRefType::add(roleType(), dependencies, TRUE); break; default: Q3CString decl = cppDecl(); int index; if ((index = decl.find("${static}")) != -1) decl.remove((unsigned) index, 9); if ((index = decl.find("${mutable}")) != -1) decl.remove((unsigned) index, 10); if ((index = decl.find("${volatile}")) != -1) decl.remove((unsigned) index, 11); if ((index = decl.find("${const}")) != -1) decl.remove((unsigned) index, 8); if ((index = decl.find("${multiplicity}")) != -1) decl.remove((unsigned) index, 15); if ((index = decl.find("${name}")) != -1) decl.remove((unsigned) index, 7); if ((index = decl.find("${inverse_name}")) != -1) decl.remove((unsigned) index, 15); if ((index = decl.find("${value}")) != -1) decl.remove((unsigned) index, 8); if ((index = decl.find("${h_value}")) != -1) decl.remove((unsigned) index, 10); if ((index = decl.find("${stereotype}")) != -1) decl.replace((unsigned) index, 13, CppSettings::relationAttributeStereotype(stereotype())); if ((index = decl.find("${association}")) != -1) { decl.replace((unsigned) index, 14, association().toString()); } replace_alias(decl); UmlTypeSpec type; type.type = roleType(); UmlClassMember::compute_dependency(dependencies, decl, type, all_in_h); } }
void UmlRelation::uml2cpp(bool) { bool composition = FALSE; switch (relationKind()) { case aGeneralisation: case aRealization: set_CppDecl("${type}"); break; case aDependency: if (stereotype() == "friend") set_CppDecl("friend " + CppSettings::classStereotype(roleType()->stereotype()) + " ${type};"); else set_CppDecl("#include in source"); break; case anAggregationByValue: case aDirectionalAggregationByValue: composition = TRUE; // no break default: { Q3CString st = CppSettings::classStereotype(parent()->stereotype()); set_CppDecl(((st == "enum") || (st == "typedef") || (st == "ignored")) ? Q3CString("") : CppSettings::relationDecl(composition, multiplicity())); } } }
void UmlRelation::write_realization(FileOut & out) { const char * k = (_uml_20) ? "ownedElement" : "packagedElement"; out.indent(); out << '<' << k << " xmi:type=\"uml:Realization\""; out.id(this); out.ref(parent(), "client"); out.ref(roleType(), "supplier"); out.ref(roleType(), "realizingClassifier"); out << ">\n"; out.indent(+1); write_constraint(out); write_description_properties(out); out.indent(-1); out.indent(); out << "</" << k << ">\n"; }
void UmlRelation::generate_implements(const char *& sep, QTextOStream & f, const Q3ValueList<UmlActualParameter> & actuals, const Q3CString & cl_stereotype) { switch (relationKind()) { default: return; case aGeneralisation: case aRealization: if (javaDecl().isEmpty()) return; UmlClass * role_type = roleType(); const Q3CString & other_stereotype = role_type->java_stereotype(); if ((other_stereotype == "interface") || (other_stereotype == "@interface")) { if ((cl_stereotype == "union") || (cl_stereotype == "enum_pattern")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>an <i>") + cl_stereotype + "</i> cannot inherits</b></font><br>"); incr_warning(); } else { f << sep; sep = ", "; const char * p = javaDecl(); while (*p) { if (!strncmp(p, "${type}", 7)) { role_type->write(f); p += 7; if (!actuals.isEmpty()) { Q3ValueList<UmlActualParameter>::ConstIterator ita; bool used = FALSE; for (ita = actuals.begin(); ita != actuals.end(); ++ita) { if ((*ita).superClass() == role_type) { used = TRUE; (*ita).generate(f); } } if (used) { f << ">"; } } } else if (*p == '@') manage_alias(p, f); else f << *p++; } } } } }
SurfaceRole& SurfaceRes::role(std::unique_ptr<SurfaceRole> role) { if(!role) { ny::sendWarning("SurfaceRes::role: nullptr as parameter not allowed"); return *role; //aargh } if(roleType() == surfaceRoleType::none) { roleType_ = role->roleType(); } else if(roleType() != role->roleType()) { ny::sendWarning("SurfaceRes::role: surface already has a different role"); return *role_; } role_ = std::move(role); return *role_; }
void UmlRelation::write(FileOut & out, bool inside) { switch (relationKind()) { case aGeneralisation: if (inside) write_generalization(out); break; case aRealization: if (inside) parent()->memo_relation(this); else write_realization(out); break; case aDependency: if (inside) parent()->memo_relation(this); else write_dependency(out); break; default: // don't generate them for actors { UmlItem * p = parent(); if (p->stereotype() == "actor") return; do { p = p->parent(); } while (p->kind() == aClass); UmlItem * op = roleType(); if (op->stereotype() == "actor") return; do { op = op->parent(); } while (op->kind() == aClass); if ((p->kind() == aClassView) && (op->kind() == aClassView)) { if (inside) write_relation_as_attribute(out); else // note : it is the first side write_relation(out); } } break; } }
void UmlRelation::write_generalization(FileOut & out) { out.indent(); out << "<generalization xmi:type=\"uml:Generalization\""; out.id(this); out.ref(roleType(), "general"); if (!constraint().isEmpty()) { out << ">\n"; out.indent(+1); write_constraint(out); out.indent(-1); out.indent(); out << "</generalization>\n"; } else out << "/>\n"; }
void UmlRelation::gen_uml_decl() { if (isClassMember()) fw.write("static, "); write(visibility()); writeq(roleName()); fw.write(" : "); roleType()->write(); QByteArray s; s = defaultValue(); if (!s.isEmpty()) { if (s[0] != '=') fw.write(" = "); writeq(s); } s = multiplicity(); if (!s.isEmpty()) { fw.write(", multiplicity : "); writeq(s); } if (isDerived()) fw.write((isDerivedUnion()) ? ", derived union" : ", derived"); if (isReadOnly()) fw.write(", read only"); if (isOrdered()) fw.write(", ordered"); if (isUnique()) fw.write(", unique"); }
void UmlRelation::gen_python_decl(QByteArray s) { QByteArray st = PythonSettings::classStereotype(stereotype()); const char * p = bypass_comment(s); while (*p) { if (!strncmp(p, "${comment}", 10)) p += 10; else if (!strncmp(p, "${description}", 14)) p += 14; else if (!strncmp(p, "${name}", 7)) { p += 7; writeq(roleName()); } else if (!strncmp(p, "${value}", 8)) { p += 8; writeq((defaultValue().isEmpty()) ? "None" : defaultValue()); } else if (!strncmp(p, "${self}", 7)) { p += 7; if (!isClassMember()) fw.write("self."); } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(); } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; writeq(st); } else if (*p == '\r') p += 1; else if (*p == '@') manage_alias(p); else writeq(*p++); } }
void UmlRelation::generate_implements(const char *& sep, QTextStream & f, const Q3CString & cl_stereotype) { switch (relationKind()) { default: return; case aGeneralisation: case aRealization: if (phpDecl().isEmpty()) return; UmlClass * role_type = roleType(); const Q3CString & other_stereotype = role_type->php_stereotype(); if (other_stereotype == "interface") { if (cl_stereotype == "union") { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>an <i>") + cl_stereotype + "</i> cannot inherits</b></font><br>"); incr_warning(); } else { f << sep; sep = ", "; const char * p = phpDecl(); while (*p) { if (!strncmp(p, "${type}", 7)) { role_type->write(f); p += 7; } else if (*p == '@') manage_alias(p, f); else f << *p++; } } } } }
void UmlRelation::html(QByteArray, unsigned int, unsigned int) { bool extension; switch (relationKind()) { case aGeneralisation: case aRealization: case aDependency: return; case aDirectionalAssociation: extension = (parent()->stereotype() == "stereotype") && (roleType()->stereotype() == "metaclass"); break; default: extension = FALSE; } define(); if (extension) fw.write("<table><tr><td><div class=\"element\">Extension</div></td></tr></table>"); else { fw.write("<table><tr><td><div class=\"element\">Relation <b>"); writeq(name()); fw.write("</b></div></td></tr></table>"); } QByteArray s = description(); if (!s.isEmpty()) { fw.write("<p>"); if (! javaDecl().isEmpty()) gen_java_decl(s, TRUE); else if (! phpDecl().isEmpty()) gen_php_decl(s, TRUE); else if (! pythonDecl().isEmpty()) gen_python_decl(s); else gen_cpp_decl(s, TRUE); fw.write("<br /></p>"); } if (extension) { fw.write("<p>Extend "); roleType()->write(); fw.write("</p>"); } else { fw.write("<p>Declaration :</p><ul>"); fw.write("<li>Uml : "); gen_uml_decl(); fw.write("</li>"); s = cppDecl(); if (!s.isEmpty()) { fw.write("<li>C++ : "); gen_cpp_decl(s, FALSE); fw.write("</li>"); } s = javaDecl(); if (!s.isEmpty()) { fw.write("<li>Java : "); gen_java_decl(s, FALSE); fw.write("</li>"); } s = phpDecl(); if (!s.isEmpty()) { fw.write("<li>Php : "); gen_php_decl(s, FALSE); fw.write("</li>"); } s = pythonDecl(); if (!s.isEmpty()) { fw.write("<li>Python : "); gen_python_decl(s); fw.write("</li>"); } fw.write("</ul>"); } annotation_constraint(); write_properties(); unload(FALSE, FALSE); }
void UmlRelation::generate_import(QTextOStream & f, const Q3CString & indent) { if ((relationKind() == aDependency) && (stereotype() == "import")) roleType()->import(f, indent); }
void UmlRelation::generate(QTextOStream & f, const Q3CString & cl_stereotype, Q3CString indent) { switch (relationKind()) { case aDependency: case aGeneralisation: case aRealization: break; default: if (!javaDecl().isEmpty()) { if (cl_stereotype == "enum_pattern") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>an <i>enum_pattern</i> cannot have relation</b></font><br>"); incr_warning(); return; } const char * p = javaDecl(); const char * pp = 0; Q3CString s; while ((*p == ' ') || (*p == '\t')) indent += *p++; f << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; f << indent; } if (*p == '\n') { f << *p++; if (*p) f << indent; } else if (*p == '@') manage_alias(p, f); else if (*p != '$') f << *p++; else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, JavaSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${visibility}", 13)) { p += 13; generate_visibility(f, cl_stereotype); } else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) f << "static "; } else if (!strncmp(p, "${final}", 8)) { p += 8; if (isReadOnly()) f << "final "; } else if (!strncmp(p, "${transient}", 12)) { p += 12; if (isJavaTransient()) f << "transient "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f << "volatile "; } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f); } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f << JavaSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${name}", 7)) { p += 7; f << roleName(); } else if (!strncmp(p, "${inverse_name}", 15)) { p += 15; switch (relationKind()) { case anAssociation: case anAggregation: case anAggregationByValue: f << side(side(TRUE) != this)->roleName(); default: break; } } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; Q3CString m = multiplicity(); if (*m != '[') f << "[]"; else { for (unsigned index = 0; index != m.length(); index += 1) { switch (m.at(index)) { case '[': f << '['; break; case ']': f << ']'; default: break; } } } } else if (!strncmp(p, "${value}", 8)) { if (!defaultValue().isEmpty()) { if (need_equal(p, defaultValue())) f << " = "; f << defaultValue(); } p += 8; } else if (!strncmp(p, "${association}", 14)) { p += 14; UmlClass::write(f, association()); } else if (!strncmp(p, "${@}", 4)) { p += 4; if (pp != 0) f << "${@}"; else if (! javaAnnotations().isEmpty()) { pp =p; p = javaAnnotations(); } } else // strange f << *p++; } f << '\n'; } } }
void UmlRelation::generate(QTextStream & f, const Q3CString &, Q3CString indent, int &) { switch (relationKind()) { case aDependency: case aGeneralisation: case aRealization: break; default: if (!phpDecl().isEmpty()) { const char * p = phpDecl(); const char * pp = 0; Q3CString s; while ((*p == ' ') || (*p == '\t')) indent += *p++; f << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; f << indent; } if (*p == '\n') { f << *p++; if (*p) f << indent; } else if (*p == '@') manage_alias(p, f); else if (*p != '$') f << *p++; else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, PhpSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${visibility}", 13)) { p += 13; generate_visibility(f); } else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) f << "static "; } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f); } else if (!strncmp(p, "${name}", 7)) { p += 7; if (!isReadOnly()) f << "$"; f << roleName(); } else if (!strncmp(p, "${inverse_name}", 15)) { p += 15; switch (relationKind()) { case anAssociation: case anAggregation: case anAggregationByValue: { UmlRelation * inverse = side(side(TRUE) != this); if (!inverse->isReadOnly()) f << "$"; f << inverse->roleName(); } default: break; } } else if (!strncmp(p, "${var}", 6)) { p += 6; if (!isReadOnly() && !isClassMember() && (visibility() == PackageVisibility)) f << "var "; } else if (!strncmp(p, "${value}", 8)) { if (!defaultValue().isEmpty()) { if (need_equal(p, defaultValue())) f << " = "; f << defaultValue(); } p += 8; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f << "const "; } else f << *p++; } f << '\n'; } } }
void UmlRelation::generate_def(QTextStream & f, WrapperStr indent, bool h, WrapperStr templates, WrapperStr cl_names, WrapperStr, WrapperStr) { if (isClassMember() && !cppDecl().isEmpty()) { UmlClass * cl = (UmlClass *) parent(); if ((!templates.isEmpty() || (cl->name().find('<') != -1)) ? h : !h) { const char * p = cppDecl(); const char * pp = 0; while ((*p == ' ') || (*p == '\t')) p += 1; bool re_template = !templates.isEmpty() && insert_template(p, f, indent, templates); if (*p != '#') f << indent; const char * pname = name_spec(p); for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (re_template) f << templates; if (*p == 0) break; if (*p != '#') f << indent; } if (*p == '\n') { f << toLocale(p); if (*p && (*p != '#')) f << indent; } else if (*p == '@') manage_alias(p, f); else if (*p != '$') { if (p == pname) f << cl_names << "::"; f << toLocale(p); } else if (!strncmp(p, "${comment}", 10)) { if (!manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()) && re_template) f << templates; } else if (!strncmp(p, "${description}", 14)) { if (!manage_description(p, pp) && re_template) f << templates; } else if (!strncmp(p, "${static}", 9)) { p += 9; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f << "const "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f << "volatile "; } else if (!strncmp(p, "${mutable}", 10)) { p += 10; } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f); } else if (!strncmp(p, "${name}", 7)) { p += 7; if (*pname == '$') f << cl_names << "::"; f << roleName(); } else if (!strncmp(p, "${inverse_name}", 15)) { p += 15; switch (relationKind()) { case anAssociation: case anAggregation: case anAggregationByValue: f << side(side(TRUE) != this)->roleName(); default: break; } } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; const WrapperStr & m = multiplicity(); if (!m.isEmpty() && (*((const char *) m) == '[')) f << m; else f << '[' << m << ']'; } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f << CppSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${value}", 8)) { if (!defaultValue().isEmpty()) { if (need_equal(p, defaultValue())) f << " = "; f << defaultValue(); } p += 8; } else if (!strncmp(p, "${h_value}", 10)) p += 10; else if (!strncmp(p, "${association}", 14)) { p += 14; UmlClass::write(f, association()); } else // strange f << toLocale(p); } f << '\n'; } } }
void UmlRelation::gen_cpp_decl(QByteArray s, bool descr) { const char * p; if (! descr) { write((cppVisibility() == DefaultVisibility) ? visibility() : cppVisibility(), cppLanguage); fw.write(": "); p = bypass_comment(s); } else p = s; while (*p) { if (!strncmp(p, "${comment}", 10)) p += 10; else if (!strncmp(p, "${description}", 14)) p += 14; else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) fw.write("static "); } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) fw.write("const "); } else if (!strncmp(p, "${mutable}", 10)) { p += 10; if (isCppMutable()) fw.write("mutable "); } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) fw.write("volatile "); } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(); } else if (!strncmp(p, "${name}", 7)) { p += 7; writeq(roleName()); } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; QByteArray m = multiplicity(); if (m.isEmpty() || (((const char *) m)[0] != '[')) { fw.write("["); writeq(m); fw.write("]"); } else writeq(m); } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; writeq(CppSettings::relationAttributeStereotype(stereotype())); } else if (!strncmp(p, "${value}", 8) || !strncmp(p, "${h_value}", 10)) { break; } else if (!strncmp(p, "${association}", 14)) { p += 14; write(association(), cppLanguage); } else if (*p == '\r') p += 1; else if (*p == '\n') { if (descr) { fw.write("<br />"); p += 1; } else { fw.write(' '); do p += 1; while ((*p != 0) && (*p <= ' ')); } } else if (*p == ';') { if (descr) fw.write(*p++); else break; } else if (*p == '@') manage_alias(p); else writeq(*p++); } }
void UmlRelation::generate_inherit(const char *& sep, QTextStream & f_h, const Q3ValueList<UmlActualParameter> & actuals, const WrapperStr & cl_stereotype) { switch (relationKind()) { default: break; case aGeneralisation: case aRealization: if ((cl_stereotype == "union") || (cl_stereotype == "enum")) { write_trace_header(); UmlCom::trace(WrapperStr(" <font color=\"red\"><b>an <i>") + cl_stereotype + "</i> cannot inherits</b></font><br>"); incr_warning(); return; } else if (cl_stereotype == "typedef") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>a <i>typedef</i> cannot inherits</b></font><br>"); incr_warning(); return; } UmlClass * role_type = roleType(); const WrapperStr & other_stereotype = role_type->stereotype(); if ((other_stereotype == "union") || (other_stereotype == "enum")) { write_trace_header(); UmlCom::trace(WrapperStr(" <font color=\"red\"><b>cannot inherits an <i>") + other_stereotype + "</i></b></font><br>"); incr_warning(); return; } f_h << sep; sep = ", "; if (cppVirtualInheritance()) f_h << "virtual "; aVisibility visibility = (cppVisibility() == DefaultVisibility) ? this->visibility() : cppVisibility(); switch (visibility) { case PublicVisibility: case PackageVisibility: f_h << "public "; break; case ProtectedVisibility: f_h << "protected "; break; default: f_h << "private "; } const char * p = cppDecl(); while (*p) { if (!strncmp(p, "${type}", 7)) { role_type->write(f_h, FALSE, 0, actuals); p += 7; } else if (*p == '@') manage_alias(p, f_h); else f_h << toLocale(p); } } }
void UmlRelation::generate_extends(const char *& sep, QTextStream & f, const Q3CString & cl_stereotype) { switch (relationKind()) { default: return; case aGeneralisation: case aRealization: if (phpDecl().isEmpty()) return; UmlClass * role_type = roleType(); const Q3CString & other_stereotype = role_type->php_stereotype(); if ((cl_stereotype == "interface") || (cl_stereotype == "@interface")) { if ((other_stereotype != "interface") && (other_stereotype != "@interface")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>cannot extends a <i>") + other_stereotype + "</i></b></font><br>"); incr_warning(); return; } } else if ((other_stereotype != "interface") && (other_stereotype != "@interface")) { if (cl_stereotype == "union") { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>an <i>") + cl_stereotype + "</i> cannot extends</b></font><br>"); incr_warning(); return; } else if ((other_stereotype == "union") || (other_stereotype == "enum")) { write_trace_header(); UmlCom::trace(Q3CString(" <font color=\"red\"><b>cannot extends an <i>") + other_stereotype + "</i></b></font><br>"); incr_warning(); return; } else if (*sep == ',') { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>extend several classes</b></font><br>"); incr_warning(); return; } } else return; // here the code is legal f << sep; sep = ", "; const char * p = phpDecl(); while (*p) { if (!strncmp(p, "${type}", 7)) { role_type->write(f); p += 7; } else if (*p == '@') manage_alias(p, f); else f << *p++; } } }
void UmlRelation::generate_require_onces(QTextStream & f, Q3CString & made) { if (!phpDecl().isEmpty()) roleType()->generate_require_onces(f, made, ((UmlClass *) parent())->assocArtifact()); }
void UmlRelation::write_relation_as_attribute(FileOut & out) { UmlRelation * first = side(TRUE); Q3CString s; UmlClass * base; if ((first->parent()->stereotype() == "stereotype") && (first->roleType()->stereotype() == "metaclass")) { if (this != first) return; base = first->roleType(); s = "base_" + base->name(); } else { base = 0; switch (_lang) { case Uml: s = roleName(); break; case Cpp: if (cppDecl().isEmpty()) return; s = true_name(roleName(), cppDecl()); break; default: // Java if (javaDecl().isEmpty()) return; s = true_name(roleName(), javaDecl()); } } out.indent(); out << "<ownedAttribute xmi:type=\"uml:Property\" name=\"" << s << '"'; out.id(this); if (base != 0) out.ref(first, "association", "EXT_"); else { write_visibility(out); write_scope(out); if (isReadOnly()) out << " isReadOnly=\"true\""; if (isDerived()) { out << " isDerived=\"true\""; if (isDerivedUnion()) out << " isDerivedUnion=\"true\""; } if (isOrdered()) out << " isOrdered=\"true\""; if (isUnique()) out << " isUnique=\"true\""; if (first->_assoc_class != 0) out.ref(first->_assoc_class, "association"); else out.ref(first, "association", "ASSOC_"); out << " aggregation=\""; if (this == first) { parent()->memo_relation(this); if (_gen_eclipse) { switch (relationKind()) { case anAggregation: case aDirectionalAggregation: out << "shared"; break; case anAggregationByValue: case aDirectionalAggregationByValue: out << "composite"; break; default: out << "none"; } } else out << "none"; } else if (_gen_eclipse) out << "none"; else { switch (relationKind()) { case anAggregation: case aDirectionalAggregation: out << "shared"; break; case anAggregationByValue: case aDirectionalAggregationByValue: out << "composite"; break; default: out << "none"; } } out << '"'; } out << ">\n"; out.indent(+1); out.indent(); out << "<type xmi:type=\"uml:Class\""; if (base != 0) { if (! base->propertyValue("metaclassPath", s)) s = (_uml_20) ? "http://schema.omg.org/spec/UML/2.0/uml.xml" : "http://schema.omg.org/spec/UML/2.1/uml.xml"; out << " href=\"" << s << '#' << base->name() << '"'; } else out.idref(roleType()); out << "/>\n"; write_multiplicity(out, multiplicity(), this); write_default_value(out, defaultValue(), this); write_constraint(out); write_annotation(out); write_description_properties(out); out.indent(-1); out.indent(); out << "</ownedAttribute>\n"; unload(); }
void UmlRelation::gen_java_decl(QByteArray s, bool descr) { const char * p = bypass_comment(s); while (*p) { if (!strncmp(p, "${comment}", 10)) p += 10; else if (!strncmp(p, "${description}", 14)) p += 14; else if (!strncmp(p, "${visibility}", 13)) { p += 13; write(visibility(), javaLanguage); fw.write(' '); } else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) fw.write("static "); } else if (!strncmp(p, "${transient}", 12)) { p += 12; if (isJavaTransient()) fw.write("transient "); } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) fw.write("volatile "); } else if (!strncmp(p, "${final}", 8)) { p += 8; if (isReadOnly()) fw.write("final "); } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(); } else if (!strncmp(p, "${name}", 7)) { p += 7; writeq(roleName()); } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; QByteArray m = multiplicity(); if (! m.isEmpty()) { const char * s = m; if (*s != '[') fw.write("[]"); else { while (*s) { switch (*s++) { case '[': fw.write('['); break; case ']': fw.write(']'); default: break; } } } } } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; writeq(JavaSettings::relationAttributeStereotype(stereotype())); } else if (!strncmp(p, "${value}", 8)) { p += 8; } else if (!strncmp(p, "${association}", 14)) { p += 14; write(association(), javaLanguage); } else if (!strncmp(p, "${@}", 4)) p += 4; else if (*p == '\r') p += 1; else if (*p == '\n') { if (descr) { fw.write("<br />"); p += 1; } else { fw.write(' '); do p += 1; while ((*p != 0) && (*p <= ' ')); } } else if (*p == ';') { if (descr) fw.write(*p++); else break; } else if (*p == '@') manage_alias(p); else writeq(*p++); } }
void UmlRelation::generate_decl(QTextStream & f, const WrapperStr & cl_stereotype, WrapperStr indent, bool) { if ((relationKind() != aGeneralisation) && (relationKind() != aRealization) && (relationKind() != aDependency)) { if (cl_stereotype == "enum") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>an <i>enum</i> cannot have relation</b></font><br>"); incr_warning(); return; } if (cl_stereotype == "typedef") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>a <i>typedef</i> cannot have relation</b></font><br>"); incr_warning(); return; } if (!idlDecl().isEmpty()) { const char * p = idlDecl(); const char * pp = 0; WrapperStr s; while ((*p == ' ') || (*p == '\t')) indent += *p++; if (*p != '#') f << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; if (*p != '#') f << indent; } if (*p == '\n') { f << *p++; if (*p && (*p != '#')) f << indent; } else if (*p == '@') manage_alias(p, f); else if (*p != '$') f << *p++; else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${readonly}", 11)) { p += 11; if (isReadOnly()) f << "readonly "; } else if (!strncmp(p, "${attribut}", 11)) { // old version p += 11; if (cl_stereotype == "interface") f << "attribute "; } else if (!strncmp(p, "${attribute}", 12)) { p += 12; if (cl_stereotype == "interface") f << "attribute "; } else if (!strncmp(p, "${visibility}", 13)) { p += 13; if (cl_stereotype == "valuetype") { switch (visibility()) { case PublicVisibility: case PackageVisibility: f << "public "; break; default: f << "private "; } } } else if (!strncmp(p, "${case}", 7)) { p += 7; WrapperStr idl_case = idlCase(); if (idl_case.isEmpty()) { write_trace_header(); UmlCom::trace(WrapperStr(" <font color=\"red\"><b>unspecified <i>case</i> for <i>") + name() + "</b></font><br>"); incr_error(); } else f << idlCase(); } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f); } else if (!strncmp(p, "${name}", 7)) { p += 7; f << roleName(); } else if (!strncmp(p, "${inverse_name}", 15)) { p += 15; switch (relationKind()) { case anAssociation: case anAggregation: case anAggregationByValue: f << side(side(TRUE) != this)->roleName(); default: break; } } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f << IdlSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; f << multiplicity(); } else if (!strncmp(p, "${association}", 14)) { p += 14; f << IdlSettings::type(association().toString()); } else // strange f << *p++; } f << '\n'; } } }
void UmlRelation::generate_decl(aVisibility & current_visibility, QTextStream & f_h, const WrapperStr & cl_stereotype, WrapperStr indent, BooL & first, bool) { switch (relationKind()) { case aDependency: if (stereotype() == "friend") { Q3ValueList<UmlFormalParameter> formals = roleType()->formals(); if (! formals.isEmpty()) { const char * sep = " template <"; Q3ValueList<UmlFormalParameter>::ConstIterator it; for (it = formals.begin(); it != formals.end(); ++it) { f_h << sep << (*it).type() << ' ' << (*it).name(); sep = ", "; } f_h << "> "; } else f_h << " "; f_h << "friend " << roleType()->cpp_stereotype() << " "; roleType()->write(f_h, FALSE); f_h << ";\n"; first = FALSE; } break; case aGeneralisation: case aRealization: break; default: if (!cppDecl().isEmpty()) { if (cl_stereotype == "enum") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>an <i>enum</i> cannot have relation</b></font><br>"); incr_warning(); return; } if (cl_stereotype == "typedef") { write_trace_header(); UmlCom::trace(" <font color=\"red\"><b>a <i>typedef</i> cannot have relation</b></font><br>"); incr_warning(); return; } generate_visibility(current_visibility, f_h, first, indent); first = FALSE; const char * p = cppDecl(); const char * pp = 0; WrapperStr s; while ((*p == ' ') || (*p == '\t')) indent += toLocale(p); if (*p != '#') f_h << indent; for (;;) { if (*p == 0) { if (pp == 0) break; // comment management done p = pp; pp = 0; if (*p == 0) break; if (*p != '#') f_h << indent; } if (*p == '\n') { f_h << toLocale(p); if (*p && (*p != '#')) f_h << indent; } else if (*p == '@') manage_alias(p, f_h); else if (*p != '$') f_h << toLocale(p); else if (!strncmp(p, "${comment}", 10)) manage_comment(p, pp, CppSettings::isGenerateJavadocStyleComment()); else if (!strncmp(p, "${description}", 14)) manage_description(p, pp); else if (!strncmp(p, "${static}", 9)) { p += 9; if (isClassMember()) f_h << "static "; } else if (!strncmp(p, "${const}", 8)) { p += 8; if (isReadOnly()) f_h << "const "; } else if (!strncmp(p, "${volatile}", 11)) { p += 11; if (isVolatile()) f_h << "volatile "; } else if (!strncmp(p, "${mutable}", 10)) { p += 10; if (isCppMutable()) f_h << "mutable "; } else if (!strncmp(p, "${type}", 7)) { p += 7; roleType()->write(f_h); } else if (!strncmp(p, "${name}", 7)) { p += 7; f_h << roleName(); } else if (!strncmp(p, "${inverse_name}", 15)) { p += 15; switch (relationKind()) { case anAssociation: case anAggregation: case anAggregationByValue: f_h << side(side(TRUE) != this)->roleName(); default: break; } } else if (!strncmp(p, "${multiplicity}", 15)) { p += 15; const WrapperStr & m = multiplicity(); if (!m.isEmpty() && (*((const char *) m) == '[')) f_h << m; else f_h << '[' << m << ']'; } else if (!strncmp(p, "${stereotype}", 13)) { p += 13; f_h << CppSettings::relationAttributeStereotype(stereotype()); } else if (!strncmp(p, "${value}", 8)) p += 8; else if (!strncmp(p, "${h_value}", 10)) { if (!defaultValue().isEmpty() && isClassMember()) { if (need_equal(p, defaultValue())) f_h << " = "; f_h << defaultValue(); } p += 10; } else if (!strncmp(p, "${association}", 14)) { p += 14; UmlClass::write(f_h, association()); } else // strange f_h << toLocale(p); } f_h << '\n'; } } }
void UmlRelation::generate_inherit(const char *& sep, QTextStream & f, const WrapperStr & cl_stereotype, BooL & already) { if ((relationKind() == aGeneralisation) || (relationKind() == aRealization)) { UmlClass * role_type = roleType(); WrapperStr other_stereotype = role_type->idl_stereotype(); if (other_stereotype == "ignored") return; if ((cl_stereotype == "union") || (cl_stereotype == "enum")) { write_trace_header(); UmlCom::trace(WrapperStr(" <font color=\"red\"><b>an <i>") + cl_stereotype + "</i> cannot inherits</b></font><br>"); incr_warning(); return; } if ((other_stereotype == "union") || (other_stereotype == "struct") || (other_stereotype == "enum") || (other_stereotype == "typedef")) { write_trace_header(); UmlCom::trace(WrapperStr(" <font color=\"red\"><b>cannot inherits an <i>") + other_stereotype + "</i></b></font><br>"); incr_warning(); return; } if (cl_stereotype == "valuetype") { if (other_stereotype == "valuetype") { if (isIdlTruncatableInheritance()) f << sep << "truncatable "; else f << sep; } else { // other_stereotype == "interface" if (!already) { already = TRUE; f << " supports "; } else f << sep; } } else f << sep; const char * p = idlDecl(); while (*p) { if (!strncmp(p, "${type}", 7)) { role_type->write(f); p += 7; } else if (*p == '@') manage_alias(p, f); else f << *p++; } sep = ", "; } }