public abstract class AbstractDeclarativeModule extends AbstractModule implements IDeclarativeModule
IDeclarativeModule
including creation, merging and disposal of
chunks and types. However, the actual adding to the containers or searching
is left to subclasses. http://jactr.org/node/120
Modifier and Type | Field and Description |
---|---|
protected ChunkActivationComparator |
_activationSorter |
static java.lang.String |
SUSPEND_DISPOSAL_KEY |
Constructor and Description |
---|
AbstractDeclarativeModule(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
java.util.concurrent.CompletableFuture<IChunk> |
addChunk(IChunk chunk)
add chunk to DM.
|
protected abstract IChunk |
addChunkInternal(IChunk chunkToAdd,
java.util.Collection<IChunk> possibleMatches)
add the chunk to DM on the module's executor.
|
java.util.concurrent.CompletableFuture<IChunkType> |
addChunkType(IChunkType chunkType)
add chunktype to DM, delegated to
addChunkTypeInternal(IChunkType)
on AbstractModule.getExecutor() |
protected abstract IChunkType |
addChunkTypeInternal(IChunkType chunkType)
add the chunktype DM on the module's executor.
|
void |
addListener(IDeclarativeModuleListener listener,
java.util.concurrent.Executor executor) |
protected void |
configure(IChunk newChunk)
calls the pluggable IChunkConfigurator
|
protected void |
configure(IChunkType newChunkType)
calls
IChunkTypeConfigurator |
java.util.concurrent.CompletableFuture<IChunk> |
copyChunk(IChunk sourceChunk)
copy the specified chunk, by default this will also copy subsymbolics
|
java.util.concurrent.CompletableFuture<IChunk> |
copyChunk(IChunk sourceChunk,
boolean copySubsymbolics) |
protected void |
copyChunkInternal(IChunk sourceChunk,
IChunk destination,
boolean copySubsymbolics)
copy source to copy
|
java.util.concurrent.CompletableFuture<IChunk> |
createChunk(IChunkType parent,
java.lang.String name)
create a chunk by delegating to
createChunkInternal(IChunkType, String) on AbstractModule.getExecutor() |
protected IChunk |
createChunkInternal(IChunkType parent,
java.lang.String name)
create the chunk
|
java.util.concurrent.CompletableFuture<IChunkType> |
createChunkType(java.util.Collection<IChunkType> parents,
java.lang.String name)
create chunktype, delegates to
#createChunkTypeInternal(IChunkType, String) on
AbstractModule.getExecutor() |
java.util.concurrent.CompletableFuture<IChunkType> |
createChunkType(IChunkType parent,
java.lang.String name) |
protected IChunkType |
createChunkTypeInternal(java.util.Collection<IChunkType> parents,
java.lang.String name) |
protected void |
deferredEncode(java.util.Collection<IChunk> chunks) |
protected void |
deferredEncode(IChunk chunk)
encode this chunk at some later time (top/bottom of the cycle).
|
protected void |
dispatch(DeclarativeModuleEvent event) |
void |
dispose(IChunk chunk)
schedule this chunk to be disposed, at the module's earliest convenience
|
protected void |
disposeInternal(IChunk chunk)
actually perform the disposal
|
protected void |
fireChunkAdded(IChunk chunk) |
protected void |
fireChunkCreated(IChunk chunk) |
protected void |
fireChunkDisposed(IChunk chunk) |
protected void |
fireChunkRemoved(IChunk chunk) |
protected void |
fireChunksMerged(IChunk original,
IChunk duplicateChunk) |
protected void |
fireChunkTypeAdded(IChunkType chunkType) |
protected void |
fireChunkTypeCreated(IChunkType chunkType) |
protected void |
fireChunkTypeDisposed(IChunkType chunkType) |
protected void |
fireChunkTypesMerged(IChunkType original,
IChunkType duplicate) |
void |
flush()
force all pending deferred operations to execute (dispose, encode, etc)
|
IAssociativeLinkageSystem |
getAssociativeLinkageSystem()
code responsible for the setting up and maintaining of associative links,
may be null.
|
IChunk |
getBusyChunk()
snag the busy chunk.
Note : this should not be called by the declarative memory module if the retrieval will access the future methods as it might result in deadlock. |
java.util.concurrent.CompletableFuture<IChunk> |
getChunk(java.lang.String name)
delegated
|
IChunkConfigurator |
getChunkConfigurator() |
IChunkFactory |
getChunkFactory() |
protected abstract IChunk |
getChunkInternal(java.lang.String chunkName) |
IChunkNamer |
getChunkNamer() |
java.util.concurrent.CompletableFuture<java.util.Collection<IChunk>> |
getChunks()
return all chunks.
|
protected abstract java.util.Collection<IChunk> |
getChunksInternal() |
java.util.concurrent.CompletableFuture<IChunkType> |
getChunkType(java.lang.String name)
delegated
|
IChunkTypeConfigurator |
getChunkTypeConfigurator() |
IChunkTypeFactory |
getChunkTypeFactory() |
protected abstract IChunkType |
getChunkTypeInternal(java.lang.String name) |
IChunkTypeNamer |
getChunkTypeNamer() |
java.util.concurrent.CompletableFuture<java.util.Collection<IChunkType>> |
getChunkTypes()
delegated
|
protected abstract java.util.Collection<IChunkType> |
getChunkTypesInternal() |
IChunk |
getEmptyChunk()
snag the busy chunk.
Note : this should not be called by the declarative memory module if the retrieval will access the future methods as it might result in deadlock. |
IChunk |
getErrorChunk()
snag the busy chunk.
Note : this should not be called by the declarative memory module if the retrieval will access the future methods as it might result in deadlock. |
IChunk |
getFreeChunk()
snag the busy chunk.
Note : this should not be called by the declarative memory module if the retrieval will access the future methods as it might result in deadlock. |
IChunk |
getFullChunk()
snag the busy chunk.
Note : this should not be called by the declarative memory module if the retrieval will access the future methods as it might result in deadlock. |
IChunk |
getNewChunk()
snag the busy chunk.
Note : this should not be called by the declarative memory module if the retrieval will access the future methods as it might result in deadlock. |
IChunk |
getRequestedChunk()
snag the busy chunk.
Note : this should not be called by the declarative memory module if the retrieval will access the future methods as it might result in deadlock. |
ISubsymbolicChunkFactory |
getSubsymbolicChunkFactory() |
ISubsymbolicChunkTypeFactory |
getSubsymbolicChunkTypeFactory() |
ISymbolicChunkFactory |
getSymbolicChunkFactory() |
ISymbolicChunkTypeFactory |
getSymbolicChunkTypeFactory() |
IChunk |
getUnrequestedChunk()
snag the busy chunk.
Note : this should not be called by the declarative memory module if the retrieval will access the future methods as it might result in deadlock. |
protected boolean |
hasListeners() |
void |
initialize()
this will be called after all the modules have been installed permitting
the module to attach listeners to other modules.
|
void |
install(IModel model)
called from the model during IModel.install(IModule).
|
static boolean |
isDisposalSuspended(IChunk chunk) |
protected IChunk |
merge(IChunk originalChunk,
IChunk newChunk)
entry point for merging chunks.
|
protected void |
mergeChunksInternal(IChunk originalChunk,
IChunk newChunk)
actually do the work or merging newChunk into originalChunk.
|
protected void |
processPendingDisposals(javolution.util.FastList<IChunk> chunkContainer,
javolution.util.FastList<IActivationBuffer> bufferContainer)
called internally at the top & bottom of the cycle and at the end of a run.
|
protected void |
processPendingEncodingAndDisposals() |
protected void |
processPendingEncodings(javolution.util.FastList<IChunk> chunkContainer,
javolution.util.FastList<IActivationBuffer> bufferContainer) |
void |
removeListener(IDeclarativeModuleListener listener) |
void |
setAssociativeLinkageSystem(IAssociativeLinkageSystem linkageSystem)
the code responsible for linking memories.
|
void |
setChunkConfigurator(IChunkConfigurator configurator) |
void |
setChunkFactory(IChunkFactory chunkFactory) |
void |
setChunkNamer(IChunkNamer namer) |
void |
setChunkTypeConfigurator(IChunkTypeConfigurator configurator) |
void |
setChunkTypeFactory(IChunkTypeFactory chunkTypeFactory) |
void |
setChunkTypeNamer(IChunkTypeNamer namer) |
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 |
setSubsymbolicChunkFactory(ISubsymbolicChunkFactory factory) |
void |
setSubsymbolicChunkTypeFactory(ISubsymbolicChunkTypeFactory factory) |
void |
setSymbolicChunkFactory(ISymbolicChunkFactory factory) |
void |
setSymbolicChunkTypeFactory(ISymbolicChunkTypeFactory factory) |
void |
uninstall(IModel model)
remove the element from this model.
|
boolean |
willEncode(IChunk chunk)
because encoding might be async, we need a method to determine if a given
chunk is scheduled for encoding
|
createBuffers, delayedFuture, delayedFuture, dispose, getExecutor, getModel, getName, getSafeName, immediateFuture, immediateReturn, setExecutor
addAdapterFactory, getAdapter, removeAdapterFactory
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
findExactMatches, findPartialMatches, getNumberOfChunks
getAdapter
public static final java.lang.String SUSPEND_DISPOSAL_KEY
protected ChunkActivationComparator _activationSorter
public AbstractDeclarativeModule(java.lang.String name)
public static void setDisposalSuspended(IChunk chunk, boolean suspend)
chunk
- public static boolean isDisposalSuspended(IChunk chunk)
public void flush()
IDeclarativeModule
flush
in interface IDeclarativeModule
public void install(IModel model)
IModule
install
in interface IModule
install
in interface IInstallable
install
in class AbstractModule
IInstallable.install(org.jactr.core.model.IModel)
public void uninstall(IModel model)
IInstallable
uninstall
in interface IInstallable
uninstall
in class AbstractModule
public void initialize()
IModule
initialize
in interface IModule
initialize
in interface IInitializable
initialize
in class AbstractModule
public void addListener(IDeclarativeModuleListener listener, java.util.concurrent.Executor executor)
addListener
in interface IDeclarativeModule
public void removeListener(IDeclarativeModuleListener listener)
removeListener
in interface IDeclarativeModule
protected void fireChunkCreated(IChunk chunk)
protected void fireChunkTypeCreated(IChunkType chunkType)
protected void fireChunkAdded(IChunk chunk)
protected void fireChunkRemoved(IChunk chunk)
protected void fireChunkDisposed(IChunk chunk)
protected void fireChunkTypeAdded(IChunkType chunkType)
protected void fireChunkTypeDisposed(IChunkType chunkType)
protected void fireChunkTypesMerged(IChunkType original, IChunkType duplicate)
protected boolean hasListeners()
protected void dispatch(DeclarativeModuleEvent event)
public IChunk getBusyChunk()
IDeclarativeModule
getBusyChunk
in interface IDeclarativeModule
public IChunk getEmptyChunk()
IDeclarativeModule
getEmptyChunk
in interface IDeclarativeModule
public IChunk getErrorChunk()
IDeclarativeModule
getErrorChunk
in interface IDeclarativeModule
public IChunk getFreeChunk()
IDeclarativeModule
getFreeChunk
in interface IDeclarativeModule
public IChunk getFullChunk()
IDeclarativeModule
getFullChunk
in interface IDeclarativeModule
public IChunk getNewChunk()
IDeclarativeModule
getNewChunk
in interface IDeclarativeModule
public IChunk getRequestedChunk()
IDeclarativeModule
getRequestedChunk
in interface IDeclarativeModule
public IChunk getUnrequestedChunk()
IDeclarativeModule
getUnrequestedChunk
in interface IDeclarativeModule
public void setChunkFactory(IChunkFactory chunkFactory)
public IChunkFactory getChunkFactory()
public void setSymbolicChunkFactory(ISymbolicChunkFactory factory)
public ISymbolicChunkFactory getSymbolicChunkFactory()
public void setSubsymbolicChunkFactory(ISubsymbolicChunkFactory factory)
public ISubsymbolicChunkFactory getSubsymbolicChunkFactory()
public void setChunkConfigurator(IChunkConfigurator configurator)
public IChunkConfigurator getChunkConfigurator()
public void setChunkNamer(IChunkNamer namer)
public IChunkNamer getChunkNamer()
public void setChunkTypeFactory(IChunkTypeFactory chunkTypeFactory)
public IChunkTypeFactory getChunkTypeFactory()
public void setSymbolicChunkTypeFactory(ISymbolicChunkTypeFactory factory)
public ISymbolicChunkTypeFactory getSymbolicChunkTypeFactory()
public void setSubsymbolicChunkTypeFactory(ISubsymbolicChunkTypeFactory factory)
public ISubsymbolicChunkTypeFactory getSubsymbolicChunkTypeFactory()
public void setChunkTypeConfigurator(IChunkTypeConfigurator configurator)
public IChunkTypeConfigurator getChunkTypeConfigurator()
public void setChunkTypeNamer(IChunkTypeNamer namer)
public IChunkTypeNamer getChunkTypeNamer()
public java.util.concurrent.CompletableFuture<IChunk> createChunk(IChunkType parent, java.lang.String name)
createChunkInternal(IChunkType, String)
on AbstractModule.getExecutor()
createChunk
in interface IDeclarativeModule
parent
- name
- IDeclarativeModule.createChunk(org.jactr.core.chunktype.IChunkType,
java.lang.String)
protected IChunk createChunkInternal(IChunkType parent, java.lang.String name)
parent
- name
- protected void configure(IChunk newChunk)
newChunk
- public java.util.concurrent.CompletableFuture<IChunk> addChunk(IChunk chunk)
addChunkInternal(IChunk, Collection)
on AbstractModule.getExecutor()
addChunk
in interface IDeclarativeModule
chunk
- IDeclarativeModule.addChunk(org.jactr.core.chunk.IChunk)
protected abstract IChunk addChunkInternal(IChunk chunkToAdd, java.util.Collection<IChunk> possibleMatches)
chunkToAdd
- possibleMatches
- TODOpublic java.util.concurrent.CompletableFuture<IChunk> copyChunk(IChunk sourceChunk)
copyChunk
in interface IDeclarativeModule
public java.util.concurrent.CompletableFuture<IChunk> copyChunk(IChunk sourceChunk, boolean copySubsymbolics)
copyChunk
in interface IDeclarativeModule
protected void copyChunkInternal(IChunk sourceChunk, IChunk destination, boolean copySubsymbolics)
sourceChunk
- copy
- public java.util.concurrent.CompletableFuture<IChunk> getChunk(java.lang.String name)
getChunk
in interface IDeclarativeModule
name
- IDeclarativeModule.getChunk(java.lang.String)
protected abstract IChunk getChunkInternal(java.lang.String chunkName)
public java.util.concurrent.CompletableFuture<java.util.Collection<IChunk>> getChunks()
IDeclarativeModule
getChunks
in interface IDeclarativeModule
IDeclarativeModule.getChunks()
protected abstract java.util.Collection<IChunk> getChunksInternal()
public java.util.concurrent.CompletableFuture<IChunkType> createChunkType(java.util.Collection<IChunkType> parents, java.lang.String name)
#createChunkTypeInternal(IChunkType, String)
on
AbstractModule.getExecutor()
createChunkType
in interface IDeclarativeModule
parent
- name
- IDeclarativeModule.createChunkType(org.jactr.core.chunktype.IChunkType,
java.lang.String)
public java.util.concurrent.CompletableFuture<IChunkType> createChunkType(IChunkType parent, java.lang.String name)
createChunkType
in interface IDeclarativeModule
protected IChunkType createChunkTypeInternal(java.util.Collection<IChunkType> parents, java.lang.String name)
protected void configure(IChunkType newChunkType)
IChunkTypeConfigurator
newChunkType
- public java.util.concurrent.CompletableFuture<IChunkType> addChunkType(IChunkType chunkType)
addChunkTypeInternal(IChunkType)
on AbstractModule.getExecutor()
addChunkType
in interface IDeclarativeModule
chunkType
- IDeclarativeModule.addChunkType(org.jactr.core.chunktype.IChunkType)
protected abstract IChunkType addChunkTypeInternal(IChunkType chunkType)
chunkType
- public java.util.concurrent.CompletableFuture<IChunkType> getChunkType(java.lang.String name)
getChunkType
in interface IDeclarativeModule
name
- IDeclarativeModule.getChunkType(java.lang.String)
protected abstract IChunkType getChunkTypeInternal(java.lang.String name)
public java.util.concurrent.CompletableFuture<java.util.Collection<IChunkType>> getChunkTypes()
getChunkTypes
in interface IDeclarativeModule
IDeclarativeModule.getChunkTypes()
protected abstract java.util.Collection<IChunkType> getChunkTypesInternal()
public void setAssociativeLinkageSystem(IAssociativeLinkageSystem linkageSystem)
IDeclarativeModule
setAssociativeLinkageSystem
in interface IDeclarativeModule
public IAssociativeLinkageSystem getAssociativeLinkageSystem()
IDeclarativeModule
getAssociativeLinkageSystem
in interface IDeclarativeModule
protected void disposeInternal(IChunk chunk)
chunk
- protected IChunk merge(IChunk originalChunk, IChunk newChunk)
mergeChunksInternal(IChunk, IChunk)
to do the real work.originalChunk
- newChunk
- protected void mergeChunksInternal(IChunk originalChunk, IChunk newChunk)
originalChunk
- newChunk
- public void dispose(IChunk chunk)
dispose
in interface IDeclarativeModule
protected void deferredEncode(IChunk chunk)
chunk
- protected void deferredEncode(java.util.Collection<IChunk> chunks)
public boolean willEncode(IChunk chunk)
IDeclarativeModule
willEncode
in interface IDeclarativeModule
protected void processPendingEncodingAndDisposals()
protected void processPendingEncodings(javolution.util.FastList<IChunk> chunkContainer, javolution.util.FastList<IActivationBuffer> bufferContainer)
protected void processPendingDisposals(javolution.util.FastList<IChunk> chunkContainer, javolution.util.FastList<IActivationBuffer> bufferContainer)