using System;
using System.Data;

namespace FactorsNamespace
{
	/// <summary>
	/// Base class for factors of all types (DB,  calculating, etc)
	/// Determines base factors interface
	/// </summary>
	public abstract class FutureFactor
	{
		/// <summary>
		/// Internal name of factors. it's used for example in formulas.
		/// </summary>
		private String name;

		public String Name
		{
			get { return name; }
			set { name = value; }
		}
		
		public delegate void GetFactorValueDelegate(DataRow row);

		public GetFactorValueDelegate GetValue;

		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="name"></param>
		/// <param name="function"></param>
		public FutureFactor(String name, GetFactorValueDelegate function)
		{
			this.name = name;
			GetValue = function;
		}

		/// <summary>
		/// This function is used for displaying in list control
		/// </summary>
		/// <returns></returns>
		public override string ToString()
		{
			return this.Name;
		}



		public virtual bool IsDependentFrom(String FactorName)
		{
			return false;
		}

		public bool IsSelfDependent()
		{
			return IsDependentFrom(this.Name);
		}
	}
}