Exemple #1
0
void printTexTable(const StateMachine& sm, ostream& out)
{
  const Transition* trans_ptr;
  int stateIndex, eventIndex;
  string actions;
  string nextState;

  out << "%& latex" << endl;
  out << "\\documentclass[12pt]{article}" << endl;
  out << "\\usepackage{graphics}" << endl;
  out << "\\begin{document}" << endl;
  //  out << "{\\large" << endl;
  out << "\\begin{tabular}{|l||";
  for(eventIndex=0; eventIndex < sm.numEvents(); eventIndex++) {
    out << "l";
  }
  out << "|} \\hline" << endl;

  for(eventIndex=0; eventIndex < sm.numEvents(); eventIndex++) {
    out << " & \\rotatebox{90}{";
    out << sm.getEvent(eventIndex).getShorthand();
    out << "}";
  }
  out << "\\\\ \\hline  \\hline" << endl;

  for(stateIndex=0; stateIndex < sm.numStates(); stateIndex++) {
    out << sm.getState(stateIndex).getShorthand();
    for(eventIndex=0; eventIndex < sm.numEvents(); eventIndex++) {
      out << " & ";
      trans_ptr = sm.getTransPtr(stateIndex, eventIndex);
      if (trans_ptr == NULL) {
      } else {
        actions = trans_ptr->getActionShorthands();
        // FIXME: should compare index, not the string
        if (trans_ptr->getNextStateShorthand() != 
            sm.getState(stateIndex).getShorthand() ) { 
          nextState = trans_ptr->getNextStateShorthand();
        } else {
          nextState = "";
        }

        out << actions;
        if ((nextState.length() != 0) && (actions.length() != 0)) {
          out << "/";
        }
        out << nextState;
      }
    }
    out << "\\\\" << endl;
  }
  out << "\\hline" << endl;
  out << "\\end{tabular}" << endl;
  //  out << "}" << endl;
  out << "\\end{document}" << endl;
}
Exemple #2
0
StateMachine::StateMachine(StateMachine& c)
{
  _currentState = c.getState();
}