Class DefaultControllerRegistry
java.lang.Object
repast.simphony.engine.controller.DefaultControllerRegistry
- All Implemented Interfaces:
Cloneable,ControllerRegistry
Basic implementation of a
ControllerRegistry.- Author:
- Jerry Vos
-
Field Summary
FieldsFields inherited from interface repast.simphony.engine.environment.ControllerRegistry
ACTION_TREE_ROOT, DEFAULT_MASTER_CONTEXT_ID -
Constructor Summary
ConstructorsConstructorDescriptionConstructs the SimpleControllerRegistry with no actions. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAction(Object contextId, ControllerAction parent, ControllerAction action) Adds an action to those for the specified context, under the specified parent action.voidaddContextId(Object parentId, Object newId) voidaddParameterSetter(ParameterSetter paramInit) clone()findAction(Object contextID, String actionID) Finds a registered action.getActionTree(Object contextId) Returns the root node for the tree of actions that occur for a specified context type.getName()voidregisterAction(Object contextID, String id, ControllerAction action) Registers an action so that it can be found later.booleanremoveAction(Object contextId, ControllerAction action) Removes an action.voidvoidremoveParameterSetter(ParameterSetter paramInit) voidreplaceAction(Object contextId, ControllerAction oldAction, ControllerAction newAction) Replaces a given action with the specified action.voidreplaceContextId(Object idToReplace, Object newId) voidvoid
-
Field Details
-
paramSetters
-
-
Constructor Details
-
DefaultControllerRegistry
public DefaultControllerRegistry()Constructs the SimpleControllerRegistry with no actions.
-
-
Method Details
-
clone
- Specified by:
clonein interfaceControllerRegistry- Overrides:
clonein classObject
-
addAction
Adds an action to those for the specified context, under the specified parent action. If the specified parent is null then the parent is assumed to be the root of the tree. Also, if the specified context id has not already been added to the controller, it will be added as a child of the top level context.- Specified by:
addActionin interfaceControllerRegistry- Parameters:
contextId- the id of the context this applies toparent- the action under which this action occurs, can be nullaction- the action to add
-
getActionTree
Description copied from interface:ControllerRegistryReturns the root node for the tree of actions that occur for a specified context type.- Specified by:
getActionTreein interfaceControllerRegistry- Parameters:
contextId- the type id of the context who's action tree to return- Returns:
- the root node in the tree of actions
-
removeAction
Removes an action. Since the actions are stored as a tree, this has the side-effect of also removing all actions nested under the given action. If this behavior is not wanted use the#replaceAction(ControllerAction, ControllerAction)method with aDefaultControllerAction.- Specified by:
removeActionin interfaceControllerRegistry- Parameters:
action- the action to remove- Returns:
- true if the action was removed, false if it was not in the registry
- See Also:
-
replaceAction
Replaces a given action with the specified action. This will result in an action tree with the old action replaced with the new one. Any actions nested under the old action will now be nested under the new action. If the new action is aDefaultControllerActionthis is the same as removing the given action without removing its children. This will not accept null as an argument, as it would not make sense as either an old action or as the new one that is replacing it. If null is received anInvalidParameterExceptionwill be thrown.- Specified by:
replaceActionin interfaceControllerRegistry- Parameters:
oldAction- the action to replacenewAction- the action with which to replace the old one
-
getContextIdTree
- Specified by:
getContextIdTreein interfaceControllerRegistry
-
addContextId
- Specified by:
addContextIdin interfaceControllerRegistry
-
removeContextId
- Specified by:
removeContextIdin interfaceControllerRegistry
-
setMasterContextId
- Specified by:
setMasterContextIdin interfaceControllerRegistry
-
getMasterContextId
- Specified by:
getMasterContextIdin interfaceControllerRegistry
-
replaceContextId
- Specified by:
replaceContextIdin interfaceControllerRegistry
-
getName
- Specified by:
getNamein interfaceControllerRegistry
-
setName
- Specified by:
setNamein interfaceControllerRegistry
-
registerAction
Description copied from interface:ControllerRegistryRegisters an action so that it can be found later.- Specified by:
registerActionin interfaceControllerRegistry
-
findAction
Description copied from interface:ControllerRegistryFinds a registered action.- Specified by:
findActionin interfaceControllerRegistry- Parameters:
contextID- the context of the actionactionID- the id of the action- Returns:
- the found action
-
addParameterSetter
- Specified by:
addParameterSetterin interfaceControllerRegistry
-
removeParameterSetter
- Specified by:
removeParameterSetterin interfaceControllerRegistry
-
getParameterSetters
- Specified by:
getParameterSettersin interfaceControllerRegistry
-