#pragma once

#include <string>

#include "chassis_calibration_service/chassis_calibration_algorithms.hpp"

namespace chassis_calibration_service
{

// 底盘标定算法门面：
// 负责输入校验、按底盘类型分发到专属实现类、再统一回填 ROS result。
// 具体算法细节放在各自的底盘专属类里，node 层不需要知道这些差异。
class ChassisCalibrationAlgorithmTemplate
{
public:
  using ExecuteTask = chassis_calibration_service::ExecuteTask;
  using ChassisType = chassis_calibration_service::ChassisType;
  using Input = ChassisCalibrationInput;
  using Output = ChassisCalibrationOutput;

  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 ChassisCalibrationAlgorithm * resolve_algorithm(const ChassisType & chassis_type) const;

  AckermannChassisAlgorithm ackermann_algorithm_;
  DifferentialChassisAlgorithm differential_algorithm_;
  SingleSteerWheelChassisAlgorithm single_steer_wheel_algorithm_;
  MultiSteerWheelChassisAlgorithm multi_steer_wheel_algorithm_;
};

}  // namespace chassis_calibration_service
