// HistoryBuffer.h: interface for the CHistoryBuffer class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_HISTORYBUFFER_H__22B624D2_0DF6_40F9_A6C2_01B930A6BED4__INCLUDED_)
#define AFX_HISTORYBUFFER_H__22B624D2_0DF6_40F9_A6C2_01B930A6BED4__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <vector>
using namespace std;

#pragma pack(1)

typedef struct {
	long lBytes;
	BYTE *data;
}RECORD;

#pragma pack()

class CHistoryBuffer  
{
public:
	CHistoryBuffer();
	virtual ~CHistoryBuffer();
	
	/////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////
	//History Size Configure
	BOOL			Configure			(	ULONG		cx,				// cx = max size per entry,
											ULONG		cy );			// cy = max entries	
	/////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////
	//History Helpers
	RECORD 		   *AddData				(	BYTE		*byInput,		//ptr to byte stream 
											UINT		 uiSize );		//number of bytes in stream
	
	RECORD		   *GetRecord			(	UINT		 uiIndex );		//Get a record, ZERO BASED INDEX!!!					 
	
	RECORD		   *GetNextRecord		(	void );						//Get the next unprocessed record

	UINT			GetCount			(	void );						//Get number of records					

private:

	/////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////
	//History Variables
	vector<RECORD>  m_vecHistoryBuffer;									//Record Buffer pointers into BYTE buffer
	BYTE		   *m_byDataBuffer;										//Buffer stores imagery of MAX size
		
	UINT		    m_uiFront;											//Index to where next record goes
	UINT		    m_uiRear;											//Index to last record
		
	UINT			m_uiTotalRecords;									//Logical number of records								
	UINT			m_uiMaxRecords;										//Max records to store
	UINT			m_uiMaxLineBytes;									//Max bytes per history line
};

#endif // !defined(AFX_HISTORYBUFFER_H__22B624D2_0DF6_40F9_A6C2_01B930A6BED4__INCLUDED_)
