/**
 *
  */

#include "opcodes.h"

class CSafeMemFile;

class CPartStatus
{
public:
	//
			CPartStatus(uint64 size);
			~CPartStatus();
	//
	void	Set(uint64 start, uint64 stop);
	void	Clear(uint64 start, uint64 stop);
	bool	IsComplete(uint64 start, uint64 stop);
	bool	FindFirstComplete(uint64& start, uint64& stop);
	bool	FindFirstNeeded(uint64& start, uint64& stop);
	//
	uint64	GetBytesCount() {return m_size;}
	uint16	GetPartsCount() {return (m_size + PARTSIZE - 1) / PARTSIZE;}
	uint64	GetBytesCompleted();
	uint16	GetPartsCompleted();
	uint64	GetBytesNeeded() {return GetBytesCount() - GetBytesCompleted();}
	uint16	GetPartsNeeded() {return GetPartsCount() - GetPartsCompleted();}
	// Read/Write part status vectors
	void	ReadPartStatus(CSafeMemFile* data, bool defState);
	void	WritePartStatus(CSafeMemFile* data, bool defState, bool useCrumbs = false);
private:
	uint64	m_size;
	uint8*	m_chunks;
};