#include "AutoLoop.h"

void Loop::tickPrivateSlot(void)
{
	++this->loopCounter;
	this->onTick();
	
	for ( int i=0; i< this->callBackFuncArray.size(); ++i)
	{
		this->callBackFuncArray[i]();
	}

	emit tickSignal();
}
Loop::Loop(void)
{
	QObject::connect( &this->loopTimer, SIGNAL(timeout()), this , SLOT( tickPrivateSlot()) );
}
unsigned long long Loop::getLoopCount(void)
{
	return this->loopCounter;
}
bool Loop::addConnection( const QObject *receiver, const char *member)
{
	return QObject::connect( this, SIGNAL( tickSignal()), receiver , member );
}
void Loop::start( unsigned int loopSpeed )
{
	this->loopTimer.start( loopSpeed );
}
void Loop::stop(void)
{
	this->loopTimer.stop();
}
