/* 

   Copyright (C) Arnaud Houdelette		2012-2014
   Copyright (C) Emmanuel Langlois		2012-2014

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using System.Threading;
using System.Xml;

namespace DMX2
{
	public abstract class DriverDMX: IDisposable
	{
		string id;

		public string ID {
			get {
				return id;
			}
			set {
				id = value;
			}
		}

		public DriverDMX (string _id) 
		{
			id=_id;
		}

		public abstract Gtk.Widget GetUI();


		protected bool disposed = false;		

		public static DriverDMX Load (Conduite conduite, XmlElement el)
		{
			switch (el.Name) {
			case "DriverBoitierV1":
				return DriverBoitierV1.Load(conduite, el);
			case "DriverBoitierV2":
				return DriverBoitierV2.Load(conduite,el);
			case "DriverBoitierV3":
				return DriverBoitierV3.Load(conduite,el);
			}
			return null;
		}

		public abstract void Save (XmlElement parent);

		#region IDisposable implementation

		public virtual void Dispose()
		{
			disposed = true;
		}

		void IDisposable.Dispose ()
		{
			if(!disposed)
				Dispose();
		}
		#endregion
	}
}

