#pragma once

#include <string>

#include "sensor_calibration_service/sensor_calibration_algorithms.hpp"

namespace sensor_calibration_service
{

// 传感器标定算法门面：
// 1. 负责对 node 组装好的 SensorCalibrationInput 做统一入口校验。
// 2. 负责按任务类型分发到相机内参、IMU 内参、外参、手眼的专属实现。
// 3. 负责保持 node 层与具体算法实现解耦，方便后续整体替换某个算法 cpp 文件。
class SensorCalibrationAlgorithmTemplate
{
public:
  using Input = SensorCalibrationInput;
  using Output = SensorCalibrationOutput;
  using TaskType = sensor_calibration_service::SensorCalibrationTaskType;
  using TaskSubtype = sensor_calibration_service::SensorCalibrationTaskSubtype;

  bool run(
    const Input & input,
    Output & output,
    std::string & failure_reason) const;

private:
  bool validate_input(const Input & input, std::string & failure_reason) const;
  const SensorCalibrationAlgorithm * resolve_algorithm(
    const TaskType & task_type,
    const TaskSubtype & task_subtype) const;

  FrontCameraIntrinsicCalibrationAlgorithm front_camera_intrinsic_algorithm_;
  DownwardCameraIntrinsicCalibrationAlgorithm downward_camera_intrinsic_algorithm_;
  ImuIntrinsicCalibrationAlgorithm imu_intrinsic_algorithm_;
  FrontCameraExtrinsicCalibrationAlgorithm front_camera_extrinsic_algorithm_;
  DownwardCameraExtrinsicCalibrationAlgorithm downward_camera_extrinsic_algorithm_;
  ImuExtrinsicCalibrationAlgorithm imu_extrinsic_algorithm_;
  Lidar2DExtrinsicCalibrationAlgorithm lidar_2d_extrinsic_algorithm_;
  Lidar3DExtrinsicCalibrationAlgorithm lidar_3d_extrinsic_algorithm_;
  EyeInHandCalibrationAlgorithm eye_in_hand_algorithm_;
  EyeToHandCalibrationAlgorithm eye_to_hand_algorithm_;
};

}  // namespace sensor_calibration_service
