/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2015 Raytrix GmbH. All rights reserved.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once

#include <cstdint>
#include "RxCore.h"

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// namespace: Rx
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace Rx
{
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>
	/// 	Timer class for time measurements.
	/// </summary>
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	class RXCORE_API CTimer
	{
	public:

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// 	Default constructor.
		/// </summary>
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		CTimer();

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// 	Constructor with possibility to start the timer immediately.
		/// </summary>
		///
		/// <param name="bStart"> If true, start the timer immediately. If false, call CTimer::Start to start the timer manually. </param>
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		CTimer(bool bStart);

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// 	Destructor.
		/// </summary>
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		~CTimer();

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// 	Starts this timer. This resets the starting time.
		/// </summary>
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		void Start();

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// 	Gets the elapsed time in milliseconds since CTimer::Start has been called.
		/// </summary>
		///
		/// <returns> The elapsed time in milliseconds. </returns>
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		double ElapsedMilliseconds();

	private:

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// 	Get the current performance counter.
		/// </summary>
		///
		/// <returns> The current counter. </returns>
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		int64_t _GetCurrentCounter();

	private:

		int64_t m_i64StartCounter;
		int64_t m_i64TicksPerSecond;
	};
}
