예제 #1
0
파일: UmlState.cpp 프로젝트: SciBoy/douml
void UmlState::html(Q3CString pfix, unsigned int rank, unsigned int level) {
  define();

  chapter((parent()->kind() == aClassView)
	  ? "StateMachine" : "State",
	  pfix, rank, "state", level);

  Q3CString s = description();
  
  if (!s.isEmpty()) {
    fw.write("<p>");
    writeq(description());
    fw.write("<br /></p>");
  }

  UmlState * ref = reference();
  
  if (ref != 0) {
    fw.write("<p>References ");
    ref->write();
    fw.write("</p>");
  }
  else {
    if (isActive())
      fw.write("<p>Active state</p>\n");
    
    UmlOperation * beh = specification();
    
    if (beh != 0) {
      fw.write("<p>Implements ");
      beh->write();
      fw.write("</p>");
    }
    
    Q3CString scpp, sjava;
    
    s = entryBehavior();
    scpp = cppEntryBehavior();
    sjava = javaEntryBehavior();
    
    if (!s.isEmpty() || !scpp.isEmpty() || !sjava.isEmpty()) {
      fw.write("<p>Entry Behavior :</p><ul>");
      
      if (!s.isEmpty()) {
	fw.write("<li>OCL : <pre>\n");
	writeq(s);
	fw.write("</pre></li>");
      }
      
      if (!scpp.isEmpty()) {
	fw.write("<li>C++ : <pre>\n");
	writeq(scpp);
	fw.write("</pre></li>");
      }
      
      if (!sjava.isEmpty()) {
	fw.write("<li>Java : <pre>\n");
	writeq(sjava);
	fw.write("</pre></li>");
      }
      
      fw.write("</ul>");
    }
    
    s = exitBehavior();
    scpp = cppExitBehavior();
    sjava = javaExitBehavior();
    
    if (!s.isEmpty() || !scpp.isEmpty() || !sjava.isEmpty()) {
      fw.write("<p>Exit Behavior :</p><ul>");
      
      if (!s.isEmpty()) {
	fw.write("<li>OCL : <pre>\n");
	writeq(s);
	fw.write("</pre></li>");
      }
      
      if (!scpp.isEmpty()) {
	fw.write("<li>C++ : <pre>\n");
	writeq(scpp);
	fw.write("</pre></li>");
      }
      
      if (!sjava.isEmpty()) {
	fw.write("<li>Java : <pre>\n");
	writeq(sjava);
	fw.write("</pre></li>");
      }
      
      fw.write("</ul>");
    }
    
    s = doActivity();
    scpp = cppDoActivity();
    sjava = javaDoActivity();
    
    if (!s.isEmpty() || !scpp.isEmpty() || !sjava.isEmpty()) {
      fw.write("<p>Do activity :</p><ul>");
      
      if (!s.isEmpty()) {
	fw.write("<li>OCL : <pre>\n");
	writeq(s);
	fw.write("</pre></li>");
      }
      
      if (!scpp.isEmpty()) {
	fw.write("<li>C++ : <pre>\n");
	writeq(scpp);
	fw.write("</pre></li>");
      }
      
      if (!sjava.isEmpty()) {
	fw.write("<li>Java : <pre>\n");
	writeq(sjava);
	fw.write("</pre></li>");
      }
      
      fw.write("</ul>");
    }
  }
  
  UmlStateDiagram * d = associatedDiagram();
  
  if (d != 0) {
    fw.write("<p>Diagram : ");
    d->write();
    fw.write("</p>");
  }

  write_properties();

  write_children(pfix, rank, level);

  unload(FALSE, FALSE);
}
예제 #2
0
void UmlState::write(FileOut & out) {
  anItemKind pkind = parent()->kind();
  bool mach = (pkind != aState) && (pkind != aRegion);
  UmlState * ref = reference();
  const char * k;
  
  if (mach) {
    k = (_uml_20) ? "ownedMember" : "packagedElement";
    memo_incoming_trans();
  }
  else
    k = "subvertex";
  
  out.indent(); 
  out << "<" << k << " xmi:type=\"uml:"
    << ((mach || (stereotype() == "machine")) ? "StateMachine" : "State")
    << '"';
  out.id(this); 
  out << " name=\"";
  out.quote(name());
  out << '"';
  if (ref != 0)
    out.ref(ref, "submachine");
  else {
    if (specification() != 0)
      out.ref(specification(), "specification");
    if (isActive())
      out << " isActive=\"true\"";
  }
  out << ">\n";
  out.indent(+1); 
  
  write_description_properties(out); 
  
  if (ref == 0) {
    QCString doentry;
    QCString doactivity;
    QCString doexit;
    
    switch (_lang) {
    case Uml:
      doentry = entryBehavior();
      doactivity = doActivity();
      doexit = exitBehavior();
      break;
    case Cpp:
      doentry = cppEntryBehavior();
      doactivity = cppDoActivity();
      doexit = cppExitBehavior();
      break;
    default: // Java
      doentry = javaEntryBehavior();
      doactivity = javaDoActivity();
      doexit = javaExitBehavior();
      break;
    }
    
    if (! doentry.isEmpty()) {
      out.indent();
      out << "<entry xmi:type=\"uml:Activity\"";
      out.id_prefix(this, "ENTRY_");
      out << ">\n";
      out.indent();
      out << "\t<body>";
      out.quote(doentry);
      out << "</body>\n";
      out.indent();
      out << "</entry>\n";
    }
    
    if (! doactivity.isEmpty()) {
      out.indent();
      out << "<doActivity xmi:type=\"uml:Activity\"";
      out.id_prefix(this, "DOACTIVITY_");
      out << ">\n";
      out.indent();
      out << "\t<body>";
      out.quote(doactivity);
      out << "</body>\n";
      out.indent();
      out << "</doActivity>\n";
    }
    
    if (! doexit.isEmpty()) {
      out.indent();
      out << "<exit xmi:type=\"uml:Activity\"";
      out.id_prefix(this, "EXIT_");
      out << ">\n";
      out.indent();
      out << "\t<body>";
      out.quote(doexit);
      out << "</body>\n";
      out.indent();
      out << "</exit>\n";
    }
  }
  
  while (! _incoming_trans.isEmpty())
    _incoming_trans.take(0)->write_in(out);
  
  const QVector<UmlItem> ch = children(); 
  unsigned n = ch.size();
  unsigned i;
  bool need_region = FALSE;
     
  for (i = 0; i != n; i += 1) {
    if (ch[i]->kind() != aRegion) {
      need_region = TRUE;
      break;
    }
  }

  if (need_region) {
    if (ref == 0) {
      out.indent();
      out << "<region xmi:type=\"uml:Region\"";
      out.id_prefix(this, "IMPLICIT_REGION_");
      out << " name=\"Bouml_Implicit_Region\">\n";
      out.indent(+1);
    }
    
    for (i = 0; i != n; i += 1)
      if (ch[i]->kind() != aRegion)
	ch[i]->write(out);
    
#if 0
    // to bypass Eclipse's bug
    while (! _trans.isEmpty())
      _trans.take(0)->write_it(out);
#endif
    
    if (ref == 0) {
      out.indent(-1);
      out.indent();
      out << "</region>\n";
    }
  }

  if (ref == 0) {
    for (i = 0; i != n; i += 1)
      if (ch[i]->kind() == aRegion)
	ch[i]->write(out);
  }
       
#if 1
    // to bypass Eclipse's bug
    while (! _trans.isEmpty())
      _trans.take(0)->write_it(out);
#endif
    
  out.indent(-1); 
  out.indent(); 
  out << "</" << k << ">\n"; 
    
  unload(); 
}