/*
 * (c) 2005 Research Group Dr. Fuhrmann, University of Karlsruhe, Germany
 * All rights reserved.
 *
 * Author:
 *         Stefan Denk <denk@ira.uka.de>
 *         Kendy Kutzner <kutzner@ira.uka.de>
 *
 * $Id: downloadstatus.h,v 1.6 2006/01/05 10:31:45 denk Exp $
 *
 */

#ifndef _DOWNLOADSTATUS_H_
#define _DOWNLOADSTATUS_H_

// stdlib

#include <string>
using namespace std;

// vidtrans
#include "snippet.h"

// vdr
#include <thread.h>

/**
 * Remember the state of a task on disk.
 * The task state is kept in class snippet.
 * This class keeps the snippets on disk.
 */

class downloadstatus {
	public:
		/// Tell what directory we are talking about.
		int switchdir(string dir);
		/// Access one snippet.
		snippet & operator[](unsigned int which);
		/// Initialize.
		downloadstatus();
		/// Write things to disk, close files.
		~downloadstatus();
	private:
		/// File descriptor of the file on disk.
		int _snippetfile;
		/// Pointer to snippets in memory. This memory is mapped to a file on disk.
		snippet * _snippets;
		/// Remember what we mmap()ed. If _length is zero, nothing is maped
		size_t _length;
		/// Just a shortcut
		size_t _snippetsize;
		/// Return reference to dummy object if everything else fails
		snippet _dummy;
		/// To prevent volatile errors
		static cMutex mutex;
};



#endif // _DOWNLOADSTATUS_H_
