/*
 * See the files COPYING and README for copyright information and how to reach 
 * the author.
 *
 *  $Id: chain-vdr.h,v 1.3 2006/04/24 19:43:37 lordjaxom Exp $
 */

#ifndef VDR_BURN_CHAIN_VDR_H
#define VDR_BURN_CHAIN_VDR_H

#include "common.h"
#include "proctools/chain.h"
#include <proctools/logger.h>//XXX
#include <proctools/format.h>//XXX
#include <vdr/thread.h>

namespace vdr_burn
{

	class job;
	class path_pair;

	class chain_vdr: public proctools::chain,
					 public cThread
	{
	public:
		virtual ~chain_vdr();

		void start(void) { cThread::Start(); }
		void stop(void);

		const path_pair& get_paths(void) const { return m_paths; }
		bool get_is_active(void) { return Active(); }
		int get_progress(void) const { return m_progress; }
		bool get_is_burning(void) const { return m_burning; }
	
	protected:
		chain_vdr(const std::string& name, job& job_);

		virtual void Action(void);

		void add_process(proctools::process* proc);
		std::string create_temp_path(const std::string& templ);

		void set_progress(int percent) { proctools::logger::debug(proctools::format("progress {0}") % percent); m_progress = std::min(percent, 100); }

		job& get_job(void) { return m_job; }

	private:
		job&      m_job;
		path_pair m_paths;
		int       m_progress;
		bool      m_burning;
	};

};

#endif // VDR_BURN_CHAIN_VDR_H
