Beispiel #1
0
void UmlClassMember::write_type(FileOut & out, const UmlTypeSpec & t, Q3CString s, const char * k_name, const char * k_type)
{
    s = s.simplifyWhiteSpace();

    int index;

    // remove k_name and all after it except []
    if (k_name && *k_name && ((index = s.find(k_name, 0)) != -1)) {//[rageek] Removed CS=FALSE - rethink this, case sensitive
        //remove name
        s.remove(index, strlen(k_name));

        for (;;) {
            if (s[index] == ' ')
                s.remove(index, 1);

            if (s[index] != '[')
                break;

            index += 1;

            int index2;

            if ((index2 = s.find(index, ']')) == -1)
                break;

            index = index2 + 1;
        }

        s.resize(index);
    }
    else if ((index = s.find('=')) != -1) {
        s.resize(index);
        s = s.simplifyWhiteSpace();
    }

    if (k_type && *k_type && ((index = s.find(k_type)) == -1))
        out.idref_datatype(s);
    else if (s != k_type) {
        // have modifiers
        if (t.type != 0) {
            s.replace(index, strlen(k_type), t.type->name());
            out.idref(s, t.type);
        }
        else
            out.idref_datatype(s.replace(index, strlen(k_type), t.explicit_type));
    }
    else if (t.type != 0)
        out.idref(t.type);
    else
        out.idref_datatype(t.explicit_type);
}
Beispiel #2
0
void UmlRelation::write_ends(FileOut & out) {
  // note : it is the first side
 
  out.indent();
  out << "\t<memberEnd";
  out.idref(this);
  out << "/>\n";
  
  UmlRelation * other = side(FALSE);
  
  out.indent();
  if (other != 0) {
    out << "\t<memberEnd";
    out.idref(other);
    out << "/>\n";
  }
  else {
    out << "\t<ownedEnd xmi:type=\"uml:Property\"";
    out.id_prefix(this, "REVERSE_");
    if (_assoc_class != 0)
      out.ref(_assoc_class, "association");
    else
      out.ref(this, "association", "ASSOC_");
    out << " visibility=\"" << ((_vis_prefix) ? "vis_private\"" : "private\"");
    out.ref(parent(), "type");
    out << " aggregation=\"";
    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 << "\" isNavigable=\"false\"/>\n";

    out.indent();
    out << "\t<memberEnd ";
    out.idref_prefix(this, "REVERSE_");
    out << "/>\n";
  }

}
Beispiel #3
0
void UmlTransition::write_in(FileOut & out)
{
    out.indent();
    out << "<incoming";
    out.idref(this);
    out << "/>\n";
}
Beispiel #4
0
void UmlItem::ref(FileOut & out)
{
    // theorically not called
    out << "<UML:???kind=" << kind() << "??? ";
    out.idref(this);
    out << "/>";
}
Beispiel #5
0
void UmlOperation::write_return_type(FileOut & out, QCString decl) {
  const UmlTypeSpec & t = returnType();
  static int return_rank = 0;
  
  if ((t.type != 0) || !t.explicit_type.isEmpty()) {
    out.indent();
    out << "<UML:Parameter name=\"return\" xmi.id=\"BOUML_return_"
        << ++return_rank << "\" kind=\"return\">\n";
    out.indent();
    out << "\t<UML:Parameter.type>\n";
    out.indent();
    out << "\t\t<UML:DataType";
    switch (_lang) {
    case Uml:
      if (t.type != 0)
	out.idref(t.type);
      else
	out.idref_datatype(t.explicit_type);
      break;
    case Cpp:
      write_cpp_returntype(out, decl);
      break;
    default: // java
      write_java_returntype(out, decl);
    }
    out << "/>\n";
    out.indent();
    out << "\t</UML:Parameter.type>\n";
    out.indent();
    out << "</UML:Parameter>\n";
  }
}
Beispiel #6
0
void UmlActivityNode::write_incoming_flows(FileOut & out) {
  Q3PtrListIterator<UmlFlow> it(_incoming_flows);
  
  while (it.current() != 0) {
    out.indent();
    out << "<incoming";
    out.idref(it.current());
    out << "/>\n";
    ++it;
  }

}
Beispiel #7
0
void UmlTransition::write(FileOut & out)
{
    UmlStateItem * x = dynamic_cast<UmlStateItem *>(parent()->parent());

    if (x == 0)
        x = dynamic_cast<UmlStateItem *>(parent());

    x->memo_trans(this);

    out.indent();
    out << "<outgoing";
    out.idref(this);
    out << "/>\n";
}
Beispiel #8
0
void UmlClass::ref(FileOut & out)
{
    if ((stereotype() == "actor") ||
        ((parent()->kind() != aClassView) &&
         (parent()->kind() != aClass)))
        out << "<UML:Actor";
    else if (stereotype() == "interface")
        out << "<UML:Interface";
    else
        out << "<UML:Class";

    out.idref(this);
    out << "/>";
}
void UmlCallBehaviorAction::write(FileOut & out) {
  write_begin(out, "CallBehaviorAction");
  write_end(out, TRUE);
  
  UmlItem * b = behavior();
  
  if (b != 0) {
    out.indent();
    out << "<behavior";
    out.idref(b);
    out << "/>\n";
  }

  write_close(out);

}
void UmlCallOperationAction::write(FileOut & out) {
  write_begin(out, "CallOperationAction");
  write_end(out, TRUE);
  
  UmlOperation * op = operation();
  
  if (op != 0) {
    out.indent();
    out << "<operation";
    out.idref(op);
    out << "/>\n";
  }

  write_close(out);

}
Beispiel #11
0
void UmlClass::write_actuals(FileOut & out)
{
    Q3ValueList<UmlActualParameter> actual_params = actuals();
    Q3ValueList<UmlActualParameter>::ConstIterator iter;
    int rank;
    UmlClass * super = 0;

    for (iter = actual_params.begin(), rank = 0;
         iter != actual_params.end();
         ++iter, rank += 1) {
        if (super != (*iter).superClass()) {
            if (super != 0) {
                out.indent(-1);
                out.indent();
                out << "</templateBinding>\n";
            }

            super = (*iter).superClass();

            out.indent();
            out << "<templateBinding xmi:type=\"uml:TemplateBinding\"";
            out.id_prefix(this, "ACTUAL", rank);
            out << ">\n";
            out.indent(+1);

            out.indent();
            out << "<boundElement";
            out.idref(this);
            out << " />\n";

            out.indent();
            out << "<signature";
            out.idref_prefix(super, "FORMALS_");
            out << " />\n";
        }

        (*iter).write(out, this, rank);
    }

    if (super != 0) {
        out.indent(-1);
        out.indent();
        out << "</templateBinding>\n";
    }

}
void UmlReduceAction::write(FileOut & out) {
  write_begin(out, "ReduceAction");
  
  if (isOrdered())
    out << " isOrdered=\"true\"";
  
  write_end(out, TRUE);

  UmlItem * r = reducer();
  
  if (r != 0) {
    out.indent();
    out << "<reducer";
    out.idref(r);
    out << "/>\n";
  }

  write_close(out);
}
Beispiel #13
0
void UmlOperation::write_uml_params(FileOut & out) {
  const QValueList<UmlParameter> p = params();
  QValueList<UmlParameter>::ConstIterator it;
  
  for (it = p.begin(); it != p.end(); ++it) {
    out.indent();
    out << "<UML:Parameter name=\"" << (*it).name
      << "\" xmi.id=\"BOUML_op_param_"
	<< ++param_id << "\" kind =\"";
    switch ((*it).dir) {
    case InputOutputDirection: out << "inout\">\n"; break;
    case OutputDirection: out << "out\">\n"; break;
    default: out << "in\">\n";
    }
    
    const UmlTypeSpec & pt = (*it).type;
    
    if (pt.type != 0) {
      out.indent();
      out << "\t<UML:Parameter.type>\n";
      out.indent();
      out << "\t\t<UML:DataType";
      out.idref(pt.type);
      out << "/>\n";
      out.indent();
      out << "\t</UML:Parameter.type>\n";
    }
    else if (!pt.explicit_type.isEmpty()) {
      out.indent();
      out << "\t<UML:Parameter.type>\n";
      out.indent();
      out << "\t\t<UML:DataType";
      out.idref_datatype(pt.explicit_type);
      out << "/>\n";
      out.indent();
      out << "\t</UML:Parameter.type>\n";
    }
    
    out.indent();
    out << "</UML:Parameter>\n";
  }
}
Beispiel #14
0
void UmlOperation::write_exceptions(FileOut & out)
{
    const Q3ValueList<UmlTypeSpec> excpts = exceptions();
    Q3ValueList<UmlTypeSpec>::ConstIterator iter;

    for (iter = excpts.begin(); iter != excpts.end(); ++iter) {
        const UmlTypeSpec & e = *iter;

        if (e.type != 0) {
            out.indent();
            out << "<raisedException";
            out.idref(e.type);
            out << "/>\n";
        }
        else if (!e.explicit_type.isEmpty()) {
            out.indent();
            out << "<raisedException";
            out.idref_datatype(e.explicit_type);
            out << "/>\n";
        }
    }
}
Beispiel #15
0
void UmlItem::write_type(FileOut & out, const UmlTypeSpec & t, const char * tk)
{
    if (t.type != 0) {
        out.indent();
        out << '<' << ((tk != 0) ? tk : "type") << " xmi:type=\"uml:Class\"";
        out.idref(t.type);
        out << "/>\n";
    }
    else if (!t.explicit_type.isEmpty()) {
        out.indent();
        out << '<' << ((tk != 0) ? tk : "type") << " xmi:type=\"uml:";

        if (t.explicit_type == "int")
            out << ((_uml_20)
                    ? "PrimitiveType\" href=\"http://schema.omg.org/spec/UML/2.0/uml.xml#Integer\"/>\n"
                    : "PrimitiveType\" href=\"http://schema.omg.org/spec/UML/2.1/uml.xml#Integer\"/>\n");
        else if (t.explicit_type == "bool")
            out << ((_uml_20)
                    ? "PrimitiveType\" href=\"http://schema.omg.org/spec/UML/2.0/uml.xml#Boolean\"/>\n"
                    : "PrimitiveType\" href=\"http://schema.omg.org/spec/UML/2.1/uml.xml#Boolean\"/>\n");
        else if (t.explicit_type == "string")
            out << ((_uml_20)
                    ? "PrimitiveType\" href=\"http://schema.omg.org/spec/UML/2.0/uml.xml#String\"/>\n"
                    : "PrimitiveType\" href=\"http://schema.omg.org/spec/UML/2.1/uml.xml#String\"/>\n");
        else if (t.explicit_type == "long")
            out << ((_uml_20)
                    ? "PrimitiveType\" href=\"http://schema.omg.org/spec/UML/2.0/uml.xml#UnlimitedNatural\"/>\n"
                    : "PrimitiveType\" href=\"http://schema.omg.org/spec/UML/2.1/uml.xml#UnlimitedNatural\"/>\n");
        else {
            out << "Class\"";
            out.idref_datatype(t.explicit_type);
            out << "/>\n";
        }
    }

}
Beispiel #16
0
void UmlComponent::ref(FileOut & out)
{
    out << "<UML:Component";
    out.idref(this);
    out << "/>";
}
Beispiel #17
0
bool UmlAttribute::write_if_needed(FileOut & out)
{
    switch (_lang) {
    case Uml:
        parent()->write(out);
        out.indent();
        out << "<UML:Attribute name=\"" << name() << '"';
        break;

    case Cpp:
        if (cppDecl().isEmpty())
            return FALSE;

        parent()->write(out);
        out.indent();
        out << "<UML:Attribute name=\"" << true_name(cppDecl()) << '"';
        break;

    default: // Java
        if (javaDecl().isEmpty())
            return FALSE;

        parent()->write(out);
        out.indent();
        out << "<UML:Attribute name=\"" << true_name(javaDecl()) << '"';
        break;
    }

    out.id(this);

    switch (_lang) {
    case Uml:
        write_visibility(out);
        break;

    case Cpp:
        write_visibility(out,
                         (cppVisibility() == DefaultVisibility)
                         ? visibility() : cppVisibility());
        break;

    default: // Java
        if (javaDecl().find("${visibility}") != -1)
            write_visibility(out, visibility());

        break;
    }

    write_scope(out);
    out << ">\n";
    out.indent(+1);

    const UmlTypeSpec & t = type();

    if ((t.type != 0) || !t.explicit_type.isEmpty()) {
        out.indent();
        out << "<UML:StructuralFeature.type>\n";
        out.indent();
        out << "\t<UML:DataType";

        switch (_lang) {
        case Uml:
            if (t.type != 0)
                out.idref(t.type);
            else
                out.idref_datatype(t.explicit_type);

            break;

        case Cpp:
            write_cpp_type(out);
            break;

        default: // java
            write_java_type(out);
        }

        out << "/>\n";
        out.indent();
        out << "</UML:StructuralFeature.type>\n";
    }

    write_stereotype(out);
    write_annotation(out);
    write_description_properties(out);

    out.indent(-1);
    out.indent();
    out << "</UML:Attribute>\n";

    unload();

    return TRUE;
}
Beispiel #18
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();
}