/*
{{copyright}}
*/

/*
{{version}}
*/

/*
{{license}}
*/

#pragma once

#include <STM32Headers.h>
#include <sdi_toolBox/dateTime/iPause.h>

namespace sdi_uToolBox::dateTime
{
//--------------------------------------------------------------
/**
 * @brief STM32 pause implementation.
 *
 * Implements IPause to provide a blocking pause using HAL_Delay 
 * on STM32 platforms.
 */
class Pause : public sdi_toolBox::dateTime::IPause
{
  public:
  Pause()                                = default;     // Default constructor
  ~Pause()                               = default;     // Default destructor
  Pause(const Pause &obj)                = default;     // Copy constructor
  Pause(Pause &&obj) noexcept            = default;     // Move constructor
  Pause &operator=(const Pause &obj)     = default;     // Copy assignment operator
  Pause &operator=(Pause &&obj) noexcept = default;     // Move assignment operator

  explicit Pause(const Duration &duration);     // Constructor

  /**
   * @brief Pause execution for the specified duration using HAL_Delay.
   * @param duration Duration of the pause.
   */
  void wait(const Duration &duration) const override;
};
//--------------------------------------------------------------
/* Constructor */
inline Pause::Pause(const Duration &duration)
{
  wait(duration);
}
//--------------------------------------------------------------
/* Pause execution for the specified duration */
inline void Pause::wait(const Duration &duration) const
{
  HAL_Delay(duration.count());
}
//--------------------------------------------------------------
}     // namespace sdi_uToolBox::dateTime
