#ifndef INTEGRATOR_H
#define INTEGRATOR_H

#include <memory>
#include <array>

class Rocket;
class Environment;
class ForcesModel;
class FlightState;

/**
 * @brief Advances the rocket's flight state using numerical integration.
 *
 * The Integrator uses simple time-stepping methods (e.g., Euler, RK4) to
 * update position, velocity, and optionally orientation and angular velocity.
 */
class Integrator {
public:
    /**
     * @brief Constructs a new Integrator.
     * @param rocket Pointer to the rocket being simulated.
     * @param forcesModel Pointer to the forces model.
     */
    Integrator(std::shared_ptr<Rocket> rocket,
               std::shared_ptr<ForcesModel> forcesModel);

    /**
     * @brief Default destructor.
     */
    ~Integrator() = default;

    /**
     * @brief Advances the flight state forward by one time step.
     * @param state The flight state to update.
     * @param deltaTime Time step size (seconds).
     */
    void step(FlightState& state, const std::array<double, 3>& netForce, double deltaTime);

private:
    std::shared_ptr<Rocket> rocket_; ///< Rocket model reference.
    std::shared_ptr<ForcesModel> forcesModel_; ///< Forces model reference.

    /**
     * @brief Performs simple Euler integration for translational motion.
     * @param state Current flight state.
     * @param netForce Force vector acting on rocket [N].
     * @param deltaTime Time step size (seconds).
     */
    void eulerIntegration(FlightState& state,
                           const std::array<double, 3>& netForce,
                           double deltaTime);
};

#endif // INTEGRATOR_H