# radar_data_reader/core/structures/__init__.py

"""
This package contains all data structure definitions, organized by functionality.
This __init__.py file re-exports all key classes to provide a unified
namespace under `radar_data_reader.core.structures`.

It also defines the top-level DataBatch class, which aggregates all other
parsed data blocks.
"""

from dataclasses import dataclass, field
from typing import List, Optional

# Import all structure definitions from submodules
from .base_structures import *
from .ge_header_structures import *
from .cdpsts_structures import *
from .d1553_structures import *
from .generic_structures import *
from .tracking_structures import *


# Define the main aggregator class here, after all dependencies are loaded.
@dataclass
class DataBatch:
    """
    Represents a complete data batch, typically starting with a DspHeaderIn
    and containing various subsequent data blocks.
    """

    batch_id: int
    blocks: List[BaseBlock] = field(default_factory=list)
    cdp_sts_results: Optional["CdpStsBlock"] = None
    timer_data: Optional["TimerBlock"] = None
    aesa_data: Optional["AesaBlock"] = None
    d1553_data: Optional["D1553Block"] = None
    exp_data: Optional["ExpBlock"] = None
    pc_data: Optional["PcBlock"] = None
    det_data: Optional["DetBlock"] = None
    stt_data: Optional["SttBlock"] = None

    @property
    def main_header(self) -> Optional["DspHeaderIn"]:
        """Convenience property to access the main DspHeaderIn block."""
        for block in self.blocks:
            if isinstance(block, DspHeaderIn):
                return block
        return None