File 'base/sequencer.cls' (part of 'Pool_Base')

Description (short)
Sequencer framework
Written by
Andreas Kupries
Description
Framework for building sequencers. Currently used by the smtp and pop3 implementations. See background for more information and <f net/pop3/*> and <f net/smtp/*> for examples of its usage.
Keywords
Sequencer, State machines, finite automatons

Class 'sequencer'

Options
timeout
Methods
public
Event (event arglist)
OnDone ()
OnLine (line)
OnNext ()
Receive (channel)
Timeout (channel)
errorInfo ()
event (event args)
next (method)
state ()
wait (channel method)
Membervariables
public
state
error
nextMethod
lineMethod
after

Options

-timeout
Timeout in milliseconds.

Methods

Event (event arglist)

The real event handler. Execution is set up by event. Takes the same arguments.
Argument: event Name of event to raise. Allowed values are 'error', 'timeout', 'eof', 'line', 'next' and 'done'.
Argument: arglist Arbitrary arguments given to the event. Only 'error' and 'line' actually use arguments (the first one only), all else ignore this information.

OnDone ()

Abstract method. Called by the framework if the FA is done with its work (= upon event 'done').

OnLine (line)

Called by the framework to proceed after receiving a 'line' event. The default implementation uses lineMethod to call the correct handler method.
Argument: line Contains the received information.

OnNext ()

Called by the framework to proceed to the next step in the sequence (upon event 'next'). The default implementation uses nextMethod to call the correct method.

Receive (channel)

Callback executed in case of data arriving at channel. May raise 'eof' and 'line' events in the sequencer. Will disable the timeout in this cases. In case of having received an incomplete line the system will just go to sleep again, to wait for more data.
Argument: channel Name of channel the sequencer waited for.

Timeout (channel)

Callback executed in case of a timeout during the wait for input at channel. Removes the fileevent handler, then raises the 'timeout' event in the sequencer.
Argument: channel Name of channel the sequencer waited for.

errorInfo ()

Returns: The error information of this sequencer.

event (event args)

Raises event in the given sequencer. Automatically the last command executed in the surounding context, i.e behaves as 'return'. The actual handling of the event is delayed by 'after' and done inside Event.
Notes: Raising 'done' executes 'OnDone' and then automatically destroys the sequencer
Argument: event Name of event to raise. Allowed values are 'error', 'timeout', 'eof', 'line', 'next' and 'done'.
Argument: args Arbitrary arguments given to the event. Only 'error' and 'line' actually use arguments (the first one only), all else ignore this information.

next (method)

Defines a method to be executed if the 'next' event was triggered. Removes any existing 'line' handler.
Argument: method The method to set as 'next' handler.

state ()

Returns: The state of this sequencer.

wait (channel method)

Convenience procedure to setup the sequencer to wait for input on a channel. After receiving a complete line the appropriate event will be raised. The wait will be able to time out if such information is part of the sequencer configuration. Removes any existing 'next' handler .
Argument: channel Name of channel to wait on for input.
Argument: method Name of the method to execute after a line was received.


Membervariables

state
The current state of the sequencer. One of: error, timeout, eof, done, next or line. Equal to the last event executed by us.
error
Error message placed into the sequencer by a derived class.
nextMethod
Name of the method to call upon receiving the 'next' event.
lineMethod
Name of the method to call upon receiving the 'line' event.
after
The handle of the timeout set via wait.

Generated by AutoDoc 2.4 at 09/14/2000, invoked by Andreas Kupries