com.tomgibara.pronto.state
Class StateFactory

java.lang.Object
  extended by com.tomgibara.pronto.state.StateFactory
Direct Known Subclasses:
StateFactoryImpl

public abstract class StateFactory
extends java.lang.Object

This class is used to obtain graphs and engines to manage state transitions.

The idiom for using this package is to obtain an instance of this factory and from that an empty state graph. Then to obtain an editor on that graph through which any permitted states and transitions are added. And finally to combine that state graph with an activator in an engine that will manage state the transitions.

Only one instance of a StateFactory is available through the getInstance() method. The default implementation returned by this static method can be changed by assigning the system property com.tomgibara.pronto.state.factory the name of a class which extends this abstract base class.

Author:
Tom Gibara

Constructor Summary
StateFactory()
           
 
Method Summary
abstract
<S,L> StateGraph<S,L>
emptyStateGraph()
          Creates an empty state graph from which an editor is typically obtained to build any required state graph.
static StateFactory getInstance()
          Should be called to obtain a StateFactory instance.
abstract
<S,L,P> StateEngine<S,L,P>
newEngine(StateGraph<S,L> graph, StateActivator<S,L,P> activator)
          Combines a graph and activator to form a new engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateFactory

public StateFactory()
Method Detail

getInstance

public static StateFactory getInstance()
                                throws com.tomgibara.pronto.core.ProntoException
Should be called to obtain a StateFactory instance. This method is the single entry-point to state management functionality in the pronto framework.

Returns:
the single instance of this factory
Throws:
com.tomgibara.pronto.core.ProntoException - if the factory instance could not be created

emptyStateGraph

public abstract <S,L> StateGraph<S,L> emptyStateGraph()
Creates an empty state graph from which an editor is typically obtained to build any required state graph.

Type Parameters:
S - the type of states the state graph editor will permit
L - the type of labels the state graph editor will permit
Returns:
a state graph containing no states

newEngine

public abstract <S,L,P> StateEngine<S,L,P> newEngine(StateGraph<S,L> graph,
                                                     StateActivator<S,L,P> activator)
Combines a graph and activator to form a new engine.

Type Parameters:
S - the type of states in the graph
L - the type of labels in the graph
P - the type of parameters accepted by the activator
Parameters:
graph - the graph of states and transitions permitted by the engine
activator - an object that can 'act' in response to state changes
Returns:
a new engine which can transition over the graph of states subject to execution of the activator


Copyright © 2006-2007 Tom Gibara. All Rights Reserved.