|
@@ -5,7 +5,7 @@
|
|
|
* (c) 2006 Ouest Systèmes Informatiques (OSI)
|
|
|
* Licensed under the CeCILL 2.0 license
|
|
|
*
|
|
|
- * $Id: Finite_State_Machine.php,v 1.5 2007-05-08 20:54:22 marand Exp $
|
|
|
+ * $Id: Finite_State_Machine.php,v 1.6 2007-05-08 21:47:28 marand Exp $
|
|
|
*/
|
|
|
require_once('misc.php'); // for func_name()
|
|
|
error_reporting(E_ALL|E_STRICT);
|
|
@@ -68,7 +68,7 @@ class fsm_result
|
|
|
* - submit any event (including idle) by using $this->apply_event($event_name)
|
|
|
*
|
|
|
*/
|
|
|
-abstract class fsm
|
|
|
+abstract class Finite_State_Machine
|
|
|
{
|
|
|
const IDLE_EVENT = 'idle'; // must not change name: method f_idle depends on it
|
|
|
|
|
@@ -82,7 +82,7 @@ abstract class fsm
|
|
|
public $idle_work = TRUE;
|
|
|
public $allow_actions = TRUE;
|
|
|
|
|
|
- protected $f_event_mode = fsm::EVENT_NORMAL;
|
|
|
+ protected $f_event_mode = Finite_State_Machine::EVENT_NORMAL;
|
|
|
protected $f_queue = array(); // event queue for EVENT_QUEUE mode
|
|
|
|
|
|
/**
|
|
@@ -258,7 +258,7 @@ abstract class fsm
|
|
|
{
|
|
|
// echo func_name() . ", event = $event_name";
|
|
|
$current_state = $this->f_state;
|
|
|
- if (($event_name == fsm::IDLE_EVENT) && !$this->idle_work)
|
|
|
+ if (($event_name == Finite_State_Machine::IDLE_EVENT) && !$this->idle_work)
|
|
|
{
|
|
|
return new fsm_result();
|
|
|
}
|
|
@@ -323,7 +323,7 @@ abstract class fsm
|
|
|
*/
|
|
|
public function idle()
|
|
|
{
|
|
|
- return $this->apply_event(fsm::IDLE_EVENT);
|
|
|
+ return $this->apply_event(Finite_State_Machine::IDLE_EVENT);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -344,7 +344,7 @@ abstract class fsm
|
|
|
{
|
|
|
switch ($mode)
|
|
|
{
|
|
|
- case fsm::EVENT_NORMAL :
|
|
|
+ case Finite_State_Machine::EVENT_NORMAL :
|
|
|
if (count($this->f_queue) > 0)
|
|
|
{
|
|
|
while ($event = array_shift($this->f_queue))
|
|
@@ -353,9 +353,9 @@ abstract class fsm
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
- case fsm::EVENT_QUEUE : // nothing special to do
|
|
|
+ case Finite_State_Machine::EVENT_QUEUE : // nothing special to do
|
|
|
break;
|
|
|
- case fsm::EVENT_SINK : // empty queue if needed
|
|
|
+ case Finite_State_Machine::EVENT_SINK : // empty queue if needed
|
|
|
if (count($this->f_queue) > 0)
|
|
|
{
|
|
|
$this->f_queue = array();
|
|
@@ -406,11 +406,11 @@ abstract class fsm
|
|
|
$t[$id] = array();
|
|
|
switch ($id)
|
|
|
{
|
|
|
- case fsm::INIT_STATE :
|
|
|
+ case Finite_State_Machine::INIT_STATE :
|
|
|
if ($osd)
|
|
|
echo " Initial state\n";
|
|
|
break;
|
|
|
- case fsm::FINAL_STATE :
|
|
|
+ case Finite_State_Machine::FINAL_STATE :
|
|
|
if ($osd)
|
|
|
echo " Final state\n";
|
|
|
break;
|