#pragma once

#include <windows.h>
#include <mmsystem.h>
#include "list.h"

class CClock
{
public:
	LARGE_INTEGER m_StartTime;
	LARGE_INTEGER m_LastFrame;
	LARGE_INTEGER m_ThisFrame;
	LARGE_INTEGER m_RunTime;
	DWORD m_FrameTime;
	DWORD m_dwRunTime;
	
	bool m_bUsingQPF;
	LONGLONG m_TicksPerSec;

	float m_AvgFPS;
	float m_AvgFPSAllFrames;
	float m_AnimMultiplier;
	DWORD m_FPSInterval;
	DWORD m_FrameCounter;

	DWORD m_FPSFrameCounter;
	LARGE_INTEGER m_LastFPSUpdate;

	LList<LONGLONG> m_CaptureTimes;

public:
	CClock(void);
	~CClock(void);
	void Reset(void);
	void Tick(void);

	void StartCapture(const unsigned CaptureID);
	void EndCapture(const unsigned CaptureID);
	LONGLONG GetCaptureTime(const unsigned CaptureID) const;
	void ClearCapture(const unsigned CaptureID);

	//GetFunctions

	float AnimMultiplier(void) const { return m_AnimMultiplier; }
	unsigned FrameTime(void) const { return m_FrameTime; } //duration of last frame in ticks
	unsigned StartTime(void) const { return (unsigned)m_StartTime.QuadPart; }
	unsigned RunTime(void) const { return m_dwRunTime; } //runtime in ms
	float AvgFPS(void) const { return m_AvgFPS; }
	float AvgFPSAllFrames(void) const { return m_AvgFPSAllFrames; }
	unsigned FrameCounter(void) const { return m_FrameCounter; }
	LONGLONG GetTicksPerSec(void) const { return m_TicksPerSec; }
};
