-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtracker.py
31 lines (21 loc) · 914 Bytes
/
tracker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""Module for base tracker."""
from typing import Any, Generic, Optional, TypeVar
T = TypeVar("T")
class Tracker(Generic[T]):
"""Base tracker class."""
def __init__(self):
self._target: Optional[T] = None
def target_builder(self, struct: T) -> T:
"""Initializes the target with the given struct.
See sipyco.sync_struct.Subscriber for details.
This will make self._target the synchronized structure of the notifier.
Args:
struct: The initial structure for the target.
"""
self._target = struct
return self._target
def notify_callback(self, mod: dict[str, Any]): # pylint: disable=unused-argument
"""Notifies modification to the tracker called as notify_cb() of sipyco system.
Args:
mod: The argument of notify_cb() called by sipyco.sync_struct.Subscriber.
"""