/* vim: set tabstop=4:softtabstop=4:shiftwidth=4:noexpandtab */
/*
 * SSTT - Simplified Spatial Target Tracker
 *
 * (c) Copyrights 2007-2018 Hartmut Seichter
 */

#ifndef PW_CORE_TIMER_HPP_
#define PW_CORE_TIMER_HPP_


#include <pw/core/globals.hpp>

#include <chrono>

namespace pw {

/**
 * @brief A simple timer
 */
class timer {
public:

    const static unsigned int UnitMicroSeconds = 1000000;
    const static unsigned int UnitMilliSeconds = 1000;
    const static unsigned int UnitSeconds = 1;

	typedef std::chrono::time_point<std::chrono::high_resolution_clock> tick_t;

	timer(); /// c'tor
	~timer(); /// d'tor

    void reset(); /// reset the timer

    /**
     * @brief elapsed time based on the scale
     * @param scale units the time will be reported
     * @return value of the time since last @see reset
     */
    double elapsed(unsigned int scale = UnitMilliSeconds) const;

    /**
     * @brief Now
     * @param scale
     * @return
     */
    static double now(unsigned int scale = UnitMicroSeconds);

protected:

	tick_t _start;
};

}


#endif
