瀏覽代碼

Add interface class StatechartMemoryInterface

Joeri Exelmans 5 年之前
父節點
當前提交
1dcba925d9
共有 1 個文件被更改,包括 14 次插入1 次删除
  1. 14 1
      src/sccd/statechart/dynamic/memory_snapshot.py

+ 14 - 1
src/sccd/statechart/dynamic/memory_snapshot.py

@@ -1,8 +1,19 @@
 from sccd.action_lang.dynamic.memory import *
 from sccd.util import timer
 
+class StatechartMemoryInterface(MemoryInterface):
+  # Notify the memory implementation that a transition was completed.
+  @abstractmethod
+  def flush_transition(self):
+    pass
+
+  # Notify the memory implementation that its 'round' was completed and therefore the snapshot should be refreshed.
+  @abstractmethod
+  def flush_round(self):
+    pass
+
 # Non-snapshotting memory. Basically delegates all operations.
-class StatechartMemory(MemoryInterface):
+class StatechartMemory(StatechartMemoryInterface):
   __slots__ = ["delegate"]
 
   def __init__(self, delegate: MemoryInterface):
@@ -29,6 +40,8 @@ class StatechartMemory(MemoryInterface):
   def _get_frame(self, offset):
     return self.delegate._get_frame(offset)
 
+  # No shapshots are maintained, so the following 2 methods don't have to do anything:
+
   def flush_transition(self):
     pass