Exemplo n.º 1
0
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 UmlJoinActivityNode::solve_output_flows() {
  // output is data if at least one input is data
  ControlOrData k = Unset;
  const Q3PtrVector<UmlItem> ch = children();
  unsigned n = ch.size(); // theo 1

  if (n == 0)
    return;

  UmlFlow * f = (UmlFlow *) ch[0];

  // look at input flows
  Q3PtrListIterator<UmlFlow> it(_incoming_flows);

  while (it.current() != 0) {
    k = it.current()->control_or_data();

    if (k == Unset) {
      ((UmlActivityNode *) it.current()->parent())->solve_output_flows();
      k = it.current()->control_or_data();
    }

    if (k == IsData)
      break;

    ++it;
  }

  f->set_control_or_data((k == IsData) ? IsData : IsControl);
}
Exemplo n.º 3
0
bool UmlComponent::write_if_needed(FileOut & out)
{
    parent()->write(out);

    out.indent();
    out << "<UML:Component name=\"";
    out.quote(name());
    out << '"';
    out.id(this);
    out << " visibility=\"public\" isAbstract=\"false\" isActive=\"false\" >\n";
    out.indent(+1);
    write_stereotype(out);
    write_description_properties(out);
    out.indent(-1);
    out.indent();
    out << "</UML:Component>\n";

    const Q3PtrVector<UmlItem> ch = children();
    unsigned n = ch.size();

    for (unsigned i = 0; i != n; i += 1)
        ch[i]->write_if_needed(out);

    unload();

    return TRUE;
}
Exemplo n.º 4
0
void UmlPseudoState::write(FileOut & out) {
  out.indent();
  out << "<subvertex xmi:type=\"uml:Pseudostate\"";
  out.id(this);
  if (! name().isEmpty()) {
    out << " name=\"";
    out.quote((const char*)name());//[jasa] ambiguous call
    out << '"';
  }
  out << " kind=\"" << sKind() << "\">\n";

  out.indent(+1);
  
  write_description_properties(out); 
     
  while (! _incoming_trans.isEmpty())
    _incoming_trans.take(0)->write_in(out);
  
  const Q3PtrVector<UmlItem> ch = children(); 
  unsigned n = ch.size();
  unsigned i;
     
  for (i = 0; i != n; i += 1)
    ch[i]->write(out);

  out.indent(-1);
  out.indent();
  out << "</subvertex>\n";
    
  unload(); 
}
Exemplo n.º 5
0
void UmlActivityPartition::write(FileOut & out) {
  const char * p = (parent()->kind() == aPartition)
    ? "subpartition" : "group";
  
  out.indent();
  out << "<" << p << " xmi:type=\"uml:ActivityPartition\" name=\"";
  out.quote((const char*)name());//[jasa] ambiguous call
  out << '"';
  out.id(this);
  if (isDimension())
    out << " isDimension=\"true\"";
  if (isExternal())
    out << " isExternal=\"true\"";
  if (represents() != 0)
    out.ref(represents(), "represents");
  out << ">\n";
  out.indent(+1);
  
  write_description_properties(out); 
  
  const Q3PtrVector<UmlItem> ch = children();
  unsigned n = ch.size();
  
  for (unsigned i = 0; i != n; i += 1)
    ch[i]->write(out);
  
  out.indent(-1);
  out.indent();
  out << "</" << p << ">\n";

  unload();
}
Exemplo n.º 6
0
void UmlActivity::readParameterNode(FileIn & in, Token & token)
{
    // the parameter node may already exist because of a
    // ActivityParameter definition, search for it
    UmlActivityParameter * param = 0;
    WrapperStr s = token.valueOf("name");
    const Q3PtrVector<UmlItem> ch = children();
    unsigned int n = ch.size();
    int i;

    for (i = 0; i != (int) n; i += 1) {
        UmlActivityParameter * p = dynamic_cast<UmlActivityParameter *>(ch[i]);

        if ((p != 0) && (p->name() == s)) {
            param = p;
            break;
        }
    }

    if (param == 0) {
        param = UmlActivityParameter::create(this, s);

        if (param == 0)
            in.error("cannot create activity parameter node '"
                     + s + "' in '" + name() + "'");

        param->addItem(token.xmiId(), in);
    }

    param->readParameterNode(in, token);

}
Exemplo n.º 7
0
void UmlPackage::roundtrip_python()
{
    Q3PtrVector<UmlItem> ch = UmlItem::children();

    for (unsigned index = 0; index != ch.size(); index += 1)
        ch[index]->roundtrip_python();
}
Exemplo n.º 8
0
void UmlItem::rename_jdk5()
{
    const Q3PtrVector<UmlItem> ch = children();

    for (unsigned i = 0; i != ch.size(); i += 1)
        ch[i]->rename_jdk5();
}
Exemplo n.º 9
0
void UmlPackage::mark_useless(Q3PtrList<UmlItem> & l) {
  Q3PtrVector<UmlItem> ch = UmlItem::children();
  UmlClassItem ** v = (UmlClassItem **) ch.data();
  UmlClassItem ** const vsup = v + ch.size();
    
  for (;v != vsup; v += 1)
    (*v)->mark_useless(l);
}
Exemplo n.º 10
0
void UmlClass::generate_import(QTextOStream & f, const Q3CString & indent) {
  Q3PtrVector<UmlItem> ch = children();
  const unsigned sup = ch.size();
  unsigned index;
  
  for (index = 0; index != sup; index += 1)
    ch[index]->generate_import(f, indent);
}
Exemplo n.º 11
0
void UmlClass::search_class_assoc()
{
    const Q3PtrVector<UmlItem> ch = children();
    unsigned n = ch.size();

    for (unsigned i = 0; i != n; i += 1)
        ch[i]->search_class_assoc();
}
Exemplo n.º 12
0
void UmlItem::write(FileOut & out) {
  const Q3PtrVector<UmlItem> ch = children();
  unsigned n = ch.size();
  
  for (unsigned i = 0; i != n; i += 1)
    ch[i]->write(out);

}
Exemplo n.º 13
0
void UmlArtifact::write(FileOut & out)
{
    const char * k = (_uml_20) ? "ownedMember" : "packagedElement";

    out.indent();
    out << "<" << k << " xmi:type=\"uml:Artifact\"";
    out.id(this);
    out << " name=\"";
    out.quote((const char *)name()); //[jasa] ambiguous call
    out << "\">\n";
    out.indent(+1);

    write_description_properties(out);

    const Q3PtrVector<UmlItem> ch = children();
    unsigned i;
    unsigned n = ch.size();
    unsigned rank = 0;

    for (i = 0; i != n; i += 1) {
        UmlItem * x = ch[i];

        if ((x->kind() == aNcRelation) &&
            (x->stereotype() == "manifest") &&
            (((UmlNcRelation *) x)->relationKind() == aDependency))
            write_manifest(out, ((UmlNcRelation *) x)->target(), "dependency", ++rank);
        else
            ch[i]->write(out);
    }

    if (stereotype() == "source") {
        const Q3PtrVector<UmlClass> & cls = associatedClasses();

        n = cls.size();

        for (i = 0; i != n; i += 1)
            write_manifest(out, cls[i], "source", ++rank);
    }
    else {
        const Q3PtrVector<UmlArtifact> & arts = associatedArtifacts();

        n = arts.size();

        for (i = 0; i != n; i += 1)
            write_manifest(out, arts[i], 0, ++rank);
    }

    out.indent(-1);
    out.indent();
    out << "</" << k << ">\n";

    unload();

}
Exemplo n.º 14
0
void UmlActivityAction::write_end(FileOut & out, bool dontclose) {
  out << ">\n";
  out.indent(+1);
  
  Q3CString s = constraint();
  
  if (! s.isEmpty()) {
    out.indent();
    out << "<ownedRule xmi:type=\"uml:Constraint\"";
    out.id_prefix(this, "CONSTRAINT_");
    out.ref(this, "constrainedElement");
    out << ">\n";
    out.indent();
    out << "\t<specification xmi:type=\"uml:OpaqueExpression\"";
    out.id_prefix(this, "CSPEC_");
    out << ">\n";
    out.indent();
    out << "\t\t<body>";
    out.quote(s);
    out << "</body>\n";
    out.indent();
    out << "\t</specification>\n";
    out.indent();
    out << "</ownedRule>\n";
  }
  
  write_description_properties(out);

  switch (_lang) {
  case Uml:
    write_condition(out, preCondition(), TRUE);
    write_condition(out, postCondition(), FALSE);
    break;
  case Cpp:
    write_condition(out, cppPreCondition(), TRUE);
    write_condition(out, cppPostCondition(), FALSE);
    break;
  default:
    // java
    write_condition(out, javaPreCondition(), TRUE);
    write_condition(out, javaPostCondition(), FALSE);
  }

  const Q3PtrVector<UmlItem> ch = children();
  unsigned n = ch.size();
  
  for (unsigned i = 0; i != n; i += 1)
    ch[i]->write(out);

  write_incoming_flows(out);
  
  if (!dontclose)
    write_close(out);
}
Exemplo n.º 15
0
bool UmlItem::write_if_needed(FileOut & out)
{
    const Q3PtrVector<UmlItem> ch = children();
    unsigned n = ch.size();
    bool used = FALSE;

    for (unsigned i = 0; i != n; i += 1)
        used |= ch[i]->write_if_needed(out);

    return used;
}
Exemplo n.º 16
0
void UmlForkActivityNode::solve_output_flows() {
  // input and outputs flows must be control/data

  UmlFlow * f;
  ControlOrData k;
  const Q3PtrVector<UmlItem> ch = children();
  unsigned n = ch.size();

  if (!_incoming_flows.isEmpty()) {
    f = _incoming_flows.getFirst();
    k = f->control_or_data();
  }
  else {
    f = 0;
    k = Unset;
  }

  if (k == Unset) {
    // look at output flows
    for (unsigned i = 0; i != n; i += 1) {
      UmlFlow * f = dynamic_cast<UmlFlow *>(ch[i]);

      if ((f != 0) && ((k = f->control_or_data()) != Unset))
	break;
    }

    if (f != 0) {
      // f is unset
      if (k != Unset) {
	if (f->control_or_data() == Unset)
	  // propagate on input
	  f->set_control_or_data(k);
      }
      else {
	// solve input flow
	((UmlActivityNode *) f->parent())->solve_output_flows();
	k = f->control_or_data();
	if (k == Unset)
	  // not possible to know, force control
	  k = IsControl;
	// propagate on input
	f->set_control_or_data(k);
      }
    }
  }

  // propagate on output
  for (unsigned i = 0; i != n; i += 1) {
    UmlFlow * f = dynamic_cast<UmlFlow *>(ch[i]);

    if ((f != 0) && (f->control_or_data() == Unset))
      f->set_control_or_data(k);
  }
}
Exemplo n.º 17
0
void UmlPseudoState::memo_incoming_trans() {
  const Q3PtrVector<UmlItem> ch = children(); 
  unsigned n = ch.size();
  unsigned i;
     
  for (i = 0; i != n; i += 1) {
    UmlStateItem * x = dynamic_cast<UmlStateItem *>(ch[i]);

    if (x != 0)
      x->memo_incoming_trans();
  }
}
Exemplo n.º 18
0
void UmlInitialActivityNode::solve_output_flows() {
  const Q3PtrVector<UmlItem> ch = children();
  unsigned n = ch.size();
  
  for (unsigned i = 0; i != n; i += 1) {
    UmlFlow * f = dynamic_cast<UmlFlow *>(ch[i]);

    if ((f != 0) && (f->control_or_data() == Unset))
      f->set_control_or_data(IsControl);
  }

}
Exemplo n.º 19
0
void UmlActivityParameter::write(FileOut & out) {
  // write parameter def

  out.indent();
  out << "<ownedParameter name=\"";
  out.quote(name());
  out << '"';
  out.id(this);
  write_dir(out);
  write_effect(out);
  write_flags(out);
  out << ">\n";
  
  out.indent(+1);
  
  write_description_properties(out);
  write_multiplicity(out, multiplicity(), this);
  write_default_value(out, defaultValue(), this);
  UmlItem::write_type(out, type());
  
  out.indent(-1);

  out.indent();
  out << "</ownedParameter>\n";

  //write parameter node
  out.indent();
  out << "<node xmi:type=\"uml:ActivityParameterNode\" name =\"";
  out.quote(name());
  out << '"';
  out.id_prefix(this, "PARAMETER_NODE_");
  if (isControlType())
    out << " isControlType=\"true\"";
  write_ordering(out);
  write_selection(out);
  write_in_state(out);
  out << ">\n";
  out.indent(+1);

  UmlItem::write_type(out, type());

  const Q3PtrVector<UmlItem> ch = children();
  unsigned n = ch.size();
  
  for (unsigned i = 0; i != n; i += 1)
    ch[i]->write(out);

  out.indent(-1);
  out.indent();
  out << "</node>\n";

  unload();
}
Exemplo n.º 20
0
void UmlClassView::change(Context & ctx) {
  if (ctx.onClass() || ctx.onOperation() ||
      ctx.onAttribute() || ctx.onRelation()) {
    const Q3PtrVector<UmlItem> ch = children();
    unsigned i;
    
    for (i = 0; i != ch.size(); i += 1)
      ch[i]->change(ctx);
    
    unload(TRUE, TRUE);
  }
}
Exemplo n.º 21
0
void UmlActivityNode::memo_incoming_flow() {
  const Q3PtrVector<UmlItem> ch = children(); 
  unsigned n = ch.size();
  unsigned i;
     
  for (i = 0; i != n; i += 1) {
    UmlActivityItem * x = dynamic_cast<UmlActivityItem *>(ch[i]);
								
    if (x != 0)
      x->memo_incoming_flow();
  }
}
Exemplo n.º 22
0
void UmlItem::loadFromProfile()
{
    WrapperStr id;

    if (propertyValue("xmiId", id) && (All.find(id) == All.end()))
        All.insert(id, this);

    const Q3PtrVector<UmlItem> ch = children();
    unsigned n = ch.size();

    for (unsigned u = 0; u != n; u += 1)
        ch[u]->loadFromProfile();
}
Exemplo n.º 23
0
void UmlItem::move_after(anItemKind k, const char * name)
{
    const Q3PtrVector<UmlItem> ch = parent()->children();
    unsigned i;

    for (i = 0; i != ch.size(); i += 1) {
        if ((ch[i]->kind() == k) &&
            (ch[i]->name() == name)) {
            moveAfter(ch[i]);
            break;
        }
    }
}
Exemplo n.º 24
0
void UmlClass::uml2java(bool rec) {
  if (isJavaExternal())
    set_JavaDecl(JavaSettings::externalClassDecl());
  else {
    Q3CString st = JavaSettings::classStereotype(stereotype());
    UmlItem * pack = parent()->parent();
    
    while (pack->kind() != aPackage)
      pack = pack->parent();
    
    if ((st == "stereotype") ||
	(st == "metaclass") ||
	(pack->stereotype() == "profile")) {
      set_CppDecl("");
      return;
    }
    
    if (st == "enum_pattern")
      set_JavaDecl(JavaSettings::enumPatternDecl());
    else if (st == "enum")
      set_JavaDecl(JavaSettings::enumDecl());
    else if (st == "interface")
      set_JavaDecl(JavaSettings::interfaceDecl());
    else if (st == "@interface") {
      Q3CString s = JavaSettings::interfaceDecl();
      int index = s.find("interface");
      
      if (index != -1)
	s.insert(index, '@');
      set_JavaDecl(s);
    }
    else if (st == "ignored") {
      set_JavaDecl("");
      return;
    }
    else
      set_JavaDecl(JavaSettings::classDecl());
    
    if (rec) {
      const Q3PtrVector<UmlItem> ch = children();
      unsigned n = ch.size();
      
      for (unsigned i = 0; i != n; i += 1)
	ch[i]->uml2java(rec);
    }
    
    if (parent()->kind() == aClassView)
      // not nested
      artifact()->set_JavaSource(JavaSettings::sourceContent());
  }
}
Exemplo n.º 25
0
bool UmlClass::isAppliedStereotype(Token & tk, WrapperStr & prof_st, Q3ValueList<WrapperStr> & base_v)
{
    static Q3Dict<WrapperStr> stereotypes;
    static Q3Dict<Q3ValueList<WrapperStr> > bases;

    WrapperStr s = tk.what();
    WrapperStr * st = stereotypes[s];

    if (st != 0) {
        prof_st = *st;
        base_v = *bases[s];
        return TRUE;
    }

    base_v.clear();

    if (tk.xmiType().isEmpty() && (getFct(tk) == 0))  {
        int index = s.find(':');

        if ((index != -1) &&
            ((index != 3) || ((s.left(3) != "uml") && (s.left(3) != "xmi")))) {
            UmlClass * cl = findStereotype(s, FALSE);

            if (cl != 0) {
                const Q3PtrVector<UmlItem> ch = cl->children();
                unsigned n = ch.size();

                for (unsigned i = 0; i != n; i += 1) {
                    UmlItem * x = ch[i];

                    if ((x->kind() == aRelation) &&
                        (((UmlRelation *) x)->relationKind() == aDirectionalAssociation) &&
                        (((UmlRelation *) x)->roleType()->stereotype() == "metaclass"))
                        base_v.append("base_" + ((UmlRelation *) x)->roleType()->name().lower());
                }

                if (base_v.isEmpty())
                    base_v.append("base_element");

                prof_st = cl->parent()->parent()->name() + ":" + cl->name();
                stereotypes.insert(s, new WrapperStr(prof_st));
                bases.insert(s, new Q3ValueList<WrapperStr>(base_v));
                return TRUE;
            }
        }
    }

    return FALSE;
}
Exemplo n.º 26
0
void UmlClass::uml2idl(bool rec) {
  if (isIdlExternal())
    set_IdlDecl(IdlSettings::externalClassDecl());
  else {
    Q3CString st = IdlSettings::classStereotype(stereotype());
    UmlItem * pack = parent()->parent();
    
    while (pack->kind() != aPackage)
      pack = pack->parent();
    
    if ((st == "stereotype") ||
	(st == "metaclass") ||
	(pack->stereotype() == "profile")) {
      set_CppDecl("");
      return;
    }
    
    if (st == "struct")
      set_IdlDecl(IdlSettings::structDecl());
    else if (st == "union")
      set_IdlDecl(IdlSettings::unionDecl());
    else if (st == "enum")
      set_IdlDecl(IdlSettings::enumDecl());
    else if (st == "exception")
      set_IdlDecl(IdlSettings::exceptionDecl());
    else if (st == "typedef")
      set_IdlDecl(IdlSettings::typedefDecl());
    else if (st == "interface")
      set_IdlDecl(IdlSettings::interfaceDecl());
    else if (st == "ignored") {
      set_IdlDecl("");
      return;
    }
    else
      set_IdlDecl(IdlSettings::valuetypeDecl());
    
    if (rec) {
      const Q3PtrVector<UmlItem> ch = children();
      unsigned n = ch.size();
      
      for (unsigned i = 0; i != n; i += 1)
	ch[i]->uml2idl(rec);
    }
    
    if (parent()->kind() == aClassView)
      // not nested
      artifact()->set_IdlSource(IdlSettings::sourceContent());
  }
}
Exemplo n.º 27
0
void UmlClass::uml2cpp(bool rec) {
  if (isCppExternal())
    set_CppDecl(CppSettings::externalClassDecl());
  else {
    Q3CString st = CppSettings::classStereotype(stereotype());
    UmlItem * pack = parent()->parent();
    
    while (pack->kind() != aPackage)
      pack = pack->parent();
    
    if ((st == "stereotype") ||
	(st == "metaclass") ||
	(pack->stereotype() == "profile")) {
      set_CppDecl("");
      return;
    }
    
    if (st == "enum")
      set_CppDecl(CppSettings::enumDecl());
    else if (st == "union")
      set_CppDecl(CppSettings::unionDecl());
    else if (st == "struct")
      set_CppDecl(CppSettings::structDecl());
    else if (st == "typedef")
      set_CppDecl(CppSettings::typedefDecl());
    else if (st == "ignored") {
      set_CppDecl("");
      return;
    }
    else
      set_CppDecl(CppSettings::classDecl());
    
    if (rec) {
      const Q3PtrVector<UmlItem> ch = children();
      unsigned n = ch.size();
      
      for (unsigned i = 0; i != n; i += 1)
	ch[i]->uml2cpp(rec);
    }
    
    if (parent()->kind() == aClassView) {
      // not nested
      UmlArtifact * art = artifact();
			 
      art->set_CppSource(CppSettings::sourceContent());
      art->set_CppHeader(CppSettings::headerContent());
    }
  }
}
Exemplo n.º 28
0
void UmlActivityAction::solve_output_flows() {
  const Q3PtrVector<UmlItem> ch = children();
  unsigned n = ch.size();
  
  for (unsigned i = 0; i != n; i += 1) {
    UmlFlow * f = dynamic_cast<UmlFlow *>(ch[i]);

    if ((f != 0) && (f->control_or_data() == Unset)) {
      UmlActivityObject * o = dynamic_cast<UmlActivityObject *>(f->target());

      f->set_control_or_data(((o == 0) || o->isControlType()) ? IsControl : IsData);
    }
  }

}
Exemplo n.º 29
0
void UmlClass::generate_def(QTextOStream & f, Q3CString indent, bool h) {
  if (! cppDecl().isEmpty()) {
    Q3PtrVector<UmlItem> ch = children();
    Q3CString templates;
    Q3CString cl_names;
    Q3CString templates_tmplop;
    Q3CString cl_names_tmplop;
    
    spec(templates, cl_names, templates_tmplop, cl_names_tmplop);
    
    for (unsigned index = 0; index != ch.size(); index += 1)
      if (ch[index]->kind() != aNcRelation)
	((UmlClassItem *) ch[index])
	  ->generate_def(f, indent, h, templates, cl_names,
			 templates_tmplop, cl_names_tmplop);
  }
}
Exemplo n.º 30
0
bool UmlBaseClass::set_Name(const Q3CString & s) {
  if (!UmlBaseItem::set_Name(s))
    return FALSE;

  const Q3PtrVector<UmlItem> ch = children();
  Q3CString destr = "~" + name();

  for (unsigned i = 0; i != ch.size(); i += 1) {
    if (ch[i]->kind() == anOperation) {
      if (ch[i]->name() == name())
	ch[i]->set_Name(s);
      else if (ch[i]->name() == destr)
	ch[i]->set_Name("~" + s);
    }
  }

  return TRUE;
}