# acmenra_cv/instance/enums.py

import logging
from enum import Enum


logger = logging.getLogger(__name__)


class TaskType(Enum):
    """
    Enumerates supported computer vision task types for inference backends.

    Defines the operating mode of a model, determining what type of output
    it produces and how results should be post-processed. Used by Backend
    and Result classes to select appropriate processing logic.

    Each value matches the Ultralytics YOLO task naming convention for
    seamless integration with YOLO models.

    Note:
        - DETECT, SEGMENT, OBB are the primary tasks supported by YOLOBackend
        - Other tasks (POSE, CLASSIFY, RTDETR) are reserved for future backends
        - TRACK and DETECT_TRACK imply built-in tracking support
        - WORLD and E refer to specific YOLO model variants
    """

    DETECT = 'detect'              # Object detection (bounding boxes)
    SEGMENT = 'segment'            # Instance segmentation (masks + boxes)
    CLASSIFY = 'classify'          # Image classification
    POSE = 'pose'                  # Pose estimation (keypoints)
    OBB = 'obb'                    # Oriented bounding boxes (rotated)
    TRACK = 'track'                # Multi-object tracking
    DETECT_TRACK = 'detect_track'  # Detection + tracking combined
    WORLD = 'world'                # YOLO-World (open-vocabulary detection)
    E = 'e'                        # YOLOE (enhanced version)
    RTDETR = 'rtdetr'              # RT-DETR (real-time detection transformer)


class DeviceType(Enum):
    """
    Enumerates supported hardware devices for model inference.

    Defines the target execution platform for inference backends.
    Used by Backend and Result classes to select appropriate
    hardware acceleration and optimize performance.

    Device naming follows common conventions:
    - CPU/GPU/MPS: generic device types
    - CUDA/cuda:N: NVIDIA GPU with specific device index
    - NPU_*/TPU_*: specialized AI accelerators for embedded/edge
    - TENSORRT: NVIDIA TensorRT optimized inference
    - AUTO: automatic device selection based on availability

    Note:
        - AUTO lets the backend choose the best available device
        - CUDA_N variants target specific GPU in multi-GPU systems
        - NPU_* and TPU_* variants are for embedded/edge deployments
        - MPS is specific to Apple Silicon (M1/M2/M3/M4)
    """

    AUTO = 'auto'                  # Automatic device selection
    MPS = 'mps'                    # Apple Silicon (Metal Performance Shaders)
    CPU = 'cpu'                    # Central Processing Unit
    GPU = 'gpu'                    # Generic GPU (backend-specific)
    NPU = 'npu'                    # Generic Neural Processing Unit
    NPU_RK3588 = 'npu:rk3588'      # Rockchip RK3588 NPU
    NPU_INTEL = 'npu:intel'        # Intel NPU (Meteor Lake+)
    NPU_HAILO = 'npu:hailo'        # Hailo AI accelerator
    TPU = 'tpu'                    # Generic Tensor Processing Unit
    TPU_CORAL = 'tpu:coral'        # Google Coral Edge TPU
    CUDA = 'cuda'                  # NVIDIA CUDA (default device)
    CUDA_0 = 'cuda:0'              # NVIDIA CUDA device 0
    CUDA_1 = 'cuda:1'              # NVIDIA CUDA device 1
    CUDA_2 = 'cuda:2'              # NVIDIA CUDA device 2
    CUDA_3 = 'cuda:3'              # NVIDIA CUDA device 3
    TENSORRT = 'tensorrt'          # NVIDIA TensorRT optimized inference