Source code for kosmos.dqc_scheduling.event

from dataclasses import dataclass

from kosmos.protocols.protocol import Protocol


[docs] @dataclass(frozen=True) class EventId: """Identifier of an event. Attributes: value (str): Identifier string. """ value: str def __post_init__(self) -> None: """Validate that the value is non-empty.""" if not self.value or not self.value.strip(): msg = "EventId must be a non-empty string." raise ValueError(msg) def __str__(self) -> str: """Return the string value.""" return self.value
[docs] @dataclass class Event: """Event for scheduling within the Simulator. Attributes: time (int): Time at which the event is scheduled. id (EventId): Event identifier. protocol (Protocol): Event's protocol. """ time: int id: EventId protocol: Protocol def __lt__(self, other: object) -> bool: """Order events by time for priority-queue usage (e.g., heapq).""" if not isinstance(other, Event): return NotImplemented return self.time < other.time