Пример #1
0
void UmlPackage::applyStereotype(FileIn & in, Token & token)
{
    WrapperStr prof_st;
    Q3ValueList<WrapperStr> base_v;
    WrapperStr s;

    if (UmlClass::isAppliedStereotype(token, prof_st, base_v)) {
        WrapperStr s;
        Q3ValueList<WrapperStr>::Iterator it_ext;

        for (it_ext = base_v.begin(); it_ext != base_v.end(); ++it_ext) {
            WrapperStr s2;

            if (token.valueOf(*it_ext, s2)) {
                if (s.isEmpty())
                    s = s2;
                else if (s != s2)
                    in.warning("doesn't refer to the same element ('" + s + "' != '" + s2 + "')");
            }
        }

        if (s.isEmpty())
            in.warning("value of 'base_...' is missing");
        else {
            UmlItem * elt = All[s];

            if (elt == 0) {
                if (!FileIn::isBypassedId(s))
                    in.warning("unknown reference '" + s + "'");
            }
            else {
                elt->set_Stereotype(prof_st);
                elt->UmlItem::applyStereotype();	// set properties

                Q3Dict<WrapperStr> props = elt->properties();
                Q3DictIterator<WrapperStr> it(props);

                while (it.current()) {
                    WrapperStr k = it.currentKey().latin1();

                    if (token.valueOf(k.mid(k.findRev(':') + 1).lower(), s))
                        elt->set_PropertyValue(k, s);

                    ++it;
                }
            }
        }

        if (! token.closed())
            in.finish(token.what());
    }
    else
        in.bypass(token);

}
Пример #2
0
void UmlItem::solveGeneralizationDependencyRealization(int context, WrapperStr idref, WrapperStr label, WrapperStr)
{
    QMap<QString, UmlItem *>::Iterator it = All.find(idref);

    if (it != All.end()) {
        static const struct {
            aRelationKind rk;
            const char * err;
        } r[] = {
            { aGeneralisation, "cannot create generalization from '" },
            { aDependency, "cannot create dependency from '" },
            { aRealization, "cannot create realization from '" },
            { aDependency, "cannot create usage from '" },
            { aDependency, "cannot create import from '" }
        };
        UmlItem * target = *it;
        UmlItem * rel = UmlNcRelation::create(r[context].rk, this, target);

        if (rel == 0)
            UmlCom::trace(r[context].err + name() + "' to '" + target->name() + "'<br>");
        else {
            if (! label.isEmpty())
                rel->set_Name(label);

            switch (context) {
            case 3:
                rel->set_Stereotype("use");
                break;

            case 4:
                rel->set_Stereotype("import");
                break;

            default:
                break;
            }
        }
    }
    else if (!FileIn::isBypassedId(idref))
        UmlCom::trace("relation : unknown target reference '" + idref + "'<br>");

}
Пример #3
0
void UmlUseCase::solve(int context, Q3CString idref) {
  QMap<Q3CString, UmlItem *>::Iterator it = All.find(idref);
      
  if (it == All.end()) {
    if (!FileIn::isBypassedId(idref))
      UmlCom::trace("extend/include : unknown use case reference '" + idref + "'<br>");
  }
  else if ((*it)->kind() != anUseCase)
    UmlCom::trace("'" + idref + "' is not a use case<br>");
  else {
    UmlItem * rel = UmlNcRelation::create(aDependency, this, *it);
    
    if (rel == 0)
      UmlCom::trace("cannot create dependency from '" + name() + "' to '" + (*it)->name() + "'");
    else
      rel->set_Stereotype((context) ? "extend" : "include ");
  }
}