Пример #1
0
void UmlClass::extend(WrapperStr mcl)
{
    if (parent()->parent()->kind() != aPackage)
        return;

    int index = mcl.find('#');

    if (index == -1)
        return;

    WrapperStr path = mcl.left(index);
    const char * defltpath0 = "http://schema.omg.org/spec/UML/2.0/uml.xml";
    const char * defltpath1 = "http://schema.omg.org/spec/UML/2.1/uml.xml";
    bool dflt = ((path == defltpath0) || (path == defltpath1));

    mcl = mcl.mid(index + 1);

    static Q3PtrList<UmlClass> metaclasses;

    Q3PtrListIterator<UmlClass> it(metaclasses);
    UmlClass * metacl = UmlClass::get(mcl, 0);
    WrapperStr s;

    if ((metacl == 0) ||
        (metacl->stereotype() != "metaclass") ||
        !((dflt) ? (!metacl->propertyValue("metaclassPath", s) ||
                    (s == defltpath0) ||
                    (s == defltpath1))
          : (metacl->propertyValue("metaclassPath", s) &&
             (path == s)))) {
        metacl = 0;

        if (dflt) {
            for (; (metacl = it.current()) != 0; ++it) {
                if (!strcmp(mcl, metacl->name()) &&
                    (!metacl->propertyValue("metaclassPath", s) ||
                     (s == defltpath0) ||
                     (s == defltpath1)))
                    break;
            }
        }
        else {
            for (; (metacl = it.current()) != 0; ++it) {
                if (!strcmp(mcl, metacl->name()) &&
                    metacl->propertyValue("metaclassPath", s) &&
                    (path == s))
                    break;
            }
        }

        if (metacl == 0) {
            metacl = addMetaclass(mcl, (dflt) ? 0 : (const char *)path); //[rageek] different types for ? :
            metaclasses.append(metacl);
        }
    }

    UmlRelation::create(aDirectionalAssociation, this, metacl);
}
Пример #2
0
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();
}