Browse Source

Renamed fsm_result to Fsm_Result to comply with coding style
Added some phpdoc comments.
Works with ZF 1.0RC2

Frederic G. Marand 17 years ago
parent
commit
65a4e24ae1
4 changed files with 29 additions and 16 deletions
  1. 2 1
      Background_Application.php
  2. 18 12
      Finite_State_Machine.php
  3. 2 2
      Ftp_Client.php
  4. 7 1
      misc.php

+ 2 - 1
Background_Application.php

@@ -8,10 +8,11 @@
  *
  * @copyright  (c) 2007 OSI
  * @license    Licensed under the CeCILL 2.0
- * @version    CVS: $Id: Background_Application.php,v 1.2 2007-06-03 21:23:11 marand Exp $
+ * @version    CVS: $Id: Background_Application.php,v 1.3 2007-06-10 16:30:30 marand Exp $
  * @link       http://wiki.audean.com/fsm/fsm
  * @since      Not applicable yet
  * @package    fsm
+ * @subpackage fsm.ui
  */
 
 error_reporting(E_ALL|E_STRICT);

+ 18 - 12
Finite_State_Machine.php

@@ -5,20 +5,22 @@
  * @copyright  (c) 2007 OSI
  * @author     Frédéric G. MARAND
  * @license    Licensed under the CeCILL 2.0
- * @version    CVS: $Id: Finite_State_Machine.php,v 1.7 2007-06-03 21:24:29 marand Exp $
- * @link       http://drupal.org/project/offload
+ * @version    CVS: $Id: Finite_State_Machine.php,v 1.8 2007-06-10 16:30:30 marand Exp $
+ * @link       http://wiki.audean.com/fsm/fsm
  * @since      Not applicable yet
  * @package    fsm
+ * @subpackage fsm.core
+ * @todo       replace setAttribute('id',...) by setIdAttribute when PHP5.2 becomes mandatory
  */
 
 require_once('misc.php'); // for func_name()
-error_reporting(E_ALL|E_STRICT);
+$erFiniteStateMachine = error_reporting(E_ALL|E_STRICT);
 
 /**
  * This class defines a possible outcome for a given FSM transition
  *
  */
-class fsm_result
+class Fsm_Result
   {
   /**
    * The return value of the event handler
@@ -74,6 +76,7 @@ class fsm_result
  */
 abstract class Finite_State_Machine
   {
+  const VERSION      = '$Id';
   const IDLE_EVENT   = 'idle'; // must not change name: method f_idle depends on it
 
   const INIT_STATE   = 'init';
@@ -100,7 +103,7 @@ abstract class Finite_State_Machine
    * state1
    *   event1
    *     result1
-   *     state_name|fsm_result
+   *     state_name|Fsm_Result
    *   event2
    *     ...
    *   ..
@@ -128,7 +131,7 @@ abstract class Finite_State_Machine
    * make sure a transitions graph has been defined
    * @return void
    */
-  private function _check_transitions()
+  protected function _check_transitions()
     {
     if (!isset($this->f_transitions))
       throw new Exception('No FSM processing is allowed without a transitions table\n');
@@ -231,7 +234,7 @@ abstract class Finite_State_Machine
    *
    * @param string $event_name
    * @param array $params the
-   * @return fsm_result resulting state
+   * @return Fsm_Result resulting state
    */
   public function apply_event($event_name)
     {
@@ -256,7 +259,7 @@ abstract class Finite_State_Machine
    * Helper for apply_event that does not implement the post-transition action
    *
    * @param string $event_name
-   * @return fsm_result
+   * @return Fsm_Result
    * @see apply_event()
    */
   private function apply_simple_event($event_name)
@@ -265,7 +268,7 @@ abstract class Finite_State_Machine
     $current_state = $this->f_state;
     if (($event_name == Finite_State_Machine::IDLE_EVENT) && !$this->idle_work)
       {
-      return new fsm_result();
+      return new Fsm_Result();
       }
 
     if (!$this->is_event_allowed($event_name))
@@ -295,7 +298,7 @@ abstract class Finite_State_Machine
       }
 
     $transition = &$this->f_transitions[$current_state][$event_name][$outcome];
-    $result = new fsm_result
+    $result = new Fsm_Result
       (
       $outcome,
       $transition[0],
@@ -329,7 +332,7 @@ abstract class Finite_State_Machine
   /**
    * Apply an fsm::IDLE_EVENT event. Do not confuse with f_idle !
    *
-   * @return fsm_result
+   * @return Fsm_Result
    */
   public function idle()
     {
@@ -464,4 +467,7 @@ abstract class Finite_State_Machine
         }
       }
     }
-  }
+  }
+
+error_reporting($erFiniteStateMachine);
+unset($erFiniteStateMachine);

+ 2 - 2
Ftp_Client.php

@@ -5,7 +5,7 @@
  * @copyright  (c) 2007 OSI
  * @author     Frédéric G. MARAND
  * @license    Licensed under the CeCILL 2.0
- * @version    CVS: $Id: Ftp_Client.php,v 1.1 2007-06-03 21:27:57 marand Exp $
+ * @version    CVS: $Id: Ftp_Client.php,v 1.2 2007-06-10 16:30:30 marand Exp $
  * @link
  * @since      Not applicable yet
  * @package    osinetoffice
@@ -66,7 +66,7 @@ class Ftp_Client extends Finite_State_Machine
    *
    * @todo should really check names and values.
    * @param array $params
-   * @return fsm_result
+   * @return Fsm_Result
    */
   public function setParameters($params)
     {

+ 7 - 1
misc.php

@@ -5,7 +5,7 @@
  * @copyright  (c) 2007 OSI
  * @author     Frédéric G. MARAND
  * @license    Licensed under the CeCILL 2.0
- * @version    CVS: $Id: misc.php,v 1.2 2007-06-03 21:25:11 marand Exp $
+ * @version    CVS: $Id: misc.php,v 1.3 2007-06-10 16:30:30 marand Exp $
  * @link       http://drupal.org/project/offload
  * @since      Not applicable yet
  * @package    default
@@ -41,6 +41,12 @@ function get_temp_dir()
   return 'e:/src/OsinetOffice/tmp';
   }
 
+/**
+ * @link http://blog.riff.org/2006_11_19_console_encoding_in_php_gtk_apps
+ *
+ * @param string $s
+ * @return string
+ */
 function output_encoder($s)
   {
   return iconv('UTF-8', 'IBM850', $s);