qui/models: add LocalModelManager

This commit is contained in:
Robert Jördens 2016-04-05 17:16:16 +08:00
parent 826d529756
commit 4edfd6caa4

View File

@ -3,9 +3,8 @@ from PyQt5 import QtCore
from artiq.protocols.sync_struct import Subscriber
class ModelSubscriber(Subscriber):
def __init__(self, notifier_name, model_factory):
Subscriber.__init__(self, notifier_name, self._create_model)
class ModelManager:
def __init__(self, model_factory):
self.model = None
self._model_factory = model_factory
self._setmodel_callbacks = []
@ -22,6 +21,24 @@ class ModelSubscriber(Subscriber):
cb(self.model)
class ModelSubscriber(ModelManager, Subscriber):
def __init__(self, notifier_name, model_factory):
ModelManager.__init__(self, model_factory)
Subscriber.__init__(self, notifier_name, self._create_model)
class LocalModelManager(ModelManager):
def __init__(self, model_factory):
ModelManager.__init__(self, model_factory)
self.notify_cbs = []
def init(self, struct):
self._create_model(struct)
mod = {"action": "init", "struct": struct}
for notify_cb in self.notify_cbs:
notify_cb(mod)
class _SyncSubstruct:
def __init__(self, update_cb, ref):
self.update_cb = update_cb