⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smctablegenerator.java

📁 SMC takes a state machine stored in a .sm file and generates a State pattern in twelve programming l
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        return;    } // end of visit(SmcMap)    public void visit(SmcState state)    {        List<SmcAction> actions;        // Output the row data. This consists of:        // + the state name.        // + the state entry actions.        // + the state exit actions.        // + Each of the transtions.        _source.println("        <td>");        _source.print("          ");        _source.println(state.getInstanceName());        _source.println("        </td>");        _source.println("        <td>");        actions = state.getEntryActions();        if (actions != null && actions.isEmpty() == false)        {            _source.println("          <pre>");            for (SmcAction action: actions)            {                action.accept(this);            }            _source.println("          </pre>");        }        _source.println("        </td>");        _source.println("        <td>");        actions = state.getExitActions();        if (actions != null && actions.isEmpty() == false)        {            _source.println("          <pre>");            for (SmcAction action: actions)            {                action.accept(this);            }            _source.println("          </pre>");        }        _source.println("        </td>");        // Note: SmcMap generates our transitions for us in order        //       to guarantee correct transition ordering.        return;    } // end of visit(SmcState)    public void visit(SmcTransition transition)    {        for (SmcGuard guard: transition.getGuards())        {            _source.println();            guard.accept(this);        }        return;    }    public void visit(SmcGuard guard)    {        SmcTransition transition = guard.getTransition();        SmcState state = transition.getState();        SmcMap map = state.getMap();        String mapName = map.getName();        String stateName = state.getClassName();        int transType = guard.getTransType();        String condition = guard.getCondition();        String endStateName = guard.getEndState();        List<SmcAction> actions = guard.getActions();        // Print out the guard (if there is one).        if (condition.length() > 0)        {            _source.print('[');            _source.print(condition);            _source.println(']');        }        // If this is a pop transition, then print        // out the pop transition and any arguments.        if (transType == Smc.TRANS_POP)        {            _source.print("  pop(");            // Is there a pop transition?            if (endStateName.equals(NIL_STATE) == false &&                endStateName.length() > 0)            {                String popArgs = guard.getPopArgs();                _source.print(endStateName);                // Output any and all pop arguments.                if (popArgs.length() > 0)                {                    _source.print(", ");                    _source.print(popArgs.trim());                }            }            _source.println(")");        }        else if (transType == Smc.TRANS_PUSH)        {            _source.print("  push(");            // If the end state is nil, then replace it with the            // current map and state.            if (endStateName.equals(NIL_STATE) == true)            {                _source.print(mapName);                _source.print("::");                _source.print(stateName);            }            else            {                _source.print(endStateName);            }            _source.println(")");        }        // Else this is a plain, old transition.        else        {            // Print out the end state.            _source.print("  ");            // If the end state is nil, then replace it with the            // current state's read name.            if (endStateName.equals(NIL_STATE) == true)            {                _source.println(stateName);            }            else            {                _source.println(endStateName);            }        }        // Print out the actions (if there are any). Otherwise        // output empty braces.        if (actions.size() == 0)        {            _source.println("  {}");        }        else        {            _source.println("  {");            _indent = "    ";            for (SmcAction action: actions)            {                action.accept(this);            }            _source.println("  }");        }        return;    } // end of visit(SmcGuard)    public void visit(SmcAction action)    {        Iterator<String> it;        String sep;        _source.print(_indent);        _source.print(action.getName());        _source.print("(");        for (it = action.getArguments().iterator(), sep = "";             it.hasNext() == true;             sep = ", ")        {            _source.print(sep);            _source.print((it.next()).trim());        }        _source.println(");");        return;    } // end of visit(SmcAction)    public void visit(SmcParameter parameter)    {        _source.print(parameter.getType());        return;    } // end of visit(SmcParameter)//---------------------------------------------------------------// Member data//} // end of class SmcTableGenerator//// CHANGE LOG// $Log: SmcTableGenerator.java,v $// Revision 1.6  2008/03/21 14:03:17  fperrad// refactor : move from the main file Smc.java to each language generator the following data ://  - the default file name suffix,//  - the file name format for the generated SMC files//// Revision 1.5  2007/02/21 13:56:51  cwrapp// Moved Java code to release 1.5.0//// Revision 1.4  2007/01/15 00:23:52  cwrapp// Release 4.4.0 initial commit.//// Revision 1.3  2006/09/16 15:04:29  cwrapp// Initial v. 4.3.3 check-in.//// Revision 1.2  2005/11/07 19:34:54  cwrapp// Changes in release 4.3.0:// New features://// + Added -reflect option for Java, C#, VB.Net and Tcl code//   generation. When used, allows applications to query a state//   about its supported transitions. Returns a list of transition//   names. This feature is useful to GUI developers who want to//   enable/disable features based on the current state. See//   Programmer's Manual section 11: On Reflection for more//   information.//// + Updated LICENSE.txt with a missing final paragraph which allows//   MPL 1.1 covered code to work with the GNU GPL.//// + Added a Maven plug-in and an ant task to a new tools directory.//   Added Eiten Suez's SMC tutorial (in PDF) to a new docs//   directory.//// Fixed the following bugs://// + (GraphViz) DOT file generation did not properly escape//   double quotes appearing in transition guards. This has been//   corrected.//// + A note: the SMC FAQ incorrectly stated that C/C++ generated//   code is thread safe. This is wrong. C/C++ generated is//   certainly *not* thread safe. Multi-threaded C/C++ applications//   are required to synchronize access to the FSM to allow for//   correct performance.//// + (Java) The generated getState() method is now public.//// Revision 1.1  2005/05/28 19:28:42  cwrapp// Moved to visitor pattern.//// Revision 1.1  2005/02/21 15:38:24  charlesr// Added Francois Perrad to Contributors section for Python work.//// Revision 1.0  2005/02/03 17:12:24  charlesr// Initial revision//

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -