Interface MemoryContext<CellType>

  • Type Parameters:
    CellType - type of the memory cell
    All Superinterfaces:
    Context
    All Known Implementing Classes:
    AbstractMemoryContext

    public interface MemoryContext<CellType>
    extends Context
    This memory context supports basic methods for accessing the memory, like reading and writing memory cells. If the memory wants to support additional functionality, it should extend this interface. Plugins which need the specific memory contexts, should declare a dependency on the memory plugin.
    • Method Detail

      • read

        CellType read​(int memoryPosition)
        Reads one cell from a memory.
        Parameters:
        memoryPosition - memory position (address) of the read cell
        Returns:
        read cell
      • readWord

        CellType[] readWord​(int memoryPosition)
        Reads two adjacent cells from a memory at once. Implementation of return value is up to plugin programmer (e.g. ordering of cells). If cells in memory are pure bytes (java type is e.g. short), concatenation can be realized as (in small endian):
         
         result = (mem[from]&0xFF) | ((mem[from+1]<<8)&0xFF);
         
         
        and in big endian as:
         
         result = ((mem[from]<<8)&0xFF) | (mem[from+1]&0xFF);
         
         
        Parameters:
        memoryPosition - memory position (address) of the read cells
        Returns:
        two read cells, accessible at indexes 0 and 1, respectively.
      • write

        void write​(int memoryPosition,
                   CellType value)
        Write one cell-size (e.g. byte) data to a cell to a memory at specified location.
        Parameters:
        memoryPosition - memory position (address) of the cell where data will be written
        value - data to be written
      • writeWord

        void writeWord​(int memoryPosition,
                       CellType[] value)
        Write two cell-size (e.g. word - usually two bytes) data to a cell to a memory at specified location.
        Parameters:
        memoryPosition - memory position (address) of the cell with index 0
        value - two cells at indexes 0 and 1, respectively.
      • getDataType

        java.lang.Class<CellType> getDataType()
        Get the type of memory cells.
        Returns:
        Java data type of memory cells
      • clear

        void clear()
        Clears the memory.
      • addMemoryListener

        void addMemoryListener​(Memory.MemoryListener listener)
        Adds the specified memory listener to receive memory events from this memory. Memory events occur even if single cell is changed in memory. If listener is null, no exception is thrown and no action is performed.
        Parameters:
        listener - the memory listener
      • removeMemoryListener

        void removeMemoryListener​(Memory.MemoryListener listener)
        Removes the specified memory listener so that it no longer receives memory events from this memory. Memory events occur even if single cell is changed in memory. If listener is null, no exception is thrown and no action is performed.
        Parameters:
        listener - the memory listener to be removed
      • getSize

        int getSize()
        Get memory size. The size is a number of cells of the generic type T.
        Returns:
        memory size
      • setMemoryNotificationsEnabled

        void setMemoryNotificationsEnabled​(boolean enabled)
        Enable/disable notifications of memory changes globally. Enabled by default.
        Parameters:
        enabled - - true if enabled, false if disabled.
      • areMemoryNotificationsEnabled

        boolean areMemoryNotificationsEnabled()
        Determine if notifications of memory changes are globally enabled or disabled.
        Returns:
        true if notifications are enabled, false if disabled.