/*
{{copyright}}
*/

/*
{{version}}
*/

/*
{{license}}
*/

#pragma once

#include "iPause.h"

#include <thread>

namespace sdi_toolBox::dateTime
{
//--------------------------------------------------------------
/**
 * @brief Standard pause implementation.
 *
 * Implements IPause to provide a blocking pause using standard C++ mechanisms.
 * The actual delay is performed using std::this_thread::sleep_for.
 */
class Pause : public 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.
   * @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
{
  std::this_thread::sleep_for(duration);
}
//--------------------------------------------------------------
}     // namespace sdi_toolBox::dateTime
