/*!
	@file
	@brief	タイマクラス timeGetTime() Ver.
*/

#include"CTimer_timeGetTime.h"

#include"../../Setup/Win32.h"


//WIN32_LEAN_AND_MEAN を指定してるため ヘッダがincludeされない
#include<mmsystem.h>

#pragma comment (lib,"winmm.lib" )


namespace Maid
{

int CTimer_timeGetTime::s_RefarenceCount;

CTimer_timeGetTime::CTimer_timeGetTime()
{
	if( s_RefarenceCount==0 )
	{
		::TIMECAPS TimeCaps;
		::timeGetDevCaps(&TimeCaps,sizeof(::TIMECAPS));       
		::timeBeginPeriod(TimeCaps.wPeriodMin);
	}

	++s_RefarenceCount;
}

CTimer_timeGetTime::CTimer_timeGetTime( const CTimer_timeGetTime& rha )
{
	++s_RefarenceCount;
}

CTimer_timeGetTime::~CTimer_timeGetTime()
{
	--s_RefarenceCount;

	if( s_RefarenceCount==0 )
	{
		::TIMECAPS TimeCaps;
		::timeGetDevCaps(&TimeCaps,sizeof(::TIMECAPS));       
		::timeEndPeriod(TimeCaps.wPeriodMin);
	}
}

unt CTimer_timeGetTime::Get() const
{
	return ::timeGetTime();
}

void CTimer_timeGetTime::Sleep( unt time )
{
	::Sleep( time );
}


CTimer_timeGetTime& CTimer_timeGetTime::operator = ( const CTimer_timeGetTime& rha )
{
	++s_RefarenceCount;

	return *this;
}

}


