org.jactr.core.chunk
Interface IChunk

All Superinterfaces:
Commentable, java.lang.Comparable<IChunk>, IMetaContainer
All Known Implementing Classes:
AbstractChunk, DefaultChunk5

public interface IChunk
extends java.lang.Comparable<IChunk>, Commentable, IMetaContainer

The basic chunk wrapper to contain the symbolic and subsymbolic portions. It is also the point of access for all event notification.

Author:
harrison

Method Summary
 void addListener(IChunkListener cl, java.util.concurrent.Executor executor)
          add a chunk listener that will be notified with this executor
 void addListener(IParameterListener pl, java.util.concurrent.Executor executor)
          add a parameter listener that will be notified with this executor
 void dispatch(ChunkEvent chunkEvent)
          dispatch an event.
 void dispatch(ParameterEvent parameterEvent)
          dispatch parameter event
 void dispose()
          called when one is sure that this chunk will NEVER be used.
 void encode(double when)
          flag that this chunk has been encoded
 boolean equalsSymbolic(IChunk chunk)
          returns true if the symbolic contents of the two chunks are the same, i.e.
 IModel getModel()
          get the model that is responsible for this chunk, note: the chunk may not have been encoded yet
 java.util.concurrent.locks.Lock getReadLock()
          return the read lock for this chunk.
 ISubsymbolicChunk getSubsymbolicChunk()
          return the subsymbolic portion of the chunk
 ISymbolicChunk getSymbolicChunk()
          return the symbolic component of the chunk
 java.util.concurrent.locks.Lock getWriteLock()
          return the read lock for this chunk.
 boolean hasBeenDisposed()
           
 boolean hasListeners()
          are there listeners attached?
 boolean hasParameterListeners()
          are there parameter listeners?
 boolean isA(IChunkType ct)
          is this chunk this type (checks all ancestors)
 boolean isAStrict(IChunkType ct)
          is this chunk's immediate type this
 boolean isEncoded()
          has this chunk been encoded?
 boolean isMutable()
          will return true if this chunks slots can be changed after encoding (like visual-location chunks).
 void removeListener(IChunkListener cl)
          remove said listener
 void removeListener(IParameterListener pl)
          remove said listener
 void setMutable(boolean isMutable)
          set that this chunk should be considered mutable
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface org.jactr.core.utils.Commentable
getComment, setComment
 
Methods inherited from interface org.jactr.core.utils.IMetaContainer
getMetaData, getMetaDataKeys, setMetaData
 

Method Detail

addListener

void addListener(IChunkListener cl,
                 java.util.concurrent.Executor executor)
add a chunk listener that will be notified with this executor

Parameters:
cl -
executor -

addListener

void addListener(IParameterListener pl,
                 java.util.concurrent.Executor executor)
add a parameter listener that will be notified with this executor

Parameters:
pl -
executor -

removeListener

void removeListener(IChunkListener cl)
remove said listener

Parameters:
cl -

removeListener

void removeListener(IParameterListener pl)
remove said listener

Parameters:
pl -

hasListeners

boolean hasListeners()
are there listeners attached?

Returns:

hasParameterListeners

boolean hasParameterListeners()
are there parameter listeners?

Returns:

dispatch

void dispatch(ChunkEvent chunkEvent)
dispatch an event. this is public so that ISymbolicChunk and ISubsymbolicChunk can access it and is not intended to be called by those outside the chunk domain

Parameters:
chunkEvent -

dispatch

void dispatch(ParameterEvent parameterEvent)
dispatch parameter event

Parameters:
parameterEvent -

getSubsymbolicChunk

ISubsymbolicChunk getSubsymbolicChunk()
return the subsymbolic portion of the chunk

Returns:

getSymbolicChunk

ISymbolicChunk getSymbolicChunk()
return the symbolic component of the chunk

Returns:
The ISymbolicChunk value
Since:

encode

void encode(double when)
flag that this chunk has been encoded

Parameters:
when - TODO

isEncoded

boolean isEncoded()
has this chunk been encoded?

Returns:

dispose

void dispose()
called when one is sure that this chunk will NEVER be used. This should only be called by the IDeclarativeModule. To dispose of a chunk, use IDeclarativeModule.dispose(IChunk) instead

Since:

hasBeenDisposed

boolean hasBeenDisposed()
Returns:
true iff the chunk has been disposed

isA

boolean isA(IChunkType ct)
is this chunk this type (checks all ancestors)

Parameters:
ct -
Returns:

isAStrict

boolean isAStrict(IChunkType ct)
is this chunk's immediate type this


isMutable

boolean isMutable()
will return true if this chunks slots can be changed after encoding (like visual-location chunks). These chunks are not searchable by the declarative memory system

Returns:

setMutable

void setMutable(boolean isMutable)
set that this chunk should be considered mutable

Parameters:
isMutable -

getModel

IModel getModel()
get the model that is responsible for this chunk, note: the chunk may not have been encoded yet

Returns:

equalsSymbolic

boolean equalsSymbolic(IChunk chunk)
returns true if the symbolic contents of the two chunks are the same, i.e. same chunktype and slot values

Parameters:
chunk - cannot be null
Returns:
true if they are the same symbolically

getReadLock

java.util.concurrent.locks.Lock getReadLock()
return the read lock for this chunk. this is an internal method made public so that all sym/subsym chunks can access it.
These locks are provided for fine-grained locking. Course use (spanning complex methods) makes deadlock a possibility.
when using the read or write locks it is important to make sure that Lock.unlock() is wrapped within the finally clause.

Additionally, to prevent deadlock, only one chunk at a time should be locked and the locks must be released before event notification.
You should also not save references to the lock, as merging may change the lock, rendering saved references invalid.

Returns:

getWriteLock

java.util.concurrent.locks.Lock getWriteLock()
return the read lock for this chunk. this is an internal method made public so that all sym/subsym chunks can access it
These locks are provided for fine-grained locking. Course use (spanning complex methods) makes deadlock a possibility.
when using the read or write locks it is important to make sure that Lock.unlock() is wrapped within the finally clause.

Additionally, to prevent deadlock, only one chunk at a time should be locked and the locks must be released before event notification.
You should also not save references to the lock, as merging may change the lock, rendering saved references invalid.

Returns: