Class AbstractMemoryContext<CellType>

java.lang.Object
net.emustudio.emulib.plugin.memory.AbstractMemoryContext<CellType>
Type Parameters:
CellType - the memory cell type
All Implemented Interfaces:
Context, MemoryContext<CellType>

@ThreadSafe public abstract class AbstractMemoryContext<CellType> extends Object implements MemoryContext<CellType>
This class implements some fundamental functionality of MemoryContext interface, that can be useful in the programming of the own memory context.
  • Field Details

    • listeners

      protected final Set<MemoryContext.MemoryListener> listeners
      List of all memory listeners. The listeners are objects implementing the IMemoryListener interface. Methods within the listeners are called on some events that happen inside memory (e.g. value change).
  • Constructor Details

    • AbstractMemoryContext

      protected AbstractMemoryContext()
      Constructs new abstract memory context.
  • Method Details

    • areMemoryNotificationsEnabled

      public boolean areMemoryNotificationsEnabled()
      Description copied from interface: MemoryContext
      Determine if notifications of memory changes are globally enabled or disabled.
      Specified by:
      areMemoryNotificationsEnabled in interface MemoryContext<CellType>
      Returns:
      true if notifications are enabled, false if disabled.
    • setMemoryNotificationsEnabled

      public void setMemoryNotificationsEnabled(boolean enabled)
      Description copied from interface: MemoryContext
      Enable/disable notifications of memory changes globally.

      Enabled by default. Usually it is disabled by CPU when in a "running" state.

      Specified by:
      setMemoryNotificationsEnabled in interface MemoryContext<CellType>
      Parameters:
      enabled - - true if enabled, false if disabled.
    • addMemoryListener

      public void addMemoryListener(MemoryContext.MemoryListener listener)
      Adds a listener onto listeners list
      Specified by:
      addMemoryListener in interface MemoryContext<CellType>
      Parameters:
      listener - listener object
    • removeMemoryListener

      public void removeMemoryListener(MemoryContext.MemoryListener listener)
      Removes the listener from listeners list
      Specified by:
      removeMemoryListener in interface MemoryContext<CellType>
      Parameters:
      listener - listener object
    • notifyMemoryContentChanged

      public void notifyMemoryContentChanged(int fromLocation, int toLocation)
      Notify all listeners that memory content has changed at given positions.

      This method should be called by a memory context, whenever a write() is invoked.

      Parameters:
      fromLocation - from location
      toLocation - to location
    • notifyMemoryContentChanged

      public void notifyMemoryContentChanged(int location)
      Notify all listeners that memory content has changed at given positions.

      This method should be called by a memory context, whenever a write() is invoked.

      Parameters:
      location - memory location
    • notifyMemorySizeChanged

      public void notifyMemorySizeChanged()
      Notify listeners that memory size has changed.