#ifndef KinectSDKPLAYERPLUGIN_H__
#define KinectSDKPLAYERPLUGIN_H__


#include "KinectSDKSourcePluginRImageSource.h"
#include "KinectSDKSourcePluginWidget.h"
#include "KinectImageIO.h"	
#include "ritkSourcePlugin.h"
#include <QTimer>

/// Automatically generated be plugin creator
class KinectSDKSourcePlugin : public ritk::SourcePlugin
{
	Q_OBJECT

public:
	/// Constructor
	KinectSDKSourcePlugin();
	/// Destructor
	~KinectSDKSourcePlugin();

	/// Get the plugins GUI @sa Plugin::GetPluginGUI
	QWidget *GetPluginGUI();

	/** @name	Player states */
	//@{
	typedef enum StateType
	{
		Disconnected,
		Connected,
		Playing, 
	} StateType;
	//@}

signals:
	/// Can be connected to a widget to request a GUI update
	void UpdateGUI();

protected:
	/// The actual source that is provided by this player
	SourcePointer GetSource();

	/// Set the state of the player
	void SetState(StateType State);

protected slots:
	/// Is connected to the widget's play button
	void Play();
	/// Is connected to the widget's pause button
	void Pause();
	/// Is connected to the widget's request next frame button
	void RequestFrame();
	/// Is connected to the widgets connect/disconnect button
	void ConnectDisconnect();


protected:
	/// The widget for this player
	KinectSDKSourcePluginWidget *m_Widget;
	/// The current state of the player
	StateType m_State;
	/// Mutex used to lock access to the state
	QMutex m_StateMutex;
	/// Timer for playing
	QTimer *m_Timer;

	KinectImageIOF2::Pointer m_KinectImageIO;

	/**	@name	The source provided by this player */
	//@{
	// Implicit template instantiation
	//typedef KinectSDKSourcePluginSource<RImageF2> KinectSDKSourcePluginSourceType;
	/// Explicit template instantiation (default)
	typedef KinectSDKSourcePluginSourceF2 KinectSDKSourcePluginSourceType;
	typedef KinectSDKSourcePluginSourceType::Pointer KinectSDKSourcePluginSourcePointer;
	/// The filter
	KinectSDKSourcePluginSourcePointer m_Source;
	//@}
};



#endif // KinectSDKPLAYERPLUGIN_H__
