Class AbstractMemoryContext<Type>
- java.lang.Object
-
- net.emustudio.emulib.plugins.memory.AbstractMemoryContext<Type>
-
- Type Parameters:
Type
- the memory cell type
- All Implemented Interfaces:
Context
,MemoryContext<Type>
@ThreadSafe public abstract class AbstractMemoryContext<Type> extends java.lang.Object implements MemoryContext<Type>
This class implements some fundamental functionality of MemoryContext interface, that can be useful in the programming of the own memory context.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<Memory.MemoryListener>
listeners
List of all memory listeners.
-
Constructor Summary
Constructors Constructor Description AbstractMemoryContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMemoryListener(Memory.MemoryListener listener)
Adds a listener onto listeners listboolean
areMemoryNotificationsEnabled()
Determine if notifications of memory changes are globally enabled or disabled.void
notifyMemoryChanged(int position)
Notify all listeners that memory has changed.void
notifyMemorySizeChanged()
Notify listeners that memory size has changed.void
removeMemoryListener(Memory.MemoryListener listener)
Removes the listener from listeners listvoid
setMemoryNotificationsEnabled(boolean enabled)
Enable/disable notifications of memory changes globally.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.emustudio.emulib.plugins.memory.MemoryContext
clear, getDataType, getSize, read, read, write, write, write
-
-
-
-
Field Detail
-
listeners
protected final java.util.Set<Memory.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).
-
-
Method Detail
-
areMemoryNotificationsEnabled
public boolean areMemoryNotificationsEnabled()
Description copied from interface:MemoryContext
Determine if notifications of memory changes are globally enabled or disabled.- Specified by:
areMemoryNotificationsEnabled
in interfaceMemoryContext<Type>
- 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.
- Specified by:
setMemoryNotificationsEnabled
in interfaceMemoryContext<Type>
- Parameters:
enabled
- - true if enabled, false if disabled.
-
addMemoryListener
public void addMemoryListener(Memory.MemoryListener listener)
Adds a listener onto listeners list- Specified by:
addMemoryListener
in interfaceMemoryContext<Type>
- Parameters:
listener
- listener object
-
removeMemoryListener
public void removeMemoryListener(Memory.MemoryListener listener)
Removes the listener from listeners list- Specified by:
removeMemoryListener
in interfaceMemoryContext<Type>
- Parameters:
listener
- listener object
-
notifyMemoryChanged
public void notifyMemoryChanged(int position)
Notify all listeners that memory has changed. This method should be called whenever a some plugin writes to the memory.- Parameters:
position
- memory position (address) on which the value has changed
-
notifyMemorySizeChanged
public void notifyMemorySizeChanged()
Notify listeners that memory size has changed.
-
-