// Span.h: interface for the Span class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_SPAN_H__2D007EAB_A54F_4563_8763_33EBBC0DF18E__INCLUDED_)
#define AFX_SPAN_H__2D007EAB_A54F_4563_8763_33EBBC0DF18E__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Insert.h"
#include "Delete.h"

class Span  
{
protected:
	DWORD Size;
	BYTE *Buffer;
	Span *Next,*Prev,*MappedTo;
	void InsertNodeAfter(Span *span);
	int FindLargestSpan(Span *comspan,DWORD *pos1,DWORD *pos2,DWORD minsize);

public:
	void DeleteChildren();
	Span(BYTE * loc,DWORD size,Span *mapto=NULL) {Buffer=loc; Size=size; MappedTo=Next=Prev=NULL; MappedTo=mapto;}
	void SpanInfo(CString &fstr,BYTE *base1,BYTE *base2);
	Span *AddSpanAt(BYTE *loc,DWORD size);
	void BuildOps(Span *sspan,CPatchOperation *OpList,const BYTE *base1,const BYTE *base2);
	Span *GetNextUnMapped();
	int MapLargestSpan(Span *comspan,DWORD minsize=64);
	virtual ~Span();
	
};

#endif // !defined(AFX_SPAN_H__2D007EAB_A54F_4563_8763_33EBBC0DF18E__INCLUDED_)
