Source code for job_shop_lib.dispatching._history_observer

"""Home of the `HistoryObserver` class."""

from job_shop_lib.dispatching import DispatcherObserver, Dispatcher
from job_shop_lib import ScheduledOperation


[docs] class HistoryObserver(DispatcherObserver): """Observer that stores the history of the dispatcher.""" def __init__(self, dispatcher: Dispatcher, *, subscribe: bool = True): super().__init__(dispatcher, subscribe=subscribe) self.history: list[ScheduledOperation] = []
[docs] def update(self, scheduled_operation: ScheduledOperation): self.history.append(scheduled_operation)
[docs] def reset(self): self.history = []