+class _InactivityNotificationClockValuesIterator(collections.abc.Iterator):
+ def __init__(self, notif_clock_values):
+ self._notif_clock_values = notif_clock_values
+ self._clock_classes = list(notif_clock_values._notif.clock_class_priority_map)
+ self._at = 0
+
+ def __next__(self):
+ if self._at == len(self._clock_classes):
+ raise StopIteration
+
+ self._at += 1
+ return self._clock_classes[at]
+
+
+class _InactivityNotificationClockValues(collections.abc.Mapping):
+ def __init__(self, notif):
+ self._notif = notif
+
+ def __getitem__(self, clock_class):
+ utils._check_type(clock_class, bt2.ClockClass)
+ clock_value_ptr = native_bt.notification_inactivity_get_clock_value(self._notif._ptr,
+ clock_class._ptr)
+
+ if clock_value_ptr is None:
+ return
+
+ clock_value = bt2.clock_value._create_clock_value_from_ptr(clock_value_ptr)
+ return clock_value
+
+ def add(self, clock_value):
+ utils._check_type(clock_value, bt2.clock_value._ClockValue)
+ ret = native_bt.notification_inactivity_set_clock_value(self._notif._ptr,
+ clock_value._ptr)
+ utils._handle_ret(ret, "cannot set inactivity notification object's clock value")
+
+ def __len__(self):
+ return len(self._notif.clock_class_priority_map)
+
+ def __iter__(self):
+ return _InactivityNotificationClockValuesIterator(self)
+
+