FSM
[ class tree: FSM ] [ index: FSM ] [ all elements ]

Class: FSM_GraphViz

Source Location: /FSM-1.4.0/FSM/GraphViz.php

Class Overview

FSM
   |
   --FSM_GraphViz

FSM to Image_GraphViz converter


Author(s):

Version:

  • $Revision$

Copyright:

  • (c) 2007 by Philippe Jausions / 11abacus

Variables

Methods


Inherited Variables

Inherited Methods

Class: FSM

FSM::FSM()
This method constructs a new Finite State Machine (FSM) object.
FSM::addTransition()
This method adds a new transition that associates:
FSM::addTransitionAny()
This method adds a new transition that associates:
FSM::addTransitions()
This method adds the same transition for multiple different symbols.
FSM::addTransitionsArray()
This method adds an array of transitions. Each transition is itself defined as an array of values which will be passed to addTransition() as parameters.
FSM::getCurrentState()
This method returns the machine's current state.
FSM::getPreviousState()
This method returns the machine's previous state.
FSM::getTransition()
This method returns (nextState, action) given an input symbol and state. The FSM is not modified in any way. This method is rarely called directly (generally only for informational purposes).
FSM::process()
This method is the main processing routine. It causes the FSM to change states and execute actions.
FSM::processList()
This method processes a list of symbols. Each symbol in the list is sent to process().
FSM::reset()
This method resets the FSM by setting the current state back to the initial state (set by the constructor).
FSM::setDefaultTransition()
This method sets the default transition. This defines an action and next state that will be used if the processing routine cannot find a suitable match in either transition list. This is useful for catching errors caused by undefined states.

Class Details

[line 51]
FSM to Image_GraphViz converter

This class extends the FSM class to have access to private properties. It is not intended to be used as a FSM instance.

PHP 5 or later is recommended to be able to handle action that return a new state.

  • Author: Philippe Jausions <jausions@php.net>
  • Version: $Revision$
  • Copyright: (c) 2007 by Philippe Jausions / 11abacus
  • Since: 1.3.0


[ Top ]


Class Variables

$_actionNameCallback =

[line 67]

Action name callback
  • Access: protected

Type:   string


[ Top ]

$_fsm =

[line 59]

Machine instance
  • Access: protected

Type:   FSM


[ Top ]



Method Detail

FSM_GraphViz (Constructor)   [line 76]

FSM_GraphViz FSM_GraphViz( FSM &$machine)

Constructor
  • Access: public

Parameters:

FSM   &$machine   —  instance to convert

[ Top ]

export   [line 109]

Image_GraphViz &export( [string $name = 'FSM'], [boolean $strict = true])

Converts an FSM to an instance of Image_GraphViz
  • Return: instance or PEAR_Error on failure
  • Access: public

Parameters:

string   $name   —  Name for the graph
boolean   $strict   —  Whether to collapse multiple edges between same nodes.

[ Top ]

setActionNameCallback   [line 90]

boolean setActionNameCallback( mixed $callback)

Sets the callback for the action name
  • Return: TRUE on success, PEAR_Error on error
  • Access: public

Parameters:

mixed   $callback   — 

[ Top ]

_addAction   [line 187]

void _addAction( Image_GraphViz &$graph, array &$nodes, mixed $action, string $state, [boolean $default = false])

Adds an action into the graph
  • Access: protected

Parameters:

Image_GraphViz   &$graph   —  instance to add the action to
array   &$nodes   —  list of nodes
mixed   $action   —  callback
string   $state   —  start state
boolean   $default   —  whether this is the action tied to the default transition

[ Top ]

_getActionName   [line 237]

string _getActionName( mixed $callback)

Returns an action as string
  • Access: protected

Parameters:

mixed   $callback   —  action

[ Top ]

_getStatesReturnedByAction   [line 289]

array _getStatesReturnedByAction( mixed $callback)

Analyzes callback for possible new state(s) returned

PHP version 5

This methods requires the use of the Reflection API to parse the doc block and looks for the @return declaration.

If the callback shall return new states, @return should specify a string followed by a

    containing a list of new states inside <li></li> tags.

    Example of doc block for action callback:

    1.  /**
    2.   * This method does something then returns a new status
    3.   *
    4.   * \@param string $symbol
    5.   * \@param mixed $payload
    6.   *
    7.   * \@return string One of
    8.   * <ul>
    9.   *  <li>RIPE</li>
    10.   *  <li>NOT_RIPE</li>
    11.   * <ul>
    12.   * \@access public
    13.   */
    14.  function checkRipeness($symbol$payload)
    15.  {
    16.     return ($symbol == 'Orange''RIPE' 'NOT_RIPE';
    17.  }

    • Return: a list of possible new states returned by the callback
    • Access: protected

    Parameters:

    mixed   $callback   —  callback to analyze

    [ Top ]

    _getSymbolName   [line 224]

    string _getSymbolName( string $symbol, string $state)

    Returns an symbol-node name
    • Access: protected

    Parameters:

    string   $symbol   — 
    string   $state   — 

    [ Top ]


    Documentation generated on Mon, 11 Mar 2019 16:02:22 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.