org.moyoman.framework
Class ModuleCreator

java.lang.Object
  |
  +--org.moyoman.framework.ModuleCreator

class ModuleCreator
extends Object

This class creates the modules that are required in order for a specific Module implementation to be able to run. The algorithm is as follows: the ModuleCreator object is initialized with a module name. Instantiate the module represented by that name, and get the module types that it requires. Verify that it is only dependent on module types that preceed it in the ordered list of module types. For each of those module types, get the module name configured to be used for those module types and implement them. Continue this process until all dependencies have been processed. It is a runtime exception if either a module is declared to be dependent on a module type which does not proceed it, or if any module is not eventually dependent on Board, because in that case, the module is never reached.


Field Summary
private  HashMap modules
          The name is a ModuleName object, and the value a Module object.
 
Constructor Summary
protected ModuleCreator(GameId id, Mode mode)
          For the given mode, instantiate the MoveGenerator module and all dependent modules.
protected ModuleCreator(GameId id, ModuleName topName, Mode mode)
          For the given module, instantiate it and all dependent modules.
 
Method Summary
protected  HashMap getModules()
          Return the modules member variable produced by the constructor.
private  void processModules(GameId id, ModuleName topName, Mode mode)
          Determine which modules are used by this game and instantiate them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modules

private HashMap modules
The name is a ModuleName object, and the value a Module object.

Constructor Detail

ModuleCreator

protected ModuleCreator(GameId id,
                        Mode mode)
                 throws InternalErrorException
For the given mode, instantiate the MoveGenerator module and all dependent modules.

Parameters:
id - The id of the game.
mode - The mode of the game.
Throws:
InternalErrorException - Thrown if any dependencies are not correct.

ModuleCreator

protected ModuleCreator(GameId id,
                        ModuleName topName,
                        Mode mode)
                 throws InternalErrorException
For the given module, instantiate it and all dependent modules.

Parameters:
id - The id of the game.
mode - The mode of the game.
Throws:
InternalErrorException - Thrown if any dependencies are not correct.
Method Detail

processModules

private void processModules(GameId id,
                            ModuleName topName,
                            Mode mode)
                     throws InternalErrorException
Determine which modules are used by this game and instantiate them.

Parameters:
id - The id of the game.
mode - The mode of the game.
Throws:
InternalErrorException - Thrown if any dependencies are not correct.

getModules

protected HashMap getModules()
Return the modules member variable produced by the constructor.

Returns:
The HashMap with the modules.