// DataTransfer.h: interface for the CDataTransfer class.
//
//////////////////////////////////////////////////////////////////////
 /*      
 *          Copyright (C) 2000 RasSimTech Ltd. 
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version. 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details. 
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
 */

#if !defined(AFX_DATATRANSFER_H__9BED14E3_32F1_11D4_99EE_00104B70C01B__INCLUDED_)
#define AFX_DATATRANSFER_H__9BED14E3_32F1_11D4_99EE_00104B70C01B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <vector>

#define DATA_TYPE double

class CDataTransfer  
{
public:
	CDataTransfer(int iDataSize, int iClassID=1);
	virtual ~CDataTransfer();

public:
	HANDLE GetCurrentMap(LPCTSTR lpstrMapName);
	void ReadData();
	void WriteData();

	void SetData(int iIndex,double dValue){m_vdData[iIndex]=dValue;};
	double dGetData(int iIndex){return(m_vdData[iIndex]);};

protected:
	void ErrorHandler(CString strString);

	CString m_strMutexName;
	CString m_strFileName;
	CString m_strMapName;
	HANDLE m_hMapFile;
	LPVOID m_lpMapAddress;
	HANDLE m_hFile;

	HANDLE CreateMapFile(LPCTSTR lpstrMapFileName);
	HANDLE CreateMap(HANDLE hFileToBeMapped, LPCTSTR lpstrMapName); 
	LPVOID MapView(HANDLE hMap);
	int m_iBufferSize;
	int m_iDataSizeBytes;

	std::vector<DATA_TYPE> m_vdData;
};

#endif // !defined(AFX_DATATRANSFER_H__9BED14E3_32F1_11D4_99EE_00104B70C01B__INCLUDED_)
