Beispiel #1
0
void UmlClass::importInstantiate(File & f) {
  if (scanning) {
    f.skipNextForm();
    return;
  }

  f.read("(");
  f.read("object");
  f.read("Instantiation_Relationship");

  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 == "quidu")
	break;
      f.skipNextForm();
      k = f.read(s2);
    }
    else
      f.syntaxError(s2);
  }
  
  if (f.read(s2) != STRING)
    f.syntaxError(s2, "quidu value");
  
  UmlClass * target = (UmlClass *) findItem(s2, aClass);
  
  if (target != 0) {
    UmlRelation * r = UmlRelation::create(aRealization, this, target);
    
    if (r == 0)
      UmlCom::trace("<br>cannot create aRealization from '" +
		    fullName() + "' to '" + target->fullName() + "'");
    else {
      newItem(r, id);
      if (!ste.isEmpty())
	r->set_Stereotype(ste);
      if (!doc.isEmpty())
	r->set_Description(doc);
      r->setProperties(prop);
    }
  }
  
  f.skipBlock();
}
Beispiel #2
0
void UmlClass::importRelations(File & f) {
  Q3CString s;
  
  f.read("(");
  f.read("list");
  if (f.read(s) != ATOM)
    f.syntaxError(s, "an atom");
  
  for (;;) {
    switch (f.read(s)) {
    case ')':
      return;
    case '(':
      break;
    default:
      f.syntaxError(s);
    }
    
    f.read("object");
    
    if (f.read(s) != ATOM)
      f.syntaxError(s, "an atom");
    
    aRelationKind rk;
    Q3CString sr;
    
    if (s == "Uses_Relationship") {
      rk = aDependency;
      sr = "dependency";
    }
    else if (s == "Inheritance_Relationship") {
      rk = aGeneralisation;
      sr = "generalisation";
    }
    else if (s == "Realize_Relationship") {
      rk = aRealization;
      sr = "realization";
    }
    else {
      f.skipBlock();
      continue;
    }
    
    // dependency or generalisation
    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());
    
    Q3CString target_id;
    aVisibility visibility = PublicVisibility;
    bool virtual_inheritance = FALSE;
    bool a_friend = FALSE;
    
    for (;;) {
      if (k == ATOM) {
	if (s2 == "quidu") {
	  if (f.read(target_id) != STRING)
	    f.syntaxError(target_id, "quidu value");
	}
	else if (s2 == "exportControl")
	  visibility = f.readVisibility();
	else if (s2 == "virtual")
	  virtual_inheritance = f.readBool();
	else if (s2 == "friend")
	  a_friend = f.readBool();
	else
	  f.skipNextForm();
	k = f.read(s2);
      }
      else if (k == ')')
	break;
      else
	f.syntaxError(s2);
    }
    
    if (target_id.isEmpty())
      f.syntaxError("quidu missing");
    
    UmlClass * target = (UmlClass *) findItem(target_id, aClass);
    
    if (target != 0) {
      UmlRelation * r;
      
      if (a_friend) {
	if ((r = UmlRelation::create(rk, target, this)) == 0) {
	  UmlCom::trace("<br>cannot create " + sr + " from '" +
			target->fullName() + "' to '" + fullName() + "'");
	  f.skipBlock();
	  return;
	}
	r->set_Stereotype("friend");
      }
      else {
	if ((r = UmlRelation::create(rk, this, target)) == 0) {
	  UmlCom::trace("<br>cannot create " + sr + " from '" +
			fullName() + "' to '" + target->fullName() + "'");
	  f.skipBlock();
	  return;
	}

	if (!ste.isEmpty())
	  r->set_Stereotype(ste);
	if (visibility != PublicVisibility)
	  r->set_Visibility(visibility);
	if (virtual_inheritance)
	  r->set_CppVirtualInheritance(TRUE);
      }
      
      newItem(r, id);
      if (!doc.isEmpty())
	r->set_Description(doc);
      r->setProperties(prop);
    }
  }
}