コード例 #1
0
ファイル: UmlItem.cpp プロジェクト: bleakxanadu/douml
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();
}
コード例 #2
0
ファイル: UmlBaseClass.cpp プロジェクト: SciBoy/douml
const Q3PtrVector<UmlComponent> UmlBaseClass::associatedComponents() {
  UmlCom::send_cmd(_identifier, assocComponentCmd);

  Q3PtrVector<UmlComponent> result;
  unsigned n = UmlCom::read_unsigned();

  result.resize(n);

  for (unsigned index = 0; index != n; index += 1)
    result.insert(index, (UmlComponent *) UmlBaseItem::read_());

  return result;
}
コード例 #3
0
ファイル: UmlCom.cpp プロジェクト: SciBoy/douml
void UmlCom::read_item_list(Q3PtrVector<UmlItem> & v)
{
  unsigned n = read_unsigned();
  
  v.resize(n);
  
#ifdef TRACE
  //cout << "UmlCom::read_item_list " << n << " items\n";
#endif
  
  for (unsigned index = 0; index != n; index += 1)
    v.insert(index, UmlBaseItem::read_());
}
コード例 #4
0
ファイル: UmlClass.cpp プロジェクト: SciBoy/douml
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());
  }
}
コード例 #5
0
ファイル: UmlClass.cpp プロジェクト: daniel7solis/douml
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;
}
コード例 #6
0
ファイル: UmlClass.cpp プロジェクト: SciBoy/douml
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());
    }
  }
}
コード例 #7
0
ファイル: UmlClass.cpp プロジェクト: SciBoy/douml
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());
  }
}
コード例 #8
0
ファイル: UmlActivityAction.cpp プロジェクト: SciBoy/douml
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);
    }
  }

}
コード例 #9
0
ファイル: UmlClass.cpp プロジェクト: SciBoy/douml
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);
  }
}
コード例 #10
0
ファイル: UmlBaseClass.cpp プロジェクト: SciBoy/douml
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;
}
コード例 #11
0
ファイル: UmlComponentView.cpp プロジェクト: SciBoy/douml
bool UmlComponentView::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); 
     
  if (used && _gen_views) { 
    out.indent(-1); 
    out.indent(); 
    out << "</UML:Namespace.ownedElement>\n"; 
     
    out.indent(-1); 
    out.indent(); 
    out << "</UML:Package>\n"; 
  } 
 
  return used; 
}
コード例 #12
0
ファイル: UmlClass.cpp プロジェクト: bleakxanadu/douml
void UmlClass::get_extended(Q3ValueList<WrapperStr> & r)
{
    r.clear();

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

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

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

    if (r.isEmpty())
        r.append("Element");
}
コード例 #13
0
ファイル: UmlPackage.cpp プロジェクト: bleakxanadu/douml
UmlPackage * UmlPackage::findProfile(WrapperStr xmiId)
{
    if (stereotype() == "profile") {
        WrapperStr id;

        if (propertyValue("xmiId", id) && (id == xmiId))
            return this;
    }

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

    for (unsigned u = 0; u != n; u += 1) {
        if ((ch[u]->kind() == aPackage) &&
            ((r = ((UmlPackage *) ch[u])->findProfile(xmiId)) != 0))
            return r;
    }

    return 0;
}
コード例 #14
0
ファイル: UmlClass.cpp プロジェクト: SciBoy/douml
void UmlClass::uml2python(bool rec) {
  if (isPythonExternal())
    set_PythonDecl(PythonSettings::externalClassDecl());
  else {
    Q3CString st = PythonSettings::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_PythonDecl(PythonSettings::enumDecl());
    else if (st == "ignored") {
      set_PythonDecl("");
      return;
    }
    else
      set_PythonDecl(PythonSettings::classDecl());
    
    if (rec) {
      const Q3PtrVector<UmlItem> ch = children();
      unsigned n = ch.size();
      
      for (unsigned i = 0; i != n; i += 1)
	ch[i]->uml2python(rec);
    }
    
    if (parent()->kind() == aClassView)
      // not nested
      artifact()->set_PythonSource(PythonSettings::sourceContent());
  }
}
コード例 #15
0
void UmlClass::reorder(Q3PtrList<UmlItem> & expected_order)
{
    if (expected_order.isEmpty())
        return;

    Q3PtrVector<UmlItem> ch = UmlItem::children(); // copy
    UmlItem ** v = ch.data();

    unload(); // to not reload children each time

    //bool updated = FALSE;
    UmlItem * expected_previous = 0;
    Q3PtrListIterator<UmlItem> expected_it(expected_order);
    UmlItem * expected;

    while ((expected = expected_it.current()) != 0) {
        if (*v != expected) {
            //updated = TRUE;
            expected->moveAfter(expected_previous);

            UmlItem * x1 = expected;

            do {
                UmlItem * x2 = *v;

                *v = x1;
                x1 = x2;
            }
            while (x1 != expected);
        }

        expected_previous = expected;
        ++expected_it;
        v += 1;
    }

    //if (updated)
    //  get_class()->set_updated();
}
コード例 #16
0
ファイル: Package.cpp プロジェクト: jeremysalwen/douml
UmlPackage * Package::get_uml(bool mandatory)
{
    if (uml == 0) {
        const char * name = text(0);
        Package * pa = (Package *) parent();
        UmlPackage * uml_pa = pa->get_uml();	// will end on project

        Q3PtrVector<UmlItem> ch = uml_pa->children();

        for (unsigned index = 0; index != ch.size(); index += 1) {
            UmlItem * it = ch[index];

            if ((it->kind() == aPackage) && (it->name() == name))
                return uml = (UmlPackage *) it;
        }

        if ((uml = UmlBasePackage::create(uml_pa, name)) == 0) {
            if (!mandatory)
                return 0;

#ifdef REVERSE
            UmlCom::trace(WrapperStr("<font face=helvetica><b>cannot create package <i>")
                          + name + "</i> under package <i>" + uml_pa->name() +
                          "</b></font><br>");
            UmlCom::message("");
            throw 0;
#else
            QMessageBox::critical(0, "Fatal Error",
                                  QString("<font face=helvetica><b>cannot create package <i>")
                                  + name + "</i> under package <i>"
                                  + ((const char *) uml_pa->name()) + "</b></font><br>");
            QApplication::exit(1);
#endif
        }
    }

    return uml;
}
コード例 #17
0
ファイル: UmlClass.cpp プロジェクト: daniel7solis/douml
bool UmlClass::bind(UmlClass * tmpl)
{
    const Q3PtrVector<UmlItem> ch = children();
    unsigned int n = ch.size();
    int i;

    for (i = 0; i != (int) n; i += 1) {
        if ((ch[i]->kind() == aRelation) &&
            (((UmlRelation *) ch[i])->roleType() == tmpl)) {
            switch (((UmlRelation *) ch[i])->relationKind()) {
            case aRealization:
                ((UmlRelation *) ch[i])->set_Stereotype("bind");

                // no break
            case aGeneralisation:
                return TRUE;

            default:
                break;
            }
        }
    }

    // add realization
    UmlRelation * r =
        UmlRelation::create(aRealization, this, tmpl);

    if (r == 0) {
        UmlCom::trace("class reference '" + id() +
                      "' can't realize class reference '" + tmpl->id() + "'<br>");

        return FALSE;
    }

    r->set_Stereotype("bind");
    return TRUE;
}
コード例 #18
0
ファイル: UmlClass.cpp プロジェクト: SciBoy/douml
void UmlClass::generate_def(QTextOStream & f, Q3CString indent, bool h,
			    Q3CString templates, Q3CString cl_names,
			    Q3CString, Q3CString) {
  if (! cppDecl().isEmpty()) {
    Q3CString template1;
    Q3CString template2;
    Q3CString templates_tmplop;
    Q3CString cl_names_tmplop;
    
    get_template_prefixes(template1, template2);
    templates_tmplop = templates + "template<>\n";
    templates += template1;
    cl_names_tmplop = cl_names + "::" + name()/* true_name */;
    cl_names = cl_names_tmplop + template2;
  
    Q3PtrVector<UmlItem> ch = children();
    
    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);
  }
}
コード例 #19
0
ファイル: UmlCom.cpp プロジェクト: 02JanDal/douml
void UmlCom::send_cmd(const void * id, OnInstanceCmd cmd, const Q3PtrVector<UmlClass> & l)
{
#ifdef TRACE
    cout << "UmlCom::send_cmd(id, " << cmd << ", const Q3PtrVector<UmlClass> & l)\n";
#endif

    write_char(onInstanceCmd);
    write_id(id);
    write_char(cmd);

    unsigned n = l.count();

    write_unsigned(n);

    for (unsigned i = 0; i != n; i += 1)
        write_id(((UmlBaseItem *) l[i])->_identifier);

    flush();
}
コード例 #20
0
ファイル: UmlRelation.cpp プロジェクト: SciBoy/douml
void UmlRelation::import(File & f)
{
  if (scanning)
    f.skipBlock();
  else {
    Q3CString s;
    
    if (f.read(s) != STRING)
      f.syntaxError(s, "relation's name");
    else if (*s == '$')
      // unnamed
      s = "";
    
    Q3CString id;
    Q3CString ste;
    Q3CString doc;
    Q3Dict<Q3CString> prop;
    Q3CString s2;
    int k;
    
    do {
      k = f.readDefinitionBeginning(s2, id, ste, doc, prop);
    } while (id.isEmpty());
    
    for (;;) {
      if (k == ATOM) {
	if (s2 == "roles")
	  break;
	f.skipNextForm();
	k = f.read(s2);
      }
      else
	f.syntaxError(s);
    }
    
    f.read("(");
    f.read("list");
    f.read("role_list");
    
    Role role_1; 
    Role role_2; 
    Role * role1 = &role_1; 
    Role * role2 = &role_2; 
    
    role_1.import(f);
    role_2.import(f);
    
    UmlRelation * r = 0; 
    bool bidir = role_1.is_navigable && role_2.is_navigable;

    // place information in the logical side !
    bool b = role_1.is_aggregate;

    role_1.is_aggregate = role_2.is_aggregate;
    role_2.is_aggregate = b;

    role_1.is_aggregate |= role_1.is_byvalue;
    role_2.is_aggregate |= role_2.is_byvalue;

    if (bidir && role_2.is_aggregate) {
      // manage bouml limitation : only role1 may be an aggregate
      if (role_1.is_aggregate)
        bidir = FALSE;
      else {
	// exchange roles
	role1 = &role_2;
	role2 = &role_1;
      }
    }

    if ((role1->target != 0) && (role2->target != 0)) { 
      if (role1->is_navigable) {
	r = UmlRelation::create(role1->rel_kind(bidir), role2->target, role1->target);
	
	if (r == 0) {
	  UmlCom::trace("<br>cannot create relation '" + role1->name + "' from '" +
			role2->target->fullName() + "' to '" +
			role1->target->fullName() + "'");
	  f.read(")");
	  f.skipBlock();
	  return;
	}
	
	if (!ste.isEmpty())
	  r->set_Stereotype(ste);
	
	if (! s.isEmpty())
	  r->set_Name(s);
	
	r->import(role1);
      }
      
      if (role2->is_navigable) {
	if (bidir) {
	  const Q3PtrVector<UmlItem> ch = role2->target->children();
	  
	  r = (UmlRelation *) ch.at(ch.count() - 1);
	}
	else {
	  r = UmlRelation::create(role2->rel_kind(FALSE),role1->target, role2->target);
	  
	  if (r == 0) {
	    UmlCom::trace("<br>cannot create relation '" + role2->name +
			  "' from '" +
			  role1->target->fullName() + "' to '" +
			  role2->target->fullName() + "'");
	    f.read(")");
	    f.skipBlock();
	    return;
	  }
	  
	  if (!ste.isEmpty())
	    r->set_Stereotype(ste);
	   
	  if (! s.isEmpty()) 
	    r->set_Name(s); 
	}
	  
	r->import(role2);
      }
    }

    f.read(")");
    f.skipBlock();
  }
}
コード例 #21
0
ファイル: UmlClass.cpp プロジェクト: bleakxanadu/douml
void UmlClass::write(FileOut & out)
{
    WrapperStr st = stereotype();

    if (st == "metaclass")
        return;

    bool is_actor = (st == "actor");
    bool is_enum = (st == "enum");
    bool is_stereotype =
        (st == "stereotype") &&
        (parent()->parent()->kind() == aPackage) &&
        (parent()->parent()->stereotype() == "profile");

    if (!is_actor) {
        switch (_lang) {
        case Cpp:
            if (cppDecl().isEmpty())
                return;

            break;

        case Java:
            if (javaDecl().isEmpty())
                return;

        default:
            break;
        }
    }

    const char * k = (parent()->kind() == aClass)
                     ? "nestedClassifier"
                     : ((!_uml_20)
                        ? "packagedElement"
                        : ((is_stereotype) ? "ownedStereotype" : "ownedMember"));
    bool is_assoc_class = (_assoc != 0);

    out.indent();
    out << "<" << k << " xmi:type=\"uml:"
        << ((is_actor)
            ? "Actor"
            : ((is_assoc_class)
               ? "AssociationClass"
               : ((st == "interface")
                  ? "Interface"
                  : ((is_enum)
                     ? "Enumeration"
                     : ((is_stereotype) ? "Stereotype" : "Class")))))
        << "\" name=\"";
    out.quote((const char *)name()); //[jasa] ambiguous call
    out << '"';
    out.id(this);
    write_visibility(out);

    if (isAbstract())
        out << " isAbstract=\"true\"";

    if (isActive())
        out << " isActive=\"true\"";

    out << ">\n";

    if (is_assoc_class)
        _assoc->write_ends(out);

    out.indent(+1);

    write_constraint(out);
    write_annotation(out);
    write_description_properties(out);

    if (_gen_extension && (st == "typedef")) {
        const UmlTypeSpec & base = baseType();

        if ((base.type != 0) || !base.explicit_type.isEmpty()) {
            out.indent();
            out << "<xmi:Extension extender=\"Bouml\">\n";
            out.indent();
            out << "\t<typedef>\n";
            out.indent(+2);
            UmlItem::write_type(out, base, "base");
            out.indent(-2);
            out.indent();
            out << "\t</typedef>\n";
            out.indent();
            out << "</xmi:Extension>\n";
        }
    }

    write_formals(out);
    write_actuals(out);

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

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

    if (is_stereotype) {
        WrapperStr path;

        if (propertyValue("stereotypeIconPath", path) && !path.isEmpty()) {
            out.indent();
            out << "<icon xmi:type=\"uml:Image\"";
            out.id_prefix(this, "Icon_");
            out << " location=\"" << path << "\"/>\n";
        }
    }

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

    if (is_stereotype)
        for (i = 0; i != n; i += 1)
            if (ch[i]->kind() == aRelation)
                ((UmlRelation *) ch[i])->write_extension(out);

    unload();
}
コード例 #22
0
ファイル: UmlClass.cpp プロジェクト: SciBoy/douml
void UmlClass::generate_decl(QTextOStream & f_h, Q3CString indent) {
  context.append(this);
  
  bool removed = FALSE;
  Q3PtrVector<UmlItem> ch = children();
  const unsigned sup = ch.size();
  const Q3CString & stereotype = cpp_stereotype();
  bool a_typedef = (stereotype == "typedef");
  bool an_enum = (stereotype == "enum");
  const Q3ValueList<UmlFormalParameter> formals = this->formals();
  const Q3ValueList<UmlActualParameter> actuals = this->actuals();  
  unsigned index;
  const char * p = cppDecl();
  const char * pp = 0;
  const char * sep;
  bool nestedp = parent()->kind() == aClass;
  
  if (nestedp)
    indent += "    ";
  
  while ((*p == ' ') || (*p == '\t'))
    indent += *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 << *p++;
      if (*p && (*p != '#') &&
	  strncmp(p, "${members}", 10) &&
	  strncmp(p, "${items}", 8))
	f_h << indent;
    }
    else if (*p == '@')
      manage_alias(p, f_h);
    else if (*p != '$')
      f_h << *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, "${name}", 7)) {
      p += 7;
      f_h << name();
    }
    else if (a_typedef) {
      if (!strncmp(p, "${type}", 7)) {
	p += 7;
	UmlClass::write(f_h, baseType(), FALSE);
	
	UmlClass * cl = baseType().type;
	
	if ((cl != 0) && !actuals.isEmpty()) {
	  Q3ValueList<UmlActualParameter>::ConstIterator ita;
	  BooL need_space = FALSE;
    
	  for (ita = actuals.begin(); ita != actuals.end(); ++ita)
	    if ((*ita).superClass() == cl)
	      if (! (*ita).generate(f_h, need_space))
		// no specified value
		break;
	  
	  if (need_space)
	    f_h << " >";
	  else
	    f_h << '>';
	}
      }
      else
	// strange
	f_h << *p++;
    }
    else if (an_enum) {
      if (!strncmp(p, "${items}", 8)) {
	p += 8;
	
	// items declaration
	
	aVisibility current_visibility = DefaultVisibility;
	unsigned max = sup - 1;
	BooL first = TRUE;
	
	for (index = 0; index < sup; index += 1) {
	  UmlItem * it = ch[index];
	  
	  switch (it->kind()) {
	  case aClass:
	  case aNcRelation:
	    break;
	  default:
	    if (! ((UmlClassItem *) it)->cppDecl().isEmpty())
	      ((UmlClassItem *) it)->generate_decl(current_visibility,
						   f_h, stereotype, indent,
						   first, index == max);
	  }
	}
      
	if (*p == '}')
	  f_h << indent;
      }
      else
	// strange
	f_h << *p++;
    }
    else if (! strncmp(p, "${template}", 11)) {
      p += 11;
      
      // template
      
      if (!formals.isEmpty()) {
	sep = "template<";
	const char * sep2 = "<";
	BooL need_space = FALSE;
	
	Q3ValueList<UmlFormalParameter>::ConstIterator itf;
	
	for (itf = formals.begin(); itf != formals.end(); ++itf)
	  (*itf).generate(f_h, sep, sep2, need_space);
	
	f_h << ((need_space) ? " >\n" : ">\n");
	if (nestedp)
	  f_h << indent;
      }
      else if (name().find('<') != -1) {
	f_h << "template<>\n";
	if (nestedp)
	  f_h << indent;
      }
    }
    else if (! strncmp(p, "${inherit}", 10)) {
      p += 10;

      // inherit
  
      sep = " : ";
      
      for (index = 0; index != sup; index += 1) {
	UmlItem * x = ch[index];
	
	if ((x->kind() == aRelation) &&
	    !((UmlRelation *) ch[index])->cppDecl().isEmpty())
	  ((UmlRelation *) x)->generate_inherit(sep, f_h, actuals, stereotype);
      }
    }
    else if (! strncmp(p, "${members}", 10)) {
      p += 10;
  
      // members declaration
      
      aVisibility current_visibility;
      
      current_visibility = ((stereotype == "struct") || (stereotype == "union"))
	? PublicVisibility : DefaultVisibility;
      unsigned last = sup - 1;
      BooL first = TRUE;
      
      for (index = 0; index != sup; index += 1) {
	UmlItem * it = ch[index];
	  
	if ((it->kind() != aNcRelation) &&
	    ! ((UmlClassItem *) it)->cppDecl().isEmpty())
	  ((UmlClassItem *) it)->generate_decl(current_visibility,
					       f_h, stereotype, indent,
					       first, index == last);
      }
      
      if (*p == '}')
	f_h << indent;
    }
    else if (!strncmp(p, "${inlines}", 10)) {
      p += 10;
  
      context.removeLast();
      removed = TRUE;
      
      if (! nestedp) {
	// inline operations definition
	// template class members
	Q3CString templates;
	Q3CString cl_names;
	Q3CString templates_tmplop;
	Q3CString cl_names_tmplop;
	
	spec(templates, cl_names, templates_tmplop, cl_names_tmplop);
	
	for (index = 0; index != sup; index += 1)
	  if (ch[index]->kind() != aNcRelation)
	    ((UmlClassItem *) ch[index])
	      ->generate_def(f_h, indent, TRUE, templates, cl_names,
			     templates_tmplop, cl_names_tmplop);
      }
      
      if (*p == '\n')
	p += 1;
    }
    else
      // strange
      f_h << *p++;
  }
  
  if (! removed)
    context.removeLast();
}
コード例 #23
0
ファイル: main.cpp プロジェクト: SciBoy/douml
int main(int argc, char ** argv)
{
  if (argc != 2)
      return 0;
  
  if (UmlCom::connect(Q3CString(argv[1]).toUInt())) {
    bool aborted = TRUE;
    
    try {
      UmlCom::trace("<b>C++ roundtrip</b> release 1.3<br>");
      UmlCom::traceAutoRaise(FALSE);
      
      char * argv = 0;
      int argc = 0;
      QApplication * app = new QApplication(argc, &argv);
      UmlItem * item = UmlCom::targetItem();
      int n;

      switch (item->kind()) {
      default:
	UmlCom::trace("<font face=helvetica><b>must be applied on a <i>package, class view, deployment view, artifact</i> or <i>class</i></b></font><br>");
	aborted = FALSE;
	throw 0;
      case aPackage:
	n = ((UmlPackage *) item)->count_roundtriped();
	break;
      case aClassView:
      case aDeploymentView:
      case anArtifact:
	n = 1;
	break;
      case aClass:
	if (item->parent()->kind() != aClassView) {
	  UmlCom::trace("<font face=helvetica><b>can't be applied on a <i>class</i> nested or out of a <i>class view</i></b></font><br>");
	  aborted = FALSE;
	  throw 0;
	}
	n = 1;
	break;
      }

      UmlPackage * project = UmlPackage::getProject();
      
      UmlCom::trace("<font face=helvetica>Upload project ...</font>");
      Package::init(project, app);
      UmlCom::trace("<font face=helvetica>...done</font><br>");
      UmlCom::message("");
      Package::set_step(0, n);
      
      UmlCom::trace("<font face=helvetica>Preparation...</font>");
      if (!item->set_roundtrip_expected() &&
	  (QMessageBox::warning(0, "Roundtrip",
				"Some elements to roundtrip are read-only and will not be updated\n\n"
				"Roundtrip anyway ?",
				"Yes", "No", QString::null, 1, 1)
	   != 0)) {
	aborted = FALSE;
	throw 0;
      }
      
      Package::set_step(0, -1);
      UmlCom::trace("<font face=helvetica>...done</font><br>");
      
      if ((item->kind() == aPackage) && !UmlArtifact::is_roundtrip_usefull()) {
	UmlCom::trace("<font face=helvetica>you don't ask for to roundtrip artifact(s)<br><br>"
		      "probably you want to do a <i>reverse</i> rather than a <i>roundtrip</i></font><br>");
	aborted = FALSE;
	throw 0;
      }
	
      Q3CString f;
	
      if (project->propertyValue("#file", f))
	Lex::defines(f);
	         
      n = 0;
      item->scan_it(n);
      CppSettings::set_UseDefaults(TRUE);
      project->set_childrenVisible(FALSE);
      item->send_it(n);
      UmlOperation::force_defs();
      Statistic::produce();
      
      // umark all
      {
	Q3PtrVector<UmlItem> marked = UmlItem::markedItems();
	UmlItem ** v = marked.data();
	UmlItem ** const vsup = v + marked.size();
	
	for (;v != vsup; v += 1)
	  (*v)->set_isMarked(FALSE);
      }
      
      Q3PtrList<UmlItem> useless;
      
      item->mark_useless(useless);
      
      if (!useless.isEmpty() &&
	  (QMessageBox::warning(0, "C++ roundtrip",
				"The marked elements are useless because they don't\n"
				"correspond to something in the roundtriped files\n\n\n"
				"Delete them ?",
				"Yes", "No", QString::null, 1, 1)
	   == 0)) {
	Q3PtrListIterator<UmlItem> iter(useless);
	
	do {
	  if (iter.current()->isMarked())
	    iter.current()->deleteIt();
	} while (++iter, iter.current() != 0);
      }
      
      project->set_childrenVisible(TRUE);
      item->set_childrenVisible(TRUE); // re select it
      aborted = FALSE;
    }
    catch (...) {
    }
    
    try {
      // socket may be already closed
      if (aborted)
	UmlCom::trace("<font face=helvetica><br><b>Rountrip aborted!</b></font><br>");	
      
      UmlCom::message("");
      UmlCom::showTrace();
      UmlCom::bye((aborted) ? 1 : 0);	// application must not be deleted
    }
    catch (...) {
    }
  }
  
  UmlCom::close();	// application must not be deleted
  return 0;
}
コード例 #24
0
ファイル: UmlClass.cpp プロジェクト: SciBoy/douml
void UmlClass::generate(QTextOStream & f, Q3CString indent) {
  Q3PtrVector<UmlItem> ch = children();
  const Q3ValueList<UmlActualParameter> actuals = this->actuals();
  const unsigned sup = ch.size();
  const Q3CString & stereotype = java_stereotype();
  bool an_enum_pattern = (stereotype == "enum_pattern");
  bool an_enum = (stereotype == "enum");
  unsigned index;
  const char * p = javaDecl();
  const char * pp = 0;
  const char * sep;
  
  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 &&
	  strncmp(p, "${members}", 10) &&
	  strncmp(p, "${items}", 8) &&
	  strncmp(p, "${cases}", 8))
	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, "${public}", 9)) {
      p += 9;
      if (visibility() == PublicVisibility)
	f << "public ";
    }
    else if (!strncmp(p, "${visibility}", 13)) {
      p += 13;
      generate_visibility(f, "");
    }
    else if (!strncmp(p, "${final}", 8)) {
      p += 8;
      if (isJavaFinal())
	f << "final ";
    }
    else if (!strncmp(p, "${abstract}", 11)) {
      p += 11;
      if (isAbstract())
	f << "abstract ";
    }
    else if (! strncmp(p, "${name}", 7)) {
      p += 7;
      f << name();
      generate_formals(f);
    }
    else if (!strncmp(p, "${@}", 4)) {
      p += 4;
      if (pp != 0)
	f << "${@}";
      else if (! javaAnnotations().isEmpty()) {
	pp = p;
	p = javaAnnotations();
      }
    }
    else if (an_enum_pattern) {
      if (!strncmp(p, "${members}", 10)) {
	p += 10;
	
	int current_value = 0;
	Q3CString name = this->name();
	
	for (index = 0; index != sup; index += 1)
	  if ((ch[index]->kind() != aNcRelation) &&
	      !((UmlClassItem *) ch[index])->javaDecl().isEmpty())
	    ((UmlClassItem *) ch[index])->
	      generate_enum_pattern_item(f, current_value, name, indent);
      
	if (*p == '}')
	  f << indent;
      }
      else if (!strncmp(p, "${cases}", 8)) {
	p += 8;
	
	for (index = 0; index != sup; index += 1)
	  if ((ch[index]->kind() != aNcRelation) &&
	      !((UmlClassItem *) ch[index])->javaDecl().isEmpty())
	    ((UmlClassItem *) ch[index])->generate_enum_pattern_case(f, indent);
      }
      else
	// strange
	f << *p++;
    }
    else if (! strncmp(p, "${extends}", 10)) {
      p += 10;

      // extends
	
      sep = " extends ";
      
      for (index = 0; index != sup; index += 1) {
	UmlItem * x = ch[index];
	
	if (x->kind() == aRelation)
	  ((UmlRelation *) x)->generate_extends(sep, f, actuals, stereotype);
      }
    }
    else if (! strncmp(p, "${implements}", 13)) {
      p += 13;

      if (stereotype != "interface") {
	
	// implements
	
	sep = " implements ";
	
	for (index = 0; index != sup; index += 1) {
	  UmlItem * x = ch[index];
	  
	  if (x->kind() == aRelation)
	    ((UmlRelation *) x)->generate_implements(sep, f, actuals, stereotype);
	}
      }
    }
    else if (! strncmp(p, "${members}", 10)) {
      p += 10;
  
      // members
      
      if (an_enum) {
	for (index = 0; index != sup; index += 1) {
	  if (ch[index]->kind() != aNcRelation) {
	    UmlClassItem * it = (UmlClassItem *)ch[index];
	    
	    if (! it->javaDecl().isEmpty())
	      it->generate_enum_member(f, indent);
	  }
	}
      }
      else {
	for (index = 0; index != sup; index += 1) {
	  UmlItem * it = ch[index];
	  
	  if (it->kind() == aClass) {
	    if (! ((UmlClass *) it)->javaDecl().isEmpty()) {
	      ((UmlClass *) it)->generate(f, indent + "  ");
	      f << '\n';
	    }
	  }
	  else if ((it->kind() != aNcRelation) &&
		   !((UmlClassItem *) it)->javaDecl().isEmpty())
	    ((UmlClassItem *) it)->generate(f, stereotype, indent);
	}
      }
      
      if (*p == '}')
	f << indent;
    }
    else if (an_enum && ! strncmp(p, "${items}", 8)) {
      p += 8;
  
      // enums items
      
      BooL first = TRUE;
      
      for (index = 0; index != sup; index += 1) {
	if (ch[index]->kind() != aNcRelation) {
	  UmlClassItem * it = (UmlClassItem *)ch[index];
	  
	  if (! it->javaDecl().isEmpty())
	    it->generate_enum_item(f, indent, first);
	}
      }
      
      if (*p == '}')
	f << indent;
    }
    else
      // strange
      f << *p++;
  }
}
コード例 #25
0
ファイル: UmlTransition.cpp プロジェクト: bleakxanadu/douml
void UmlTransition::generate(UmlClass * machine, UmlClass * anystate, UmlState * state)
{
    if (_already_managed)
        return;

    Q3CString s = triggerName();

    // group transitions having the same trigger
    const Q3PtrVector<UmlItem> ch = parent()->children();
    unsigned index = ch.findRef(this);
    Q3PtrList<UmlTransition> trs;
    UmlTransition * tr_no_guard = 0;

    if (cppGuard().isEmpty())
        tr_no_guard = this;
    else
        trs.append(this);

    while (++index != ch.count()) {
        if ((ch[index]->kind() == aTransition) &&
            (((UmlTransition *) ch[index])->triggerName() == s)) {
            if (!((UmlTransition *) ch[index])->cppGuard().isEmpty())
                trs.append((UmlTransition *) ch[index]);
            else if (tr_no_guard != 0) {
                UmlCom::trace("Error : several transitions from '" + parent()->name()
                              + "' don't have guard");
                throw 0;
            }
            else
                tr_no_guard = (UmlTransition *) ch[index];

            ((UmlTransition *) ch[index])->_already_managed = TRUE;
        }
    }

    if (tr_no_guard != 0)
        // place it at end
        trs.append(tr_no_guard);

    // made the trigger

    UmlOperation * trg = state->assocClass()->trigger(s, machine, anystate);
    Q3CString body;

    if (s == "create") {
        // manage entry
        if (!state->cppEntryBehavior().isEmpty())
            body = "  _doentry(stm);\n";
    }

    if (!state->cppDoActivity().isEmpty())
        // state do activity before each event except create
        body += "  _do(stm);\n";

    bool completion = (s == "_completion");

    if (!completion && state->isLeaf() && state->hasCompletion())
        // manage completion
        body += "  if (_completion(stm)) return;\n";

    UmlTransition::generate(trs, machine, anystate, state,
                            body, "  ", completion);

    trg->set_CppBody(body);
}
コード例 #26
0
void UmlDecisionActivityNode::solve_output_flows() {
  // input and outputs flows must be control/data
  // except a possible decision input being data
  ControlOrData k = Unset;

  // look at output flows
  const Q3PtrVector<UmlItem> ch = children();
  unsigned n = ch.size();
  unsigned i;
  
  for (i = 0; i != n; i += 1) {
    UmlFlow * f = dynamic_cast<UmlFlow *>(ch[i]);

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

  if (k == Unset) {
    bool already = FALSE;

    for (;;) {
      // look at input flows
      int ndata = 0;
      bool hascontrol = FALSE;
      bool hasunset = FALSE;
      Q3PtrListIterator<UmlFlow> it(_incoming_flows);

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

	if (k == IsControl) {
	  hascontrol = TRUE;
	  break;
	}
	else if (k == IsData) {
	  if (++ndata == 2)
	    // more than a single decision input
	    break;
	}
	else
	  hasunset = TRUE;

	++it;
      }

      if (hascontrol) {
	// already has k = IsControl;
	break;
      }
      else if ((ndata == 2) || ((ndata == 1) && !hasunset)) {
	k = IsData;
	break;
      }
      else if (already || !hasunset) {
	// not possible to know, force control
	k = IsControl;
	break;
      }

      already = TRUE;

      // solve input flows
      it.toFirst();
      while (it.current() != 0) {
	((UmlActivityNode *) it.current()->parent())->solve_output_flows();
	++it;
      }
    }
  }

  // propagate
  for (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);
  }

  Q3PtrListIterator<UmlFlow> it(_incoming_flows);

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

    ++it;
  }

}
コード例 #27
0
ファイル: UmlPackage.cpp プロジェクト: SciBoy/douml
void UmlPackage::generate() {
  Q3PtrVector<UmlItem> ch = UmlItem::children();
  
  for (unsigned index = 0; index != ch.size(); index += 1)
    ch[index]->generate();
}
コード例 #28
0
ファイル: UmlPackage.cpp プロジェクト: SciBoy/douml
UmlClassView * UmlPackage::get_classview(const Q3CString & nmsp) {
  UmlPackage * pack;
  
  if (nmsp != cppNamespace()) {
    if (namespace_fixedp) {
      if ((pack = findCppNamespace(nmsp)) == 0) {
	Q3CString s = nmsp;
	
	if (s.isEmpty())
	  s = name();
	else {
	  int index = 0;
	  
	  while ((index = s.find("::", index)) != -1)
	    s.replace(index++, 2, " ");
	}
	
	if (((pack = UmlBasePackage::create(this, s)) == 0) &&
	    ((pack = UmlBasePackage::create(this, s += "_")) == 0) &&
	    ((pack = UmlBasePackage::create(this, s += "_")) == 0) &&
	    ((pack = UmlBasePackage::create(this, s += "_")) == 0) &&
	    ((pack = UmlBasePackage::create(this, s += "_")) == 0)) {
#ifdef REVERSE
	  UmlCom::trace(Q3CString("<font face=helvetica><b>cannot create package <i>")
			+ s + "</i> under package <i>"
			+ name() + "</b></font><br>");
	  UmlCom::message("");
	  throw 0;
#else
	  QMessageBox::critical(0, "Fatal Error", 
				Q3CString("<font face=helvetica><b>cannot create package <i>")
				+ s + "</i> under package <i>"
				+ Name() + "</b></font><br>");
	  QApplication::exit(1);
#endif	  
	}
	
	pack->set_CppNamespace(nmsp);
	pack->set_CppSrcDir(cppSrcDir());
	pack->set_CppHDir(cppHDir());
	pack->namespace_fixedp = TRUE;
      }
    }
    else {
      pack = this;
      pack->set_CppNamespace(nmsp);
      pack->namespace_fixedp = TRUE;
    }
  }
  else
    pack = this;
  
  if (pack->class_view == 0) {
    Q3PtrVector<UmlItem> ch = pack->children();
    
    for (unsigned index = 0; index != ch.size(); index += 1)
      // return the first class view find
      if (ch[index]->kind() == aClassView)
	return pack->class_view = (UmlClassView *) ch[index];
    
    if ((pack->class_view = UmlBaseClassView::create(pack, name())) == 0) {
#ifdef REVERSE
      UmlCom::trace(Q3CString("<font face=helvetica><b>cannot create class view <i>")
		    + name() + "</i> under package <i>"
		    + pack->name() + "</b></font><br>");
      UmlCom::message("");
      throw 0;
#else
      QMessageBox::critical(0, "Fatal Error", 
			    Q3CString("<font face=helvetica><b>cannot create class view <i>")
			    + name() + "</i> under package <i>"
			    + pack->name() + "</b></font><br>");
      QApplication::exit(1);
#endif
    }
  }
  
  return pack->class_view;
}
コード例 #29
0
void UmlCollaborationMessage::write(FileOut & out, UmlItem * diagram, const Q3PtrVector< UmlCollaborationMessage > & msgs, unsigned & index)
{
  unsigned sup = msgs.size();
  UmlPackage * prj = UmlPackage::getProject();
  
  while (index != sup) {
    const UmlCollaborationMessage * msg = msgs[index++];
    Q3CString pfix = msg->hrank() + ".";
    unsigned pfixlen = pfix.length();
    
#define MSG  "MSG", msg->itsrank
#define SEND "MSGOCCSPECSEND", msg->itsrank
#define REC  "MSGOCCSPECREC", msg->itsrank
#define BEH  "BEHEXECSPEC", msg->itsrank
#define EXEC "EXECOCCSPEC", msg->itsrank
    
    out.indent();
    out << "<fragment xmi:type=\"uml:MessageOccurrenceSpecification\"";
    out.id_prefix(diagram, SEND);
    out.ref(diagram, "covered", msg->from()->lifeline());
    out.ref(prj, "event", 
	    (msg->operation() != 0) ? msg->operation()->event(FALSE)
				    : UmlOperation::event("SEND", msg->form()));
    out.ref(diagram, "message", MSG);
    out << "/>\n";
    
    out.indent();
    out << "<message xmi:type=\"uml:Message\"";
    out.id_prefix(diagram, MSG);
    out << " name=\"";
    out.quote((const char*)((msg->operation() != 0) ? msg->operation()->name()
				      : msg->form()));//[jasa] ambiguous call
    out << '"';
    out.ref(diagram, "sendEvent", SEND);
    out.ref(diagram, "receiveEvent", REC);
    out.ref(diagram, "connector", msg->from()->connector(msg->to()));
    out << "/>\n";
    
    out.indent();
    out << "<fragment xmi:type=\"uml:MessageOccurrenceSpecification\"";
    out.id_prefix(diagram, REC);
    out.ref(diagram, "covered", msg->to()->lifeline());
    out.ref(prj, "event", 
	    (msg->operation() != 0) ? msg->operation()->event(TRUE)
				    : UmlOperation::event("REC", msg->form()));
    out.ref(diagram, "message", MSG);
    out << "/>\n";
    
    out.indent();
    out << "<fragment xmi:type=\"uml:BehaviorExecutionSpecification\"";
    out.id_prefix(diagram, BEH);
    out.ref(diagram, "covered", msg->to()->lifeline());
    out.ref(diagram, "start", REC);
    out.ref(diagram, "finish", EXEC);
    out << "/>\n";
    
    if (index != sup) {
      Q3CString pfix2 = msgs[index]->hrank() + ".";
      
      if ((pfix2.length() > pfixlen) && !strncmp(pfix, pfix2, pfixlen))
	write(out, diagram, msgs, index);
    }
    
    out.indent();
    out << "<fragment xmi:type=\"uml:ExecutionOccurrenceSpecification\"";
    out.id_prefix(diagram, EXEC);
    out.ref(diagram, "covered", msg->to()->lifeline());
    out.ref(prj, "event", 
	    UmlOperation::event("EXEC",
				(msg->operation() != 0) ? msg->operation()->name()
							: msg->form()));
    out.ref(diagram, "execution", BEH);
    out << "/>\n";
  }
}
コード例 #30
0
ファイル: UmlClass.cpp プロジェクト: SciBoy/douml
void UmlClass::compute_dependency(Q3PtrList<CppRefType> & dependencies,
				  const Q3CString &, bool all_in_h) {
  Q3PtrVector<UmlItem> ch = children();
  const Q3CString stereotype = cpp_stereotype();
  bool a_typedef = (stereotype == "typedef");
  bool an_enum = (stereotype == "enum");
  const Q3ValueList<UmlFormalParameter> formals = this->formals();
  const Q3ValueList<UmlActualParameter> actuals = this->actuals();  
  
  if (!formals.isEmpty())
    // template class, force depend in h
    all_in_h = TRUE;
  
  for (unsigned index = 0; index != ch.size(); index += 1) {
    if (ch[index]->kind() != aNcRelation) {
      UmlClassItem * it = (UmlClassItem *) ch[index];
      
      if (! it->cppDecl().isEmpty())
	it->compute_dependency(dependencies, stereotype, all_in_h);
    }
  }
  
  if (an_enum && (!formals.isEmpty() || !actuals.isEmpty())) {
    write_trace_header();
    UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b><i>template enum</i></b></font><br>");
    incr_warning();
  }
  else if (a_typedef && !formals.isEmpty()) {
    write_trace_header();
    UmlCom::trace("&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\"><b><i>template typedef</i></b></font><br>");
    incr_warning();
  }
  else {
    Q3ValueList<UmlFormalParameter>::ConstIterator itf;
    
    for (itf = formals.begin(); itf != formals.end(); ++itf)
      CppRefType::remove((*itf).name(), dependencies);
  
    Q3ValueList<UmlActualParameter>::ConstIterator ita;
    
    for (ita = actuals.begin(); ita != actuals.end(); ++ita)
      UmlClassMember::compute_dependency(dependencies, "${type}",
					 (*ita).value(), all_in_h);
    
    if (a_typedef) {
      Q3CString decl = cppDecl();
      int index;
      
      remove_comments(decl);
      if ((index = decl.find("${name}")) != -1)
	decl.remove((unsigned) index, 7);
      replace_alias(decl);

      UmlClassMember::compute_dependency(dependencies, decl,
					 baseType(), all_in_h);
    }
  }
  
  if ((associatedArtifact() == 0) ||
      (associatedArtifact()->associatedClasses().count() == 1))
    CppRefType::remove(this, dependencies);
  else
    CppRefType::force_ref(this, dependencies);
}