#ifndef AUTOLOOP_H
#define AUTOLOOP_H


#include <qobject.h>
#include <QTimer>
#include <vector>
using namespace std;

///Loop cycle executing inserted callback functions.
/**
*	You can insert callback functions, which are called everytime when 
*	the loop cycle is executed. Loop speed can also be specified and 
*	the loop cycle can be started and stoped if required.
*/
class Loop : public QObject
{
	Q_OBJECT

private:
	unsigned long long loopCounter;	/**<internal loop counter*/

	QTimer loopTimer;	/**<when timer ticks then all inserted functions are called*/

private slots:
	void tickPrivateSlot( void );

public:
	bool addConnection( const QObject *receiver, const char *member ); /**<insert Qt signal connection, which is emitted when timer ticks.*/
	unsigned long long getLoopCount(void);	/**<returns value of #Loop::loopCounter*/

	vector< void (*)(void) > callBackFuncArray; /**<calback functions array, which is called when timer ticks */
	virtual void onTick(void) {};
	Loop(void);

public slots:
	void stop(void);
	void start( unsigned int loopSpeed );

signals:
	void tickSignal(void);
};

#endif