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;
}
Exemplo n.º 2
0
void UmlClass::importIdlConstant(UmlItem * parent, const Q3CString & id, const Q3CString & s, const Q3CString & doc, Q3Dict<Q3CString> & prop)
{
  // use a class to define the constant !
  UmlClass * x;

  if ((x = UmlClass::create(parent, legalName(s))) == 0) {
    UmlCom::trace("<br>cannot create class '" + s + "' in " +
		  parent->fullName());
    throw 0;
  }

  newItem(x, id);
  x->lang = Corba;
  x->set_Stereotype("constant");
  
  if (!doc.isEmpty())
    x->set_Description(doc);

  Q3CString type;
  Q3CString value;
  Q3CString * v;
  
  if ((v = prop.find("CORBA/ImplementationType")) != 0) {
    type = *v;
    prop.remove("CORBA/ImplementationType");
  }

  if ((v = prop.find("CORBA/ConstValue")) != 0) {
    if (!v->isEmpty())
      value = " = " + *v;
    prop.remove("CORBA/ConstValue");
  }

  Q3CString d = IdlSettings::constDecl();
  int index;
  
  if ((index = d.find("${type}")) != -1)
    d.replace(index, 7, type);
    
  if ((index = d.find("${value}")) != -1)
    d.replace(index, 8, value);
  
  x->setProperties(prop);
  x->set_IdlDecl(d);
}
Exemplo n.º 3
0
void UmlClass::importIt(FileIn & in, Token & token, UmlItem * where)
{
    where = where->container(aClass, token, in);	// can't be null

    WrapperStr s = token.valueOf("name");

    if (s.isEmpty()) {
        static unsigned n = 0;

        s.sprintf("anonymous_%u", ++n);
    }
    else
        s = legalName(s);

    UmlClass * cl = create(where, s);
    Association * assocclass = 0;
    bool stereotype = FALSE;

    if (cl == 0)
        in.error("cannot create classe '" + s +
                 "' in '" + where->name() + "'");

    cl->addItem(token.xmiId(), in);

    do
        where = where->parent();

    while (where->kind() != aPackage);

    if (where->stereotype() == "profile")
        cl->set_PropertyValue("xmiId", token.xmiId());

    if (token.xmiType() == "uml:Actor")
        cl->set_Stereotype("actor");
    else if (token.xmiType() == "uml:Interface")
        cl->set_Stereotype("interface");
    else if (token.xmiType() == "uml:Enumeration")
        cl->set_Stereotype("enum");
    else if (token.xmiType() == "uml:Stereotype") {
        cl->set_Stereotype("stereotype");
        NumberOf -= 1;
        NumberOfStereotype += 1;
        stereotype = TRUE;
    }
    else if (token.xmiType() == "uml:AssociationClass") {
        assocclass = &Association::get(token.xmiId(), token.valueOf("name"));
        assocclass->set_class_association();
    }

    cl->setVisibility(token.valueOf("visibility"));

    if (token.valueOf("isabstract") == "true")
        cl->set_isAbstract(TRUE);

    if (token.valueOf("isactive") == "true")
        cl->set_isActive(TRUE);

    if (! token.closed()) {
        WrapperStr k = token.what();
        const char * kstr = k;
        WrapperStr assocclass_ref1;
        WrapperStr assocclass_ref2;

        while (in.read(), !token.close(kstr)) {
            s = token.what();

            if ((s == "ownedtemplatesignature") &&
                ((token.xmiType() == "uml:TemplateSignature") ||
                 (token.xmiType() == "uml:RedefinableTemplateSignature")))
                cl->readFormal(in, token);
            else if ((s == "templatebinding") &&
                     (token.xmiType() == "uml:TemplateBinding")) {
                Binding::import(in, token, cl);
            }
            else if ((assocclass != 0) && (s == "memberend")) {
                if (assocclass_ref1.isEmpty())
                    assocclass_ref1 = token.xmiIdref();
                else
                    assocclass_ref2 = token.xmiIdref();

                if (! token.closed())
                    in.finish(s);
            }
            else if ((assocclass != 0) &&
                     (s == "ownedend") &&
                     (token.xmiType() == "uml:Property"))
                assocclass->import(in, token);
            else if (s == "ownedrule")
                cl->set_Constraint(UmlItem::readConstraint(in, token));
            else if (stereotype &&
                     (s == "icon") &&
                     (token.xmiType() == "uml:Image")) {
                WrapperStr path = token.valueOf("location");

                if (! path.isEmpty())
                    cl->set_PropertyValue("stereotypeIconPath", path);

                if (! token.closed())
                    in.finish(s);
            }
            else
                cl->UmlItem::import(in, token);
        }
    }

    cl->unload(TRUE, FALSE);
}
Exemplo n.º 4
0
UmlClass * UmlClass::import(File & f, UmlItem * parent, const Q3CString & knd)
{
  Q3CString s;

  if (f.read(s) != STRING)
    f.syntaxError(s, "class's name");
    
  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());

  if (ste == "CORBAConstant") {
    // not a class !
    if (!scanning) {
      if (parent->kind() == aClass)
	UmlAttribute::importIdlConstant((UmlClass *) parent, id, s, doc, prop);
      else
	importIdlConstant(parent, id, s, doc, prop);
    }
    
    if (k != ')')
      f.skipBlock();
    
    return 0;
  }

  UmlClass * cl;
  
  if (scanning) {
    if (((cl = UmlBaseClass::create(parent, s)) == 0) &&
	((cl = UmlBaseClass::create(parent, legalName(s))) == 0)) {
      UmlCom::trace("<br>cannot create class '" + s + "' in " +
		    parent->fullName());
      throw 0;
    }
    newItem(cl, id);
    
    if (!ste.isEmpty()) {
      if (ste.left(5) == "CORBA") {
	if (ste != "CORBAValue")
	  cl->set_Stereotype(ste.mid(5).lower());
      }
      else 
	cl->set_Stereotype(((ste == "Actor") || (ste == "Interface"))
			   ? ste.lower() : ste);
    }
    
    if (!doc.isEmpty())
      cl->set_Description(doc);
    
    cl->lang = None;  
  }
  else if ((cl = (UmlClass *) findItem(id, aClass)) == 0) {
    UmlCom::trace("<br>unknown class '" + s + "' in " +
		  parent->fullName());
    throw 0;
  }
  
  Q3CString art_path;
  
  for (;;) {
    switch (k) {
    case ')':
      switch (cl->lang) {
      case Cplusplus:
      case AnsiCplusplus:
      case VCplusplus:
	cl->cplusplus(prop);
	break;
      case Oracle8:
	cl->oracle8(prop);
	break;
      case Corba:
	cl->corba(prop);
	break;
      case Java:
	cl->java(prop);
	break;
      default:
	break;
      }
      
      if (!scanning) {
	cl->setProperties(prop);
	cl->unload(TRUE);
      }
      return cl;
    case ATOM:
      if (s2 == "operations")
	cl->importOperations(f);
      else if (s2 == "class_attributes")
	cl->importAttributes(f);
      else if (!scanning &&
	       ((s2 == "superclasses") ||
		(s2 == "used_nodes") ||
		(s2 == "realized_interfaces")))
	cl->importRelations(f);
      else if (s2 == "nestedClasses")
	cl->importClasses(f);
      else if (s2 == "abstract") {
	if (f.readBool())
	  cl->set_isAbstract(TRUE);
      }
      else if (s2 == "language")
	cl->lang = f.readLanguage();
      else if (s2 == "instantiation_relationship") 
	cl->importInstantiate(f);
      else if (s2 == "parameters") {
	if (knd == "Parameterized_Class")
	  cl->importFormals(f);
        else
	  cl->importActuals(f);
      }
      else if (s2 == "module") {
	if (f.read(art_path) != STRING)
	  f.syntaxError(art_path, "module's name");
      }
      else if (!scanning && (s2 == "quidu")) {
	f.read(s2);
	cl->assocArtifact(Artifact::find(s2), art_path);
      }
      else
	f.skipNextForm();
      k = f.read(s2);
      break;
    default:
      f.syntaxError(s);
    }
  }
}
Exemplo n.º 5
0
UmlClass * UmlClass::auxilarily_typedef(const WrapperStr & base
#ifdef REVERSE
                                        , bool libp
# ifdef ROUNDTRIP
                                        , bool container_roundtrip
                                        , QList<UmlItem *> & container_expected_order
# endif
#endif
                                       )
{
    WrapperStr typedef_decl = CppSettings::typedefDecl();
    const QVector<UmlItem*>& children = parent()->children();
    unsigned n = children.count();
    unsigned index;

    // a typedef with the right definition already exist ?
    for (index = 0; index != n; index += 1) {
        if (children[index]->kind() == aClass) {
            UmlClass * cl = (UmlClass *) children[index];

            if ((cl->stereotype() == "typedef") &&
                (cl->cppDecl() == typedef_decl) &&
                (cl->baseType().explicit_type == base)) {
#ifdef ROUNDTRIP
                cl->set_usefull();

                if (container_roundtrip)
                    container_expected_order.append(cl);

#endif
                return cl;
            }
        }
    }

    // must create typedef with a new name
    for (;;) {
        static unsigned nty;

        QString s("typedef%1");
        s=s.arg(QString::number(++nty));


        for (index = 0; index != n; index += 1)
            if (children[index]->name() == s)
                break;

        if (index == n) {
            UmlClass * cl = UmlClass::create(parent(), s.toLatin1().constData());

            if (cl == 0) {
#ifdef REVERSE
                UmlCom::message("");
                CppCatWindow::trace(WrapperStr("<font face=helvetica><b>cannot create class <i>")
                                    + s + "</i> under <i>"
                                    + parent()->name() + "</b></font><br>");
                throw 0;
#else
                QMessageBox::critical(0, "Fatal Error",
                                      WrapperStr("<font face=helvetica><b>cannot create class <i>")
                                      + s + "</i> under <i>"
                                      + parent()->name() + "</b></font><br>");
                QApplication::exit(1);
#endif
            }

            UmlTypeSpec typespec;

            typespec.explicit_type = base;
            cl->set_Stereotype("typedef");
            cl->set_BaseType(typespec);
            cl->set_CppDecl(typedef_decl);
#ifdef REVERSE

            if (!libp)
                cl->need_artifact(Namespace::current());

# ifdef ROUNDTRIP

            if (container_roundtrip)
                container_expected_order.append(cl);

# endif
#endif

            return cl;
        }
    }
}