using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace agree.itsdb
{
	using Type = System.Type;

	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>
	/// Abstract base class for Itsdb item types
	/// </summary>
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	[StructLayout(LayoutKind.Sequential)]
	public abstract class ItsdbItemType : INotifyPropertyChanged, IEditableObject
	{
		string _Name { get { return GetType().Name.Replace("Itsdb", String.Empty).Replace('_', '-').ToLower(); } }

		public event PropertyChangedEventHandler PropertyChanged;

		protected void NotifyPropertyChanged(String s_field)
		{
			PropertyChangedEventHandler h = PropertyChanged;
			if (h != null)
				h(this, new PropertyChangedEventArgs(s_field));
		}

		public void BeginEdit()
		{
		}

		public void CancelEdit()
		{
		}

		public void EndEdit()
		{
		}
	};


	public class PrimaryKeyAttribute : Attribute
	{
	};

	public class ExternalKeyAttribute : Attribute
	{
		/// <summary>
		/// type of item in an external table which has a primary key with the matching name as the field 
		/// decorated with this attribute
		/// </summary>
		public Type ti_ext;

		/// <param name="ti_ext">
		/// type of item in an external table which has a primary key with the matching name as the field 
		/// decorated with this attribute
		/// </param>
		public ExternalKeyAttribute(Type ti_ext)
		{
			this.ti_ext = ti_ext;
		}
	};

	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/// 
	/// Item classes follow
	///
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	public class ItsdbItem : ItsdbItemType
	{
		[PrimaryKey] int _i_id;
		string _i_origin;
		string _i_register;
		string _i_format;
		int _i_difficulty;
		string _i_category;
		string _i_input;
		string _i_tokens;
		string _i_gloss;
		string _i_translation;
		int _i_wf;
		int _i_length;
		string _i_comment;
		string _i_author;
		DateTime _i_date;

		public int i_id
		{
			get { return _i_id; }
			set { if (value != _i_id) { _i_id = value; NotifyPropertyChanged("i_id"); } }
		}

		public String i_origin
		{
			get { return _i_origin; }
			set { if (value != _i_origin) { _i_origin = value; NotifyPropertyChanged("i_origin"); } }
		}

		public String i_register
		{
			get { return _i_register; }
			set { if (value != _i_register) { _i_register = value; NotifyPropertyChanged("i_register"); } }
		}

		public String i_format
		{
			get { return _i_format; }
			set { if (value != _i_format) { _i_format = value; NotifyPropertyChanged("i_format"); } }
		}

		public int i_difficulty
		{
			get { return _i_difficulty; }
			set { if (value != _i_difficulty) { _i_difficulty = value; NotifyPropertyChanged("i_difficulty"); } }
		}

		public String i_category
		{
			get { return _i_category; }
			set { if (value != _i_category) { _i_category = value; NotifyPropertyChanged("i_category"); } }
		}

		public String i_input
		{
			get { return _i_input; }
			set { if (value != _i_input) { _i_input = value; NotifyPropertyChanged("i_input"); } }
		}

		public String i_tokens
		{
			get { return _i_tokens; }
			set { if (value != _i_tokens) { _i_tokens = value; NotifyPropertyChanged("i_tokens"); } }
		}

		public String i_gloss
		{
			get { return _i_gloss; }
			set { if (value != _i_gloss) { _i_gloss = value; NotifyPropertyChanged("i_gloss"); } }
		}

		public String i_translation
		{
			get { return _i_translation; }
			set { if (value != _i_translation) { _i_translation = value; NotifyPropertyChanged("i_translation"); } }
		}

		public int i_wf
		{
			get { return _i_wf; }
			set { if (value != _i_wf) { _i_wf = value; NotifyPropertyChanged("i_wf"); } }
		}

		public int i_length
		{
			get { return _i_length; }
			set { if (value != _i_length) { _i_length = value; NotifyPropertyChanged("i_length"); } }
		}

		public String i_comment
		{
			get { return _i_comment; }
			set { if (value != _i_comment) { _i_comment = value; NotifyPropertyChanged("i_comment"); } }
		}

		public String i_author
		{
			get { return _i_author; }
			set { if (value != _i_author) { _i_author = value; NotifyPropertyChanged("i_author"); } }
		}

		public DateTime i_date
		{
			get { return _i_date; }
			set { if (value != _i_date) { _i_date = value; NotifyPropertyChanged("i_date"); } }
		}
	};


	public class ItsdbAnalysis : ItsdbItemType
	{
		[ExternalKey(typeof(ItsdbItem))] int _i_id;
		string _a_position;
		string _a_instance;
		string _a_category;
		string _a_function;
		string _a_domain;
		string _a_tag;
		string _a_comment;

		public int i_id
		{
			get { return _i_id; }
			set { if (value != _i_id) { _i_id = value; NotifyPropertyChanged("i_id"); } }
		}

		public String a_position
		{
			get { return _a_position; }
			set { if (value != _a_position) { _a_position = value; NotifyPropertyChanged("a_position"); } }
		}

		public String a_instance
		{
			get { return _a_instance; }
			set { if (value != _a_instance) { _a_instance = value; NotifyPropertyChanged("a_instance"); } }
		}

		public String a_category
		{
			get { return _a_category; }
			set { if (value != _a_category) { _a_category = value; NotifyPropertyChanged("a_category"); } }
		}

		public String a_function
		{
			get { return _a_function; }
			set { if (value != _a_function) { _a_function = value; NotifyPropertyChanged("a_function"); } }
		}

		public String a_domain
		{
			get { return _a_domain; }
			set { if (value != _a_domain) { _a_domain = value; NotifyPropertyChanged("a_domain"); } }
		}

		public String a_tag
		{
			get { return _a_tag; }
			set { if (value != _a_tag) { _a_tag = value; NotifyPropertyChanged("a_tag"); } }
		}

		public String a_comment
		{
			get { return _a_comment; }
			set { if (value != _a_comment) { _a_comment = value; NotifyPropertyChanged("a_comment"); } }
		}
	};


	public class ItsdbPhenomenon : ItsdbItemType
	{
		[PrimaryKey] int _p_id;
		string _p_name;
		string _p_supertypes;
		string _p_presupposition;
		string _p_interaction;
		string _p_purpose;
		string _p_restrictions;
		string _p_comment;
		string _p_author;
		DateTime _p_date;

		public int p_id
		{
			get { return _p_id; }
			set { if (value != _p_id) { _p_id = value; NotifyPropertyChanged("p_id"); } }
		}

		public String p_name
		{
			get { return _p_name; }
			set { if (value != _p_name) { _p_name = value; NotifyPropertyChanged("p_name"); } }
		}

		public String p_supertypes
		{
			get { return _p_supertypes; }
			set { if (value != _p_supertypes) { _p_supertypes = value; NotifyPropertyChanged("p_supertypes"); } }
		}

		public String p_presupposition
		{
			get { return _p_presupposition; }
			set { if (value != _p_presupposition) { _p_presupposition = value; NotifyPropertyChanged("p_presupposition"); } }
		}

		public String p_interaction
		{
			get { return _p_interaction; }
			set { if (value != _p_interaction) { _p_interaction = value; NotifyPropertyChanged("p_interaction"); } }
		}

		public String p_purpose
		{
			get { return _p_purpose; }
			set { if (value != _p_purpose) { _p_purpose = value; NotifyPropertyChanged("p_purpose"); } }
		}

		public String p_restrictions
		{
			get { return _p_restrictions; }
			set { if (value != _p_restrictions) { _p_restrictions = value; NotifyPropertyChanged("p_restrictions"); } }
		}

		public String p_comment
		{
			get { return _p_comment; }
			set { if (value != _p_comment) { _p_comment = value; NotifyPropertyChanged("p_comment"); } }
		}

		public String p_author
		{
			get { return _p_author; }
			set { if (value != _p_author) { _p_author = value; NotifyPropertyChanged("p_author"); } }
		}

		public DateTime p_date
		{
			get { return _p_date; }
			set { if (value != _p_date) { _p_date = value; NotifyPropertyChanged("p_date"); } }
		}
	};


	public class ItsdbParameter : ItsdbItemType
	{
		[ExternalKey(typeof(ItsdbItem_Phenomenon))] int _ip_id;
		string _position;
		string _attribute;
		string _value;
		string _instance;
		string _pa_comment;

		public int ip_id
		{
			get { return _ip_id; }
			set { if (value != _ip_id) { _ip_id = value; NotifyPropertyChanged("ip_id"); } }
		}

		public String position
		{
			get { return _position; }
			set { if (value != _position) { _position = value; NotifyPropertyChanged("position"); } }
		}

		public String attribute
		{
			get { return _attribute; }
			set { if (value != _attribute) { _attribute = value; NotifyPropertyChanged("attribute"); } }
		}

		public String value
		{
			get { return _value; }
			set { if (value != _value) { _value = value; NotifyPropertyChanged("value"); } }
		}

		public String instance
		{
			get { return _instance; }
			set { if (value != _instance) { _instance = value; NotifyPropertyChanged("instance"); } }
		}

		public String pa_comment
		{
			get { return _pa_comment; }
			set { if (value != _pa_comment) { _pa_comment = value; NotifyPropertyChanged("pa_comment"); } }
		}
	};


	public class ItsdbSet : ItsdbItemType
	{
		[PrimaryKey] int _s_id;
		[ExternalKey(typeof(ItsdbPhenomenon))] int _p_id;
		string _s_author;
		DateTime _s_date;

		public int s_id
		{
			get { return _s_id; }
			set { if (value != _s_id) { _s_id = value; NotifyPropertyChanged("s_id"); } }
		}

		public int p_id
		{
			get { return _p_id; }
			set { if (value != _p_id) { _p_id = value; NotifyPropertyChanged("p_id"); } }
		}

		public String s_author
		{
			get { return _s_author; }
			set { if (value != _s_author) { _s_author = value; NotifyPropertyChanged("s_author"); } }
		}

		public DateTime s_date
		{
			get { return _s_date; }
			set { if (value != _s_date) { _s_date = value; NotifyPropertyChanged("s_date"); } }
		}
	};


	public class ItsdbItem_Phenomenon : ItsdbItemType
	{
		[PrimaryKey] int _ip_id;
		[ExternalKey(typeof(ItsdbItem))] int _i_id;
		[ExternalKey(typeof(ItsdbPhenomenon))] int _p_id;
		string _ip_author;
		DateTime _ip_date;

		public int ip_id
		{
			get { return _ip_id; }
			set { if (value != _ip_id) { _ip_id = value; NotifyPropertyChanged("ip_id"); } }
		}

		public int i_id
		{
			get { return _i_id; }
			set { if (value != _i_id) { _i_id = value; NotifyPropertyChanged("i_id"); } }
		}

		public int p_id
		{
			get { return _p_id; }
			set { if (value != _p_id) { _p_id = value; NotifyPropertyChanged("p_id"); } }
		}

		public String ip_author
		{
			get { return _ip_author; }
			set { if (value != _ip_author) { _ip_author = value; NotifyPropertyChanged("ip_author"); } }
		}

		public DateTime ip_date
		{
			get { return _ip_date; }
			set { if (value != _ip_date) { _ip_date = value; NotifyPropertyChanged("ip_date"); } }
		}
	};


	public class ItsdbItem_Set : ItsdbItemType
	{
		[ExternalKey(typeof(ItsdbItem))] int _i_id;
		[ExternalKey(typeof(ItsdbSet))] int _s_id;
		int _polarity;

		public int i_id
		{
			get { return _i_id; }
			set { if (value != _i_id) { _i_id = value; NotifyPropertyChanged("i_id"); } }
		}

		public int s_id
		{
			get { return _s_id; }
			set { if (value != _s_id) { _s_id = value; NotifyPropertyChanged("s_id"); } }
		}

		public int polarity
		{
			get { return _polarity; }
			set { if (value != _polarity) { _polarity = value; NotifyPropertyChanged("polarity"); } }
		}
	};


	public class ItsdbRun : ItsdbItemType
	{
		[PrimaryKey] int _run_id;				// unique test run identifier
		string _run_comment;					// descriptive narrative
		string _platform;						// implementation platform (version)
		string _tsdb;							// tsdb(1) (version) used
		string _application;					// application (version) used
		string _environment;					// application_specific information
		string _grammar;						// grammar (version) used
		int _avms;								// number of avm types in image
		int _sorts;								// number of sort types in image
		int _templates;							// number of templates in image
		int _lexicon;							// number of lexical entries
		int _lrules;							// number of lexical rules
		int _rules;								// number of (non_lexical) rules
		string _user;							// user who did the test run
		string _host;							// machine used for this run
		string _os;								// operating system (version)
		DateTime _start;						// start time of this test run
		DateTime _end;							// end time for this test run
		int _items;								// number of test items in this run
		string _status;							// exit status (PVM only)

		public int run_id
		{
			get { return _run_id; }
			set { if (value != _run_id) { _run_id = value; NotifyPropertyChanged("run_id"); } }
		}

		public String run_comment
		{
			get { return _run_comment; }
			set { if (value != _run_comment) { _run_comment = value; NotifyPropertyChanged("run_comment"); } }
		}

		public String platform
		{
			get { return _platform; }
			set { if (value != _platform) { _platform = value; NotifyPropertyChanged("platform"); } }
		}

		public String tsdb
		{
			get { return _tsdb; }
			set { if (value != _tsdb) { _tsdb = value; NotifyPropertyChanged("tsdb"); } }
		}

		public String application
		{
			get { return _application; }
			set { if (value != _application) { _application = value; NotifyPropertyChanged("application"); } }
		}

		public String environment
		{
			get { return _environment; }
			set { if (value != _environment) { _environment = value; NotifyPropertyChanged("environment"); } }
		}

		public String grammar
		{
			get { return _grammar; }
			set { if (value != _grammar) { _grammar = value; NotifyPropertyChanged("grammar"); } }
		}

		public int avms
		{
			get { return _avms; }
			set { if (value != _avms) { _avms = value; NotifyPropertyChanged("avms"); } }
		}

		public int sorts
		{
			get { return _sorts; }
			set { if (value != _sorts) { _sorts = value; NotifyPropertyChanged("sorts"); } }
		}

		public int templates
		{
			get { return _templates; }
			set { if (value != _templates) { _templates = value; NotifyPropertyChanged("templates"); } }
		}

		public int lexicon
		{
			get { return _lexicon; }
			set { if (value != _lexicon) { _lexicon = value; NotifyPropertyChanged("lexicon"); } }
		}

		public int lrules
		{
			get { return _lrules; }
			set { if (value != _lrules) { _lrules = value; NotifyPropertyChanged("lrules"); } }
		}

		public int rules
		{
			get { return _rules; }
			set { if (value != _rules) { _rules = value; NotifyPropertyChanged("rules"); } }
		}

		public String user
		{
			get { return _user; }
			set { if (value != _user) { _user = value; NotifyPropertyChanged("user"); } }
		}

		public String host
		{
			get { return _host; }
			set { if (value != _host) { _host = value; NotifyPropertyChanged("host"); } }
		}

		public String os
		{
			get { return _os; }
			set { if (value != _os) { _os = value; NotifyPropertyChanged("os"); } }
		}

		public DateTime start
		{
			get { return _start; }
			set { if (value != _start) { _start = value; NotifyPropertyChanged("start"); } }
		}

		public DateTime end
		{
			get { return _end; }
			set { if (value != _end) { _end = value; NotifyPropertyChanged("end"); } }
		}

		public int items
		{
			get { return _items; }
			set { if (value != _items) { _items = value; NotifyPropertyChanged("items"); } }
		}

		public String status
		{
			get { return _status; }
			set { if (value != _status) { _status = value; NotifyPropertyChanged("status"); } }
		}
	};


	public class ItsdbParse : ItsdbItemType
	{
		[PrimaryKey] int _parse_id;						// unique parse identifier
		[ExternalKey(typeof(ItsdbRun))] int _run_id;	// test run for this parse
		[ExternalKey(typeof(ItsdbItem))] int _i_id;		// item parsed
		string _p_input;								// actual (pre_processed) parser input
		int _readings;									// number of readings obtained
		int _first;										// time to find first reading (msec)
		int _total;										// total time for parsing (msec)
		int _tcpu;										// total (cpu) processing time (msec)
		int _tgc;										// gc time used (msec)
		int _treal;										// overall real time (msec)
		int _words;										// lexical entries retrieved
		int _l_stasks;									// successful lexical rule applications
		int _p_ctasks;									// parser contemplated tasks (LKB)
		int _p_ftasks;									// parser filtered tasks
		int _p_etasks;									// parser executed tasks
		int _p_stasks;									// parser succeeding tasks
		int _aedges;									// active items in chart (PAGE)
		int _pedges;									// passive items in chart
		int _raedges;									// active items contributing to result
		int _rpedges;									// passive items contributing to result
		long _unifications;								// number of (node) unifications
		long _copies;									// number of (node) copy operations
		long _conses;									// cons() cells allocated
		long _symbols;									// symbols allocated
		long _others;									// bytes of memory allocated
		int _gcs;										// number of garbage collections
		int _i_load;									// initial load (start of parse)
		int _a_load;									// average load
		DateTime _date;									// date and time of parse
		string _error;									// error string (if applicable |:_)
		string _comment;								// application_specific comment

		public int parse_id
		{
			get { return _parse_id; }
			set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
		}

		public int run_id
		{
			get { return _run_id; }
			set { if (value != _run_id) { _run_id = value; NotifyPropertyChanged("run_id"); } }
		}

		public int i_id
		{
			get { return _i_id; }
			set { if (value != _i_id) { _i_id = value; NotifyPropertyChanged("i_id"); } }
		}

		public String p_input
		{
			get { return _p_input; }
			set { if (value != _p_input) { _p_input = value; NotifyPropertyChanged("p_input"); } }
		}

		public int readings
		{
			get { return _readings; }
			set { if (value != _readings) { _readings = value; NotifyPropertyChanged("readings"); } }
		}

		public int first
		{
			get { return _first; }
			set { if (value != _first) { _first = value; NotifyPropertyChanged("first"); } }
		}

		public int total
		{
			get { return _total; }
			set { if (value != _total) { _total = value; NotifyPropertyChanged("total"); } }
		}

		public int tcpu
		{
			get { return _tcpu; }
			set { if (value != _tcpu) { _tcpu = value; NotifyPropertyChanged("tcpu"); } }
		}

		public int tgc
		{
			get { return _tgc; }
			set { if (value != _tgc) { _tgc = value; NotifyPropertyChanged("tgc"); } }
		}

		public int treal
		{
			get { return _treal; }
			set { if (value != _treal) { _treal = value; NotifyPropertyChanged("treal"); } }
		}

		public int words
		{
			get { return _words; }
			set { if (value != _words) { _words = value; NotifyPropertyChanged("words"); } }
		}

		public int l_stasks
		{
			get { return _l_stasks; }
			set { if (value != _l_stasks) { _l_stasks = value; NotifyPropertyChanged("l_stasks"); } }
		}

		public int p_ctasks
		{
			get { return _p_ctasks; }
			set { if (value != _p_ctasks) { _p_ctasks = value; NotifyPropertyChanged("p_ctasks"); } }
		}

		public int p_ftasks
		{
			get { return _p_ftasks; }
			set { if (value != _p_ftasks) { _p_ftasks = value; NotifyPropertyChanged("p_ftasks"); } }
		}

		public int p_etasks
		{
			get { return _p_etasks; }
			set { if (value != _p_etasks) { _p_etasks = value; NotifyPropertyChanged("p_etasks"); } }
		}

		public int p_stasks
		{
			get { return _p_stasks; }
			set { if (value != _p_stasks) { _p_stasks = value; NotifyPropertyChanged("p_stasks"); } }
		}

		public int aedges
		{
			get { return _aedges; }
			set { if (value != _aedges) { _aedges = value; NotifyPropertyChanged("aedges"); } }
		}

		public int pedges
		{
			get { return _pedges; }
			set { if (value != _pedges) { _pedges = value; NotifyPropertyChanged("pedges"); } }
		}

		public int raedges
		{
			get { return _raedges; }
			set { if (value != _raedges) { _raedges = value; NotifyPropertyChanged("raedges"); } }
		}

		public int rpedges
		{
			get { return _rpedges; }
			set { if (value != _rpedges) { _rpedges = value; NotifyPropertyChanged("rpedges"); } }
		}

		public long unifications
		{
			get { return _unifications; }
			set { if (value != _unifications) { _unifications = value; NotifyPropertyChanged("unifications"); } }
		}

		public long copies
		{
			get { return _copies; }
			set { if (value != _copies) { _copies = value; NotifyPropertyChanged("copies"); } }
		}

		public long conses
		{
			get { return _conses; }
			set { if (value != _conses) { _conses = value; NotifyPropertyChanged("conses"); } }
		}

		public long symbols
		{
			get { return _symbols; }
			set { if (value != _symbols) { _symbols = value; NotifyPropertyChanged("symbols"); } }
		}

		public long others
		{
			get { return _others; }
			set { if (value != _others) { _others = value; NotifyPropertyChanged("others"); } }
		}

		public int gcs
		{
			get { return _gcs; }
			set { if (value != _gcs) { _gcs = value; NotifyPropertyChanged("gcs"); } }
		}

		public int i_load
		{
			get { return _i_load; }
			set { if (value != _i_load) { _i_load = value; NotifyPropertyChanged("i_load"); } }
		}

		public int a_load
		{
			get { return _a_load; }
			set { if (value != _a_load) { _a_load = value; NotifyPropertyChanged("a_load"); } }
		}

		public DateTime date
		{
			get { return _date; }
			set { if (value != _date) { _date = value; NotifyPropertyChanged("date"); } }
		}

		public String error
		{
			get { return _error; }
			set { if (value != _error) { _error = value; NotifyPropertyChanged("error"); } }
		}

		public String comment
		{
			get { return _comment; }
			set { if (value != _comment) { _comment = value; NotifyPropertyChanged("comment"); } }
		}
	};


	public class ItsdbResult : ItsdbItemType
	{
		[ExternalKey(typeof(ItsdbParse))] int _parse_id;		// parse for this result
		[PrimaryKey] int _result_id;							// unique result identifier
		int _time;												// time to find this result (msec)
		int _r_ctasks;											// parser contemplated tasks
		int _r_ftasks;											// parser filtered tasks
		int _r_etasks;											// parser executed tasks
		int _r_stasks;											// parser succeeding tasks
		int _size;												// size of feature structure
		int _r_aedges;											// active items for this result
		int _r_pedges;											// passive items in this result
		string _derivation;										// derivation tree for this reading
		string _surface;										// surface string (e.g. realization)
		string _tree;											// phrase structure tree (CSLI labels)
		string _mrs;											// mrs for this reading
		string _flags;											// arbitrary annotation (e.g. BLEU)

		public int parse_id
		{
			get { return _parse_id; }
			set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
		}

		public int result_id
		{
			get { return _result_id; }
			set { if (value != _result_id) { _result_id = value; NotifyPropertyChanged("result_id"); } }
		}

		public int time
		{
			get { return _time; }
			set { if (value != _time) { _time = value; NotifyPropertyChanged("time"); } }
		}

		public int r_ctasks
		{
			get { return _r_ctasks; }
			set { if (value != _r_ctasks) { _r_ctasks = value; NotifyPropertyChanged("r_ctasks"); } }
		}

		public int r_ftasks
		{
			get { return _r_ftasks; }
			set { if (value != _r_ftasks) { _r_ftasks = value; NotifyPropertyChanged("r_ftasks"); } }
		}

		public int r_etasks
		{
			get { return _r_etasks; }
			set { if (value != _r_etasks) { _r_etasks = value; NotifyPropertyChanged("r_etasks"); } }
		}

		public int r_stasks
		{
			get { return _r_stasks; }
			set { if (value != _r_stasks) { _r_stasks = value; NotifyPropertyChanged("r_stasks"); } }
		}

		public int size
		{
			get { return _size; }
			set { if (value != _size) { _size = value; NotifyPropertyChanged("size"); } }
		}

		public int r_aedges
		{
			get { return _r_aedges; }
			set { if (value != _r_aedges) { _r_aedges = value; NotifyPropertyChanged("r_aedges"); } }
		}

		public int r_pedges
		{
			get { return _r_pedges; }
			set { if (value != _r_pedges) { _r_pedges = value; NotifyPropertyChanged("r_pedges"); } }
		}

		public String derivation
		{
			get { return _derivation; }
			set { if (value != _derivation) { _derivation = value; NotifyPropertyChanged("derivation"); } }
		}

		public String surface
		{
			get { return _surface; }
			set { if (value != _surface) { _surface = value; NotifyPropertyChanged("surface"); } }
		}

		public String tree
		{
			get { return _tree; }
			set { if (value != _tree) { _tree = value; NotifyPropertyChanged("tree"); } }
		}

		public String mrs
		{
			get { return _mrs; }
			set { if (value != _mrs) { _mrs = value; NotifyPropertyChanged("mrs"); } }
		}

		public String flags
		{
			get { return _flags; }
			set { if (value != _flags) { _flags = value; NotifyPropertyChanged("flags"); } }
		}
	};


	public class ItsdbRule : ItsdbItemType
	{
		[ExternalKey(typeof(ItsdbParse))] int _parse_id;			// parse for this rule summary
		string _rule;												// rule name
		int _filtered;												// rule postulations filtered
		int _executed;												// rule postulations executed
		int _successes;												// successful rule postulations
		int _actives;												// active edges built from this rule
		int _passives;												// passive edges built from this rule

		public int parse_id
		{
			get { return _parse_id; }
			set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
		}

		public String rule
		{
			get { return _rule; }
			set { if (value != _rule) { _rule = value; NotifyPropertyChanged("rule"); } }
		}

		public int filtered
		{
			get { return _filtered; }
			set { if (value != _filtered) { _filtered = value; NotifyPropertyChanged("filtered"); } }
		}

		public int executed
		{
			get { return _executed; }
			set { if (value != _executed) { _executed = value; NotifyPropertyChanged("executed"); } }
		}

		public int successes
		{
			get { return _successes; }
			set { if (value != _successes) { _successes = value; NotifyPropertyChanged("successes"); } }
		}

		public int actives
		{
			get { return _actives; }
			set { if (value != _actives) { _actives = value; NotifyPropertyChanged("actives"); } }
		}

		public int passives
		{
			get { return _passives; }
			set { if (value != _passives) { _passives = value; NotifyPropertyChanged("passives"); } }
		}
	};


	public class ItsdbOutput : ItsdbItemType
	{
		[ExternalKey(typeof(ItsdbItem))] int _i_id;				// item for this output specification
		string _o_application;									// applicable appliaction(s)
		string _o_grammar;										// applicable grammar(s)
		string _o_ignore;										// ignore this item flag
		int _o_wf;												// application_specific grammaticality
		int _o_gc;												// maximal number of garbage collections
		string _o_derivation;									// expected derivation
		string _o_surface;										// expected surface string
		string _o_tree;											// expected phrase structure tree
		string _o_mrs;											// expected mrs
		int _o_edges;											// maximal number of edges to build
		string _o_user;											// author of this output specification
		DateTime _o_date;										// creation date

		public int i_id
		{
			get { return _i_id; }
			set { if (value != _i_id) { _i_id = value; NotifyPropertyChanged("i_id"); } }
		}

		public String o_application
		{
			get { return _o_application; }
			set { if (value != _o_application) { _o_application = value; NotifyPropertyChanged("o_application"); } }
		}

		public String o_grammar
		{
			get { return _o_grammar; }
			set { if (value != _o_grammar) { _o_grammar = value; NotifyPropertyChanged("o_grammar"); } }
		}

		public String o_ignore
		{
			get { return _o_ignore; }
			set { if (value != _o_ignore) { _o_ignore = value; NotifyPropertyChanged("o_ignore"); } }
		}

		public int o_wf
		{
			get { return _o_wf; }
			set { if (value != _o_wf) { _o_wf = value; NotifyPropertyChanged("o_wf"); } }
		}

		public int o_gc
		{
			get { return _o_gc; }
			set { if (value != _o_gc) { _o_gc = value; NotifyPropertyChanged("o_gc"); } }
		}

		public String o_derivation
		{
			get { return _o_derivation; }
			set { if (value != _o_derivation) { _o_derivation = value; NotifyPropertyChanged("o_derivation"); } }
		}

		public String o_surface
		{
			get { return _o_surface; }
			set { if (value != _o_surface) { _o_surface = value; NotifyPropertyChanged("o_surface"); } }
		}

		public String o_tree
		{
			get { return _o_tree; }
			set { if (value != _o_tree) { _o_tree = value; NotifyPropertyChanged("o_tree"); } }
		}

		public String o_mrs
		{
			get { return _o_mrs; }
			set { if (value != _o_mrs) { _o_mrs = value; NotifyPropertyChanged("o_mrs"); } }
		}

		public int o_edges
		{
			get { return _o_edges; }
			set { if (value != _o_edges) { _o_edges = value; NotifyPropertyChanged("o_edges"); } }
		}

		public String o_user
		{
			get { return _o_user; }
			set { if (value != _o_user) { _o_user = value; NotifyPropertyChanged("o_user"); } }
		}

		public DateTime o_date
		{
			get { return _o_date; }
			set { if (value != _o_date) { _o_date = value; NotifyPropertyChanged("o_date"); } }
		}
	};


	public class ItsdbEdge : ItsdbItemType
	{
		[PrimaryKey] int _e_id;								// unique edge identifier
		[ExternalKey(typeof(ItsdbParse))] int _parse_id;	// parse for this edge
		string _e_name;										// edge label (as in `derivation')
		int _e_status;										// 0 : passive;1 : active
		int _e_result;										// 0 : nope;1 : yup, result
		int _e_start;										// start vertex for this edge
		int _e_end;											// end vertex for this edge
		string _e_daughters;								// (Common_Lisp) list of daughters
		string _e_parents;									// (Common_Lisp) list of parents
		string _e_alternates;								// alternates packed into this edge

		public int e_id
		{
			get { return _e_id; }
			set { if (value != _e_id) { _e_id = value; NotifyPropertyChanged("e_id"); } }
		}

		public int parse_id
		{
			get { return _parse_id; }
			set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
		}

		public String e_name
		{
			get { return _e_name; }
			set { if (value != _e_name) { _e_name = value; NotifyPropertyChanged("e_name"); } }
		}

		public int e_status
		{
			get { return _e_status; }
			set { if (value != _e_status) { _e_status = value; NotifyPropertyChanged("e_status"); } }
		}

		public int e_result
		{
			get { return _e_result; }
			set { if (value != _e_result) { _e_result = value; NotifyPropertyChanged("e_result"); } }
		}

		public int e_start
		{
			get { return _e_start; }
			set { if (value != _e_start) { _e_start = value; NotifyPropertyChanged("e_start"); } }
		}

		public int e_end
		{
			get { return _e_end; }
			set { if (value != _e_end) { _e_end = value; NotifyPropertyChanged("e_end"); } }
		}

		public String e_daughters
		{
			get { return _e_daughters; }
			set { if (value != _e_daughters) { _e_daughters = value; NotifyPropertyChanged("e_daughters"); } }
		}

		public String e_parents
		{
			get { return _e_parents; }
			set { if (value != _e_parents) { _e_parents = value; NotifyPropertyChanged("e_parents"); } }
		}

		public String e_alternates
		{
			get { return _e_alternates; }
			set { if (value != _e_alternates) { _e_alternates = value; NotifyPropertyChanged("e_alternates"); } }
		}
	};


	public class ItsdbTree : ItsdbItemType
	{
		[ExternalKey(typeof(ItsdbParse))] int _parse_id;
		int _t_version;
		int _t_active;				// :key (2011-01-30 gcs ??)
		int _t_confidence;
		string _t_author;
		DateTime _t_start;
		DateTime _t_end;
		string _t_comment;

		public int parse_id
		{
			get { return _parse_id; }
			set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
		}

		public int t_version
		{
			get { return _t_version; }
			set { if (value != _t_version) { _t_version = value; NotifyPropertyChanged("t_version"); } }
		}

		public int t_active
		{
			get { return _t_active; }
			set { if (value != _t_active) { _t_active = value; NotifyPropertyChanged("t_active"); } }
		}

		public int t_confidence
		{
			get { return _t_confidence; }
			set { if (value != _t_confidence) { _t_confidence = value; NotifyPropertyChanged("t_confidence"); } }
		}

		public String t_author
		{
			get { return _t_author; }
			set { if (value != _t_author) { _t_author = value; NotifyPropertyChanged("t_author"); } }
		}

		public DateTime t_start
		{
			get { return _t_start; }
			set { if (value != _t_start) { _t_start = value; NotifyPropertyChanged("t_start"); } }
		}

		public DateTime t_end
		{
			get { return _t_end; }
			set { if (value != _t_end) { _t_end = value; NotifyPropertyChanged("t_end"); } }
		}

		public String t_comment
		{
			get { return _t_comment; }
			set { if (value != _t_comment) { _t_comment = value; NotifyPropertyChanged("t_comment"); } }
		}
	};


	public class ItsdbDecision : ItsdbItemType
	{
		[ExternalKey(typeof(ItsdbParse))] int _parse_id;
		int _t_version;
		int _d_state;
		int _d_type;
		string _d_key;
		string _d_value;
		int _d_start;
		int _d_end;
		DateTime _d_date;

		public int parse_id
		{
			get { return _parse_id; }
			set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
		}

		public int t_version
		{
			get { return _t_version; }
			set { if (value != _t_version) { _t_version = value; NotifyPropertyChanged("t_version"); } }
		}

		public int d_state
		{
			get { return _d_state; }
			set { if (value != _d_state) { _d_state = value; NotifyPropertyChanged("d_state"); } }
		}

		public int d_type
		{
			get { return _d_type; }
			set { if (value != _d_type) { _d_type = value; NotifyPropertyChanged("d_type"); } }
		}

		public String d_key
		{
			get { return _d_key; }
			set { if (value != _d_key) { _d_key = value; NotifyPropertyChanged("d_key"); } }
		}

		public String d_value
		{
			get { return _d_value; }
			set { if (value != _d_value) { _d_value = value; NotifyPropertyChanged("d_value"); } }
		}

		public int d_start
		{
			get { return _d_start; }
			set { if (value != _d_start) { _d_start = value; NotifyPropertyChanged("d_start"); } }
		}

		public int d_end
		{
			get { return _d_end; }
			set { if (value != _d_end) { _d_end = value; NotifyPropertyChanged("d_end"); } }
		}

		public DateTime d_date
		{
			get { return _d_date; }
			set { if (value != _d_date) { _d_date = value; NotifyPropertyChanged("d_date"); } }
		}
	};


	public class ItsdbPreference : ItsdbItemType
	{
		[ExternalKey(typeof(ItsdbParse))] int _parse_id;
		int _t_version;
		[ExternalKey(typeof(ItsdbResult))] int _result_id;

		public int parse_id
		{
			get { return _parse_id; }
			set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
		}

		public int t_version
		{
			get { return _t_version; }
			set { if (value != _t_version) { _t_version = value; NotifyPropertyChanged("t_version"); } }
		}

		public int result_id
		{
			get { return _result_id; }
			set { if (value != _result_id) { _result_id = value; NotifyPropertyChanged("result_id"); } }
		}
	};


	public class ItsdbUpdate : ItsdbItemType
	{
		[ExternalKey(typeof(ItsdbParse))] int _parse_id; int _t_version;
		int _u_matches;
		int _u_mismatches;
		int _u_new;
		int _u_gin;
		int _u_gout;
		int _u_pin;
		int _u_pout;
		int _u_in;
		int _u_out;

		public int parse_id
		{
			get { return _parse_id; }
			set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
		}

		public int t_version
		{
			get { return _t_version; }
			set { if (value != _t_version) { _t_version = value; NotifyPropertyChanged("t_version"); } }
		}

		public int u_matches
		{
			get { return _u_matches; }
			set { if (value != _u_matches) { _u_matches = value; NotifyPropertyChanged("u_matches"); } }
		}

		public int u_mismatches
		{
			get { return _u_mismatches; }
			set { if (value != _u_mismatches) { _u_mismatches = value; NotifyPropertyChanged("u_mismatches"); } }
		}

		public int u_new
		{
			get { return _u_new; }
			set { if (value != _u_new) { _u_new = value; NotifyPropertyChanged("u_new"); } }
		}

		public int u_gin
		{
			get { return _u_gin; }
			set { if (value != _u_gin) { _u_gin = value; NotifyPropertyChanged("u_gin"); } }
		}

		public int u_gout
		{
			get { return _u_gout; }
			set { if (value != _u_gout) { _u_gout = value; NotifyPropertyChanged("u_gout"); } }
		}

		public int u_pin
		{
			get { return _u_pin; }
			set { if (value != _u_pin) { _u_pin = value; NotifyPropertyChanged("u_pin"); } }
		}

		public int u_pout
		{
			get { return _u_pout; }
			set { if (value != _u_pout) { _u_pout = value; NotifyPropertyChanged("u_pout"); } }
		}

		public int u_in
		{
			get { return _u_in; }
			set { if (value != _u_in) { _u_in = value; NotifyPropertyChanged("u_in"); } }
		}

		public int u_out
		{
			get { return _u_out; }
			set { if (value != _u_out) { _u_out = value; NotifyPropertyChanged("u_out"); } }
		}
	};


	public class ItsdbFold : ItsdbItemType
	{
		[PrimaryKey] int _f_id;
		int _f_train;
		string _f_trains;
		int _f_test;
		string _f_tests;
		int _f_events;
		int _f_features;
		string _f_environment;
		int _f_iterations;
		int _f_etime;
		string _f_estimation;
		string _f_accuracy;
		string _f_extras;
		string _f_user;
		string _f_host;
		DateTime _f_start;
		DateTime _f_end;
		string _f_comment;

		public int f_id
		{
			get { return _f_id; }
			set { if (value != _f_id) { _f_id = value; NotifyPropertyChanged("f_id"); } }
		}

		public int f_train
		{
			get { return _f_train; }
			set { if (value != _f_train) { _f_train = value; NotifyPropertyChanged("f_train"); } }
		}

		public String f_trains
		{
			get { return _f_trains; }
			set { if (value != _f_trains) { _f_trains = value; NotifyPropertyChanged("f_trains"); } }
		}

		public int f_test
		{
			get { return _f_test; }
			set { if (value != _f_test) { _f_test = value; NotifyPropertyChanged("f_test"); } }
		}

		public String f_tests
		{
			get { return _f_tests; }
			set { if (value != _f_tests) { _f_tests = value; NotifyPropertyChanged("f_tests"); } }
		}

		public int f_events
		{
			get { return _f_events; }
			set { if (value != _f_events) { _f_events = value; NotifyPropertyChanged("f_events"); } }
		}

		public int f_features
		{
			get { return _f_features; }
			set { if (value != _f_features) { _f_features = value; NotifyPropertyChanged("f_features"); } }
		}

		public String f_environment
		{
			get { return _f_environment; }
			set { if (value != _f_environment) { _f_environment = value; NotifyPropertyChanged("f_environment"); } }
		}

		public int f_iterations
		{
			get { return _f_iterations; }
			set { if (value != _f_iterations) { _f_iterations = value; NotifyPropertyChanged("f_iterations"); } }
		}

		public int f_etime
		{
			get { return _f_etime; }
			set { if (value != _f_etime) { _f_etime = value; NotifyPropertyChanged("f_etime"); } }
		}

		public String f_estimation
		{
			get { return _f_estimation; }
			set { if (value != _f_estimation) { _f_estimation = value; NotifyPropertyChanged("f_estimation"); } }
		}

		public String f_accuracy
		{
			get { return _f_accuracy; }
			set { if (value != _f_accuracy) { _f_accuracy = value; NotifyPropertyChanged("f_accuracy"); } }
		}

		public String f_extras
		{
			get { return _f_extras; }
			set { if (value != _f_extras) { _f_extras = value; NotifyPropertyChanged("f_extras"); } }
		}

		public String f_user
		{
			get { return _f_user; }
			set { if (value != _f_user) { _f_user = value; NotifyPropertyChanged("f_user"); } }
		}

		public String f_host
		{
			get { return _f_host; }
			set { if (value != _f_host) { _f_host = value; NotifyPropertyChanged("f_host"); } }
		}

		public DateTime f_start
		{
			get { return _f_start; }
			set { if (value != _f_start) { _f_start = value; NotifyPropertyChanged("f_start"); } }
		}

		public DateTime f_end
		{
			get { return _f_end; }
			set { if (value != _f_end) { _f_end = value; NotifyPropertyChanged("f_end"); } }
		}

		public String f_comment
		{
			get { return _f_comment; }
			set { if (value != _f_comment) { _f_comment = value; NotifyPropertyChanged("f_comment"); } }
		}
	};


	public class ItsdbScore : ItsdbItemType
	{
		[ExternalKey(typeof(ItsdbParse))] int _parse_id;
		[ExternalKey(typeof(ItsdbResult))] int _result_id;
		int _score_start;
		int _score_end;
		[PrimaryKey] int _score_id;
		string _learner;
		int _rank;
		string _score;

		public int parse_id
		{
			get { return _parse_id; }
			set { if (value != _parse_id) { _parse_id = value; NotifyPropertyChanged("parse_id"); } }
		}

		public int result_id
		{
			get { return _result_id; }
			set { if (value != _result_id) { _result_id = value; NotifyPropertyChanged("result_id"); } }
		}

		public int score_start
		{
			get { return _score_start; }
			set { if (value != _score_start) { _score_start = value; NotifyPropertyChanged("score_start"); } }
		}

		public int score_end
		{
			get { return _score_end; }
			set { if (value != _score_end) { _score_end = value; NotifyPropertyChanged("score_end"); } }
		}

		public int score_id
		{
			get { return _score_id; }
			set { if (value != _score_id) { _score_id = value; NotifyPropertyChanged("score_id"); } }
		}

		public String learner
		{
			get { return _learner; }
			set { if (value != _learner) { _learner = value; NotifyPropertyChanged("learner"); } }
		}

		public int rank
		{
			get { return _rank; }
			set { if (value != _rank) { _rank = value; NotifyPropertyChanged("rank"); } }
		}

		public String score
		{
			get { return _score; }
			set { if (value != _score) { _score = value; NotifyPropertyChanged("score"); } }
		}
	};
}