org.jactr.core.module.declarative.basic
Class DefaultDeclarativeModule

java.lang.Object
  extended by org.jactr.core.module.AbstractModule
      extended by org.jactr.core.module.declarative.basic.AbstractDeclarativeModule
          extended by org.jactr.core.module.declarative.basic.DefaultDeclarativeModule
All Implemented Interfaces:
IDeclarativeModule, IModule, IInitializable, IInstallable, IParameterized
Direct Known Subclasses:
DefaultDeclarativeModule6

public class DefaultDeclarativeModule
extends AbstractDeclarativeModule
implements IDeclarativeModule, IParameterized


Constructor Summary
DefaultDeclarativeModule()
           
 
Method Summary
 void dispose()
          release any resources.
 void dispose(IChunk chunk)
          request that this chunk be disposed.
 java.util.concurrent.Future<java.util.Collection<IChunk>> findExactMatches(ChunkTypeRequest request, java.util.Comparator<IChunk> sorter, double activationThreshold, boolean bestOne)
          search DM for all the chunks that match pattern, sorting using sorter, that are above activationThreshold
 java.util.concurrent.Future<java.util.Collection<IChunk>> findPartialMatches(ChunkTypeRequest request, java.util.Comparator<IChunk> sorter, double activationThreshold, boolean bestOne)
          search DM for all the chunks that partially match
 long getNumberOfChunks()
          return the number of chunks in the model.
 java.lang.String getParameter(java.lang.String key)
          return parameter value - null if not defined.
 java.util.Collection<java.lang.String> getPossibleParameters()
          Return all parameters that can be read
 java.util.Collection<java.lang.String> getSetableParameters()
          Return list of all parameters that can be set.
 void initialize()
          here we attach a buffer listener to all the buffers and catch the removal notifications to see if we should encode the chunk..
static boolean isDisposalSuspended(IChunk chunk)
           
 void reset()
          reset the module.
static void setDisposalSuspended(IChunk chunk, boolean suspend)
          there is a grey area between the creation of a chunk and it's use in a buffer or encoding.
 void setParameter(java.lang.String key, java.lang.String value)
          Set the named parameter
 boolean willEncode(IChunk chunk)
          because encoding might be async, we need a method to determine if a given chunk is scheduled for encoding
 
Methods inherited from class org.jactr.core.module.declarative.basic.AbstractDeclarativeModule
addChunk, addChunkType, addListener, copyChunk, createChunk, createChunkType, getBusyChunk, getChunk, getChunks, getChunkType, getChunkTypes, getEmptyChunk, getErrorChunk, getFreeChunk, getFullChunk, getNewChunk, getRequestedChunk, getUnrequestedChunk, removeListener
 
Methods inherited from class org.jactr.core.module.AbstractModule
delayedFuture, getExecutor, getModel, getName, immediateFuture, immediateReturn, install, uninstall
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jactr.core.module.declarative.IDeclarativeModule
addChunk, addChunkType, addListener, copyChunk, createChunk, createChunkType, getBusyChunk, getChunk, getChunks, getChunkType, getChunkTypes, getEmptyChunk, getErrorChunk, getFreeChunk, getFullChunk, getNewChunk, getRequestedChunk, getUnrequestedChunk, removeListener
 
Methods inherited from interface org.jactr.core.module.IModule
getModel, getName, install
 
Methods inherited from interface org.jactr.core.utils.IInstallable
uninstall
 

Constructor Detail

DefaultDeclarativeModule

public DefaultDeclarativeModule()
Method Detail

setDisposalSuspended

public static void setDisposalSuspended(IChunk chunk,
                                        boolean suspend)
there is a grey area between the creation of a chunk and it's use in a buffer or encoding. Most never encounter it, but it can occur in the time between a perceptual search (i.e. visual-location) and encoding, where the system may want to dispose of the chunk (i.e. the underlying percept has changed too much) in order to create a new one. However, if the encoding process has already started, it is possible that the system will try to add the disposed chunk to a buffer.
This mechanism is a recommendation only, that the declarative module can use to temporarily suspend disposal.

Parameters:
chunk -

isDisposalSuspended

public static boolean isDisposalSuspended(IChunk chunk)

willEncode

public boolean willEncode(IChunk chunk)
Description copied from interface: IDeclarativeModule
because encoding might be async, we need a method to determine if a given chunk is scheduled for encoding

Specified by:
willEncode in interface IDeclarativeModule
Returns:

dispose

public void dispose()
Description copied from interface: IModule
release any resources. this should only be called by the model during its own dispose method (assuming that this module is still installed) and should not result in the propogation of ANY events. The module should dispose of all its resources, including buffers

Specified by:
dispose in interface IModule
Overrides:
dispose in class AbstractModule

getNumberOfChunks

public long getNumberOfChunks()
Description copied from interface: IDeclarativeModule
return the number of chunks in the model. this might be an estimate

Specified by:
getNumberOfChunks in interface IDeclarativeModule
Returns:

initialize

public void initialize()
here we attach a buffer listener to all the buffers and catch the removal notifications to see if we should encode the chunk..

Specified by:
initialize in interface IModule
Specified by:
initialize in interface IInitializable
Overrides:
initialize in class AbstractDeclarativeModule
See Also:
AbstractModule.initialize()

findExactMatches

public java.util.concurrent.Future<java.util.Collection<IChunk>> findExactMatches(ChunkTypeRequest request,
                                                                                  java.util.Comparator<IChunk> sorter,
                                                                                  double activationThreshold,
                                                                                  boolean bestOne)
Description copied from interface: IDeclarativeModule
search DM for all the chunks that match pattern, sorting using sorter, that are above activationThreshold

Specified by:
findExactMatches in interface IDeclarativeModule
sorter - may be null
bestOne - find only best one
Returns:
See Also:
IDeclarativeModule.findExactMatches(ChunkTypeRequest, java.util.Comparator, double, boolean)

findPartialMatches

public java.util.concurrent.Future<java.util.Collection<IChunk>> findPartialMatches(ChunkTypeRequest request,
                                                                                    java.util.Comparator<IChunk> sorter,
                                                                                    double activationThreshold,
                                                                                    boolean bestOne)
Description copied from interface: IDeclarativeModule
search DM for all the chunks that partially match

Specified by:
findPartialMatches in interface IDeclarativeModule
sorter - may be null
bestOne - true if you only want the best one chunk
Returns:
See Also:
IDeclarativeModule.findPartialMatches(ChunkTypeRequest, java.util.Comparator, double, boolean)

dispose

public void dispose(IChunk chunk)
Description copied from interface: IDeclarativeModule
request that this chunk be disposed.

Specified by:
dispose in interface IDeclarativeModule

getParameter

public java.lang.String getParameter(java.lang.String key)
Description copied from interface: IParameterized
return parameter value - null if not defined.

Specified by:
getParameter in interface IParameterized
Parameters:
key - Description of the Parameter
Returns:
The parameter value

getPossibleParameters

public java.util.Collection<java.lang.String> getPossibleParameters()
Description copied from interface: IParameterized
Return all parameters that can be read

Specified by:
getPossibleParameters in interface IParameterized
Returns:
The possibleParameters value

getSetableParameters

public java.util.Collection<java.lang.String> getSetableParameters()
Description copied from interface: IParameterized
Return list of all parameters that can be set.

Specified by:
getSetableParameters in interface IParameterized
Returns:
The setableParameters value

setParameter

public void setParameter(java.lang.String key,
                         java.lang.String value)
Description copied from interface: IParameterized
Set the named parameter

Specified by:
setParameter in interface IParameterized

reset

public void reset()
Description copied from interface: IModule
reset the module. This will typically clear the owned buffers and abort any module specific operations

Specified by:
reset in interface IModule