X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.machine%2Fsrc%2Fnet%2Fmograsim%2Fmachine%2FMemory.java;h=77c0d48bb44c048207aadc5ba4c8edd0566432ba;hb=7b8035a065c7b64f38850907d519f9a7dfb67e24;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..77c0d48b 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() + 1); + } + + /** + * 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(); }