com.tomgibara.pronto.control
Class ControlFactory

java.lang.Object
  extended by com.tomgibara.pronto.control.ControlFactory
Direct Known Subclasses:
ControlFactoryImpl

public abstract class ControlFactory
extends java.lang.Object

Instances of this class are responsible for creating Controller objects from ControllerSettings interface.

Only one instance of a ControlFactory 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.control.factory the name of a class which extends this abstract base class.

Author:
Tom Gibara

Constructor Summary
ControlFactory()
           
 
Method Summary
static ControlFactory getInstance()
          Should be called to obtain a ConfigFactory instance.
abstract  boolean isSettingsIfaceSupported(java.lang.Class<? extends ControllerSettings> iface)
          Indicates whether the interface supplied is recognized by this factory.
abstract
<S,L,P> Controller<S,L,P>
newController(ControllerSettings settings, com.tomgibara.pronto.state.StateEngine<S,L,P> engine, EngineControlAdapter<S,L,P> adapter)
          Constructs a new controller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ControlFactory

public ControlFactory()
Method Detail

getInstance

public static ControlFactory getInstance()
                                  throws com.tomgibara.pronto.core.ProntoException
Should be called to obtain a ConfigFactory instance. This method is the single entry-point to configuration 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

isSettingsIfaceSupported

public abstract boolean isSettingsIfaceSupported(java.lang.Class<? extends ControllerSettings> iface)
Indicates whether the interface supplied is recognized by this factory. Implementations of recognized interfaces may be passed to the newController method to create Controller objects.

Parameters:
iface - an interface whose instances may be used to create a new controller
Returns:
whether the factory can generate a controller from the supplied interface

newController

public abstract <S,L,P> Controller<S,L,P> newController(ControllerSettings settings,
                                                        com.tomgibara.pronto.state.StateEngine<S,L,P> engine,
                                                        EngineControlAdapter<S,L,P> adapter)
                                         throws java.lang.IllegalArgumentException,
                                                ProntoControlException
Constructs a new controller.

Type Parameters:
S - the engine's state type
L - the engine's label type
P - the engine's parameter type
Parameters:
settings - the settings that define the new controller.
engine - the engine that will be operated by the controller.
adapter - the adapter that mediates external data and the state graph
Returns:
a new controller, the operation of which is defined by the supplied settings.
Throws:
java.lang.IllegalArgumentException - if the type of settings is not recognized by this factory
ProntoControlException - if the settings supplied were invalid


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