56 lines
1.5 KiB
C++
56 lines
1.5 KiB
C++
/*
|
|
{{copyright}}
|
|
*/
|
|
|
|
/*
|
|
{{version}}
|
|
*/
|
|
|
|
/*
|
|
{{license}}
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "iTimer.h"
|
|
|
|
namespace sdi_toolBox::dateTime
|
|
{
|
|
//--------------------------------------------------------------
|
|
/**
|
|
* @brief Standard timer implementation using std::chrono.
|
|
*
|
|
* Implements ITimer using std::chrono::high_resolution_clock for
|
|
* high-precision timing in standard C++ environments.
|
|
*/
|
|
class Timer : public ITimer
|
|
{
|
|
public:
|
|
Timer(); // Default constructor
|
|
~Timer() = default; // Default destructor
|
|
Timer(const Timer &obj) = default; // Copy constructor
|
|
Timer(Timer &&obj) noexcept = default; // Move constructor
|
|
Timer &operator=(const Timer &obj) = default; // Copy assignment operator
|
|
Timer &operator=(Timer &&obj) noexcept = default; // Move assignment operator
|
|
|
|
/**
|
|
* @brief Returns the current time point using std::chrono::high_resolution_clock.
|
|
* @return The current time point.
|
|
*/
|
|
[[nodiscard]] TimePoint now() const override;
|
|
};
|
|
//--------------------------------------------------------------
|
|
/* Default constructor */
|
|
inline Timer::Timer()
|
|
{
|
|
reset();
|
|
}
|
|
//--------------------------------------------------------------
|
|
/* Get the current timepoint */
|
|
inline Timer::TimePoint Timer::now() const
|
|
{
|
|
return Clock::now();
|
|
}
|
|
//--------------------------------------------------------------
|
|
} // namespace sdi_toolBox::dateTime
|