/*++
*******************************************************************************
* Copyright (c) 1990-98 Digi International Inc., All Rights Reserved				*
* 																										*
* This software contains proprietary and confidential information of Digi		*
* International Inc.  By accepting transfer of this copy, Recipient agrees		*
* to retain this software in confidence, to prevent disclosure to others,		*
* and to make no use of this software other than that for which it was			*
* delivered.  This is an unpublished copyrighted work of Digi International	*
* Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly	*
* prohibited.																						*
* 																										*
* Restricted Rights Legend																		*
*																										*
* Use, duplication, or disclosure by the Government is subject to					*
* restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in			*
* Technical Data and Computer Software clause at DFARS 252.227-7031 or			*
* subparagraphs (c)(1) and (2) of the Commercial Computer Software -				*
* Restricted Rights at 48 CFR 52.227-19, as applicable.								*
*																										*
* Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343				*
*																										*
*******************************************************************************

Module Name:

   config.h

Abstract:

	abstract bases class representing an adapter.  The adapter's job is to get the 
	memory requested with GetMemory

Author:

   Rodger Bernstein

--*/

#ifndef _CONFIG_
#define _CONFIG_

class CAdapter;

// The idea of 'm_Registry' is the make the support of different types
// of adapters modular. You make a CAdapter derived class and add it the
// the adpater registry. The string to you register the runtime class is
// the ProductName stored with the adapter area in the NT registry. If
// you want multiple ProductName strings to map to the same CAdapter derived
// class then just add one registry entry for each ProductName string.

class CAdapter : public CObject
{
	DECLARE_DYNCREATE(CAdapter);
	static CTypedPtrMap<CMapStringToPtr,CString,CRuntimeClass *> m_Registry;
	
	friend class CSummaryDlg;

protected:
// ************************************************
// info obtains when data source was created
// this is hardwired to hold only two drivers but can be changed
// to resizable array when Dxb and more drivers get in the picture
	struct sDriverInfo
	{
		CString m_DriverName;
		CString m_DriverVersion;
		CString m_DriverDate;
	};
	CArray<sDriverInfo, sDriverInfo&> m_Drivers;
	CString m_FirmwareVersion;

// ************************************************

	CString m_Name; // adapter name
	HANDLE m_hFile; // handle to Sxb driver, opened only once and kept open

// asyncronous call to talk to driver, times out in one tenth second
	static void GetDriverInfo(sDriverInfo& Info, const CString& keyName);

	CAdapter() : CObject() { m_hFile = NULL; };

public:
	virtual ~CAdapter() { if (m_hFile) CloseHandle(m_hFile); };

// Attributes
	CString GetName() const { return m_Name; };

// Operations
	virtual BOOL LoadConfig(const CString&) { VERIFY(FALSE); return FALSE; };
	virtual void LoadSummaryInfo(CStringArray&, const CString&) { VERIFY(FALSE); };

	BOOL TestAdapter(const CString& DeviceName, CString& error);
	void DoSummaryDlg(const CString&);

	virtual BOOL GetMemory(DWORD, LPBYTE, DWORD *) const { VERIFY(FALSE); return FALSE; };
	virtual BOOL SetMemory(DWORD, LPBYTE, DWORD *) { VERIFY(FALSE); return FALSE; };

	static void AddAdapter(CString keyName, CRuntimeClass *rtc) { m_Registry.SetAt(keyName, rtc); };
	static CRuntimeClass *RegistryLookUp(const CString& key) { return m_Registry[key]; };
};

#endif
