X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.machine%2Fsrc%2Fnet%2Fmograsim%2Fmachine%2FMemory.java;h=58798c396fa1d519fed96591d849c0826175df59;hb=3813eb83f6c17041dcb67d7d2744c66a8bfdb18d;hp=8297ebb95e4600d06ae40723598791686498874d;hpb=61621670ab3ea56eea6571cc9bba5e015c9f0861;p=Mograsim.git diff --git a/net.mograsim.machine/src/net/mograsim/machine/Memory.java b/net.mograsim.machine/src/net/mograsim/machine/Memory.java index 8297ebb9..58798c39 100644 --- a/net.mograsim.machine/src/net/mograsim/machine/Memory.java +++ b/net.mograsim.machine/src/net/mograsim/machine/Memory.java @@ -16,5 +16,20 @@ public interface Memory */ public void setCell(long address, T data); - public long size(); + public default long size() + { + MemoryDefinition def = getDefinition(); + return Long.max(0, def.getMaximalAddress() - def.getMinimalAddress()); + } + + /** + * Registers an observer to be notified when a memory cell is modified + */ + public void registerObserver(MemoryObserver ob); + + public void deregisterObserver(MemoryObserver ob); + + public void notifyObservers(long address); + + public MemoryDefinition getDefinition(); }