using System;
using System.Text;
using Medivators.BusinessObjects;

namespace Medivators.Parser
{
	public interface ICacheItem
	{
		long PendingOperationID { get; set; }
		bool DBVerified { get; set; }
		string Key { get; }
		bool Equals(ICacheItem Item);
	}
	
	abstract public class CacheItem : ICacheItem
	{
		private long _pendingID  = 0;
		private bool _dbVerified = false;

		abstract public string Key { get; }

		#region ICacheItem Members

		public long PendingOperationID 
		{
			get { return _pendingID; }
			set { _pendingID = value; }
		}
		public bool DBVerified
		{
			get { return _dbVerified; }
			set { _dbVerified = value; }
		}
		public abstract bool Equals(ICacheItem Item);

		#endregion
	}

	public class LogRecordCacheItem : CacheItem
	{
		private IDeviceRecord _record;

		public LogRecordCacheItem(IDeviceRecord Record)
		{
			_record = Record;
		}
		public IDeviceRecord Record
		{
			get { return _record ; }
			set { _record = value; }
		}
		public override string Key
		{
			get { return _record.Key; }
		}
		public override bool Equals(ICacheItem Item)
		{
			LogRecordCacheItem i = (LogRecordCacheItem)Item;
			return (this.Record.Equals((IDeviceRecord)i.Record));
		}
		public bool Equals(IDeviceRecord Record)
		{
			return (this.Record.Equals(Record));
		}
		public override string ToString()
		{
			return _record.ToString();
		}
	}

	public class CycleReportCacheItem : CacheItem
	{
		private CycleReport _report;

		public CycleReportCacheItem(CycleReport Report)
		{
			_report = Report;
		}
		public CycleReport Report
		{
			get { return _report; }
			set { _report = value; }
		}
		public override string Key
		{
			get { return _report.Key; }
		}
		public override bool Equals(ICacheItem Item)
		{
			CycleReportCacheItem i = (CycleReportCacheItem)Item;
			return (this.Report.Equals(i.Report));
		}
		public bool Equals(CycleReport Report)
		{
			return (this.Report.Equals(Report));
		}
		public override string ToString()
		{
			return _report.ToString();
		}
	}
}
