//-----------------------------------------------------------------------------
#ifndef DevCtrlH
#define DevCtrlH DevCtrlH
//-----------------------------------------------------------------------------
#include <map>
#include <mvIMPACT_CPP/mvIMPACT_acquire.h>
#include <string>
#include <wx/thread.h>

class	CaptureThread;
class	PropData;
class	PropTree;
class	wxPropertyGrid;
struct	DeviceData;
class	wxWindow;

typedef std::map<const mvIMPACT::acquire::Device*, DeviceData*> DevToTreeMap;
typedef std::pair<const mvIMPACT::acquire::Device*, DeviceData*> DevTreePair;

//-----------------------------------------------------------------------------
class DevicePropertyHandler
//-----------------------------------------------------------------------------
{
public:
	DevicePropertyHandler( wxPropertyGrid* pGrid, bool boDisplayDebugInfo, bool boDisplayFullTree, bool boDisplayInvisibleComponents );
	~DevicePropertyHandler();
	enum TViewMode
	{
		vmStandard,
		vmDeveloper
	};
	void											CloseDriver( const std::string& name );
	mvIMPACT::acquire::Device*						GetActiveDevice( mvIMPACT::acquire::FunctionInterface** ppFI = 0, const mvIMPACT::acquire::Statistics** ppS = 0, CaptureThread** ppCT = 0 ) const;
	bool											GetDeviceData( mvIMPACT::acquire::Device* pDev, mvIMPACT::acquire::FunctionInterface** ppFI = 0, const mvIMPACT::acquire::Statistics** ppS = 0, CaptureThread** ppCT = 0 ) const;
	const mvIMPACT::acquire::DeviceManager&			GetDevMgr( void ) const { return m_devMgr; }
	TViewMode										GetViewMode( void ) const { return m_viewMode; }
	void											OpenDriver( const std::string& name, wxWindow* pParentWindow );
	void											SetActiveDevice( const std::string& name );
	void											SetViewMode( TViewMode mode );
	void											ValidateTrees( void );

private:
	unsigned int						m_actDevListChangedCounter;
	bool								m_boDisplayDebugInfo;
	bool								m_boDisplayInvisibleComponents;
	unsigned int						m_fullTreeChangedCounter;
	PropTree*							m_pFullTree;
	mvIMPACT::acquire::DeviceManager	m_devMgr;
	DevToTreeMap						m_devToTreeMap;
	const DeviceData*					m_pActiveDevData;
	mvIMPACT::acquire::Device*			m_pActiveDevice;
	wxPropertyGrid*						m_pPropertyGrid;
	mutable wxCriticalSection			m_critSect;
	TViewMode							m_viewMode;
	void								UpdateTreeMap( void );
	void								CreateDriverTrees( DevToTreeMap::iterator& it );
	void								DeleteDriverTrees( DevToTreeMap::iterator& it );
	void								PrepareTreeArray( void );

	struct TreeProp
	{	
		TreeProp( char*lname, char*dname )
		{	
			ListName = lname;
			DisplayName = dname;
			ChangedCounter = 0;
		}
		std::string		ListName;
		std::string		DisplayName;
		unsigned int	ChangedCounter;
	};
	std::vector<TreeProp>				m_vTreeProps;
};

#endif // DevCtrlH
