void UmlJoinActivityNode::solve_output_flows() {
  // output is data if at least one input is data
  ControlOrData k = Unset;
  const Q3PtrVector<UmlItem> ch = children();
  unsigned n = ch.size(); // theo 1

  if (n == 0)
    return;

  UmlFlow * f = (UmlFlow *) ch[0];

  // look at input flows
  Q3PtrListIterator<UmlFlow> it(_incoming_flows);

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

    if (k == Unset) {
      ((UmlActivityNode *) it.current()->parent())->solve_output_flows();
      k = it.current()->control_or_data();
    }

    if (k == IsData)
      break;

    ++it;
  }

  f->set_control_or_data((k == IsData) ? IsData : IsControl);
}
void UmlInitialActivityNode::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))
      f->set_control_or_data(IsControl);
  }

}
Esempio n. 3
0
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);
    }
  }

}
Esempio n. 4
0
void UmlActivityObject::solve_output_flows() {
  ControlOrData v = (isControlType()) ? IsControl : IsData;
  const QVector<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))
      f->set_control_or_data(v);
  }

  QListIterator<UmlFlow> it(_incoming_flows);
  
  while (it.current() != 0) {
    if (it.current()->control_or_data() == Unset)
      it.current()->set_control_or_data(v);

    ++it;
  }
}
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;
  }

}
void UmlForkActivityNode::solve_output_flows() {
  // input and outputs flows must be control/data

  UmlFlow * f;
  ControlOrData k;
  const Q3PtrVector<UmlItem> ch = children();
  unsigned n = ch.size();

  if (!_incoming_flows.isEmpty()) {
    f = _incoming_flows.getFirst();
    k = f->control_or_data();
  }
  else {
    f = 0;
    k = Unset;
  }

  if (k == Unset) {
    // look at output flows
    for (unsigned i = 0; i != n; i += 1) {
      UmlFlow * f = dynamic_cast<UmlFlow *>(ch[i]);

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

    if (f != 0) {
      // f is unset
      if (k != Unset) {
	if (f->control_or_data() == Unset)
	  // propagate on input
	  f->set_control_or_data(k);
      }
      else {
	// solve input flow
	((UmlActivityNode *) f->parent())->solve_output_flows();
	k = f->control_or_data();
	if (k == Unset)
	  // not possible to know, force control
	  k = IsControl;
	// propagate on input
	f->set_control_or_data(k);
      }
    }
  }

  // propagate on output
  for (unsigned 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);
  }
}
Esempio n. 7
0
void UmlFlow::solveThem()
{
  QValueList<Flow>::Iterator iter;
  
  for (iter = All.begin(); iter != All.end(); ++iter) {
    Flow & flow = *iter;
    
    QMap<QCString, UmlItem*>::Iterator isrc = UmlItem::All.find(flow.source);
    QMap<QCString, UmlItem*>::Iterator itgt = UmlItem::All.find(flow.target);
    
    if ((isrc == UmlItem::All.end()) && 
	((isrc = Outgoings.find(flow.id)) == Outgoings.end())) {
      if (!FileIn::isBypassedId(flow.source))
	UmlCom::trace("flow '" + flow.id + "' : unknown source reference '" + flow.source + "'<br>");
    }
    else if ((itgt == UmlItem::All.end()) && 
	     ((itgt = Incomings.find(flow.id)) == Incomings.end())) {
      if (!FileIn::isBypassedId(flow.target))
	UmlCom::trace("flow '" + flow.id + "' : unknown target reference '" + flow.target + "'<br>");
    }
    else {
      UmlActivityNode * src = dynamic_cast<UmlActivityNode*>(*isrc);
      UmlActivityNode * tgt = dynamic_cast<UmlActivityNode*>(*itgt);
    
      if (src == 0)
	UmlCom::trace("'" + flow.source + "' is not an activity node<br>");
      else if (tgt == 0)
	UmlCom::trace("'" + flow.target + "' is not an activity node<br>");
      else {
	UmlFlow * f = UmlFlow::create(src, tgt);
	
	if (f == 0)
	  UmlCom::trace("cannot create flow '" + flow.id + "'<br>");
	else {
	  UmlItem::All.insert(flow.id, f);
	  
	  if (! flow.name.isEmpty())
	    f->set_Name(flow.name);
	  if (flow.interrupt)
	    f->set_Stereotype("interrupt");
	  if (! flow.selection.isEmpty()) {
	    QMap<QCString, QCString>::Iterator iter =
	      OpaqueDefs.find(flow.selection);
	    
	    if (iter == OpaqueDefs.end()) {
	      if (!FileIn::isBypassedId(flow.selection))
		UmlCom::trace("flow '" + flow.id + "' : unknown selection reference '" + flow.selection + "'<br>");
	    }
	    else
	      f->set_Selection(*iter);
	  }
	  if (! flow.transformation.isEmpty()) {
	    QMap<QCString, QCString>::Iterator iter =
	      OpaqueDefs.find(flow.transformation);
	    
	    if (iter == OpaqueDefs.end()) {
	      if (!FileIn::isBypassedId(flow.transformation))
		UmlCom::trace("flow '" + flow.id + "' : unknown transformation reference '" + flow.transformation + "'<br>");
	    }
	    else
	      f->set_Transformation(*iter);
	  }
	  if (! flow.weight.isEmpty())
	    f->set_Weight(flow.weight);
	  
	  if (! flow.guard.isEmpty())
	    f->set_Guard(flow.guard);
	  
	  f->unload(FALSE, FALSE);
	}
      }
    }
  }

  All.clear();
}