// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool Xbim.CodeGeneration 
//  
//     Changes to this file may cause incorrect behaviour and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------

using Xbim.Ifc4.ExternalReferenceResource;
using Xbim.Ifc4.MeasureResource;
using Xbim.Ifc4.DateTimeResource;
using Xbim.Ifc4.ActorResource;
using Xbim.Ifc4.ControlExtension;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using Xbim.Common.Metadata;
using Xbim.Common;
using Xbim.Common.Exceptions;
using Xbim.Ifc4.Interfaces;
using Xbim.Ifc4.ApprovalResource;
//## Custom using statements
//##

namespace Xbim.Ifc4.Interfaces
{
	/// <summary>
    /// Readonly interface for IfcApproval
    /// </summary>
	// ReSharper disable once PartialTypeWithSinglePart
	public partial interface @IIfcApproval : IPersistEntity, IfcResourceObjectSelect
	{
		IfcIdentifier? @Identifier { get;  set; }
		IfcLabel? @Name { get;  set; }
		IfcText? @Description { get;  set; }
		IfcDateTime? @TimeOfApproval { get;  set; }
		IfcLabel? @Status { get;  set; }
		IfcLabel? @Level { get;  set; }
		IfcText? @Qualifier { get;  set; }
		IIfcActorSelect @RequestingApproval { get;  set; }
		IIfcActorSelect @GivingApproval { get;  set; }
		IEnumerable<IIfcExternalReferenceRelationship> @HasExternalReferences {  get; }
		IEnumerable<IIfcRelAssociatesApproval> @ApprovedObjects {  get; }
		IEnumerable<IIfcResourceApprovalRelationship> @ApprovedResources {  get; }
		IEnumerable<IIfcApprovalRelationship> @IsRelatedWith {  get; }
		IEnumerable<IIfcApprovalRelationship> @Relates {  get; }
	
	}
}

namespace Xbim.Ifc4.ApprovalResource
{
	[ExpressType("IfcApproval", 626)]
	// ReSharper disable once PartialTypeWithSinglePart
	public  partial class @IfcApproval : PersistEntity, IInstantiableEntity, IIfcApproval, IContainsEntityReferences, IEquatable<@IfcApproval>
	{
		#region IIfcApproval explicit implementation
		IfcIdentifier? IIfcApproval.Identifier { 
 
			get { return @Identifier; } 
			set { Identifier = value;}
		}	
		IfcLabel? IIfcApproval.Name { 
 
			get { return @Name; } 
			set { Name = value;}
		}	
		IfcText? IIfcApproval.Description { 
 
			get { return @Description; } 
			set { Description = value;}
		}	
		IfcDateTime? IIfcApproval.TimeOfApproval { 
 
			get { return @TimeOfApproval; } 
			set { TimeOfApproval = value;}
		}	
		IfcLabel? IIfcApproval.Status { 
 
			get { return @Status; } 
			set { Status = value;}
		}	
		IfcLabel? IIfcApproval.Level { 
 
			get { return @Level; } 
			set { Level = value;}
		}	
		IfcText? IIfcApproval.Qualifier { 
 
			get { return @Qualifier; } 
			set { Qualifier = value;}
		}	
		IIfcActorSelect IIfcApproval.RequestingApproval { 
 
 
			get { return @RequestingApproval; } 
			set { RequestingApproval = value as IfcActorSelect;}
		}	
		IIfcActorSelect IIfcApproval.GivingApproval { 
 
 
			get { return @GivingApproval; } 
			set { GivingApproval = value as IfcActorSelect;}
		}	
		IEnumerable<IIfcExternalReferenceRelationship> IIfcApproval.HasExternalReferences {  get { return @HasExternalReferences; } }
		IEnumerable<IIfcRelAssociatesApproval> IIfcApproval.ApprovedObjects {  get { return @ApprovedObjects; } }
		IEnumerable<IIfcResourceApprovalRelationship> IIfcApproval.ApprovedResources {  get { return @ApprovedResources; } }
		IEnumerable<IIfcApprovalRelationship> IIfcApproval.IsRelatedWith {  get { return @IsRelatedWith; } }
		IEnumerable<IIfcApprovalRelationship> IIfcApproval.Relates {  get { return @Relates; } }
		#endregion

		//internal constructor makes sure that objects are not created outside of the model/ assembly controlled area
		internal IfcApproval(IModel model, int label, bool activated) : base(model, label, activated)  
		{
		}

		#region Explicit attribute fields
		private IfcIdentifier? _identifier;
		private IfcLabel? _name;
		private IfcText? _description;
		private IfcDateTime? _timeOfApproval;
		private IfcLabel? _status;
		private IfcLabel? _level;
		private IfcText? _qualifier;
		private IfcActorSelect _requestingApproval;
		private IfcActorSelect _givingApproval;
		#endregion
	
		#region Explicit attribute properties
		[EntityAttribute(1, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 1)]
		public IfcIdentifier? @Identifier 
		{ 
			get 
			{
				if(_activated) return _identifier;
				Activate();
				return _identifier;
			} 
			set
			{
				SetValue( v =>  _identifier = v, _identifier, value,  "Identifier", 1);
			} 
		}	
		[EntityAttribute(2, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 2)]
		public IfcLabel? @Name 
		{ 
			get 
			{
				if(_activated) return _name;
				Activate();
				return _name;
			} 
			set
			{
				SetValue( v =>  _name = v, _name, value,  "Name", 2);
			} 
		}	
		[EntityAttribute(3, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 3)]
		public IfcText? @Description 
		{ 
			get 
			{
				if(_activated) return _description;
				Activate();
				return _description;
			} 
			set
			{
				SetValue( v =>  _description = v, _description, value,  "Description", 3);
			} 
		}	
		[EntityAttribute(4, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 4)]
		public IfcDateTime? @TimeOfApproval 
		{ 
			get 
			{
				if(_activated) return _timeOfApproval;
				Activate();
				return _timeOfApproval;
			} 
			set
			{
				SetValue( v =>  _timeOfApproval = v, _timeOfApproval, value,  "TimeOfApproval", 4);
			} 
		}	
		[EntityAttribute(5, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 5)]
		public IfcLabel? @Status 
		{ 
			get 
			{
				if(_activated) return _status;
				Activate();
				return _status;
			} 
			set
			{
				SetValue( v =>  _status = v, _status, value,  "Status", 5);
			} 
		}	
		[EntityAttribute(6, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 6)]
		public IfcLabel? @Level 
		{ 
			get 
			{
				if(_activated) return _level;
				Activate();
				return _level;
			} 
			set
			{
				SetValue( v =>  _level = v, _level, value,  "Level", 6);
			} 
		}	
		[EntityAttribute(7, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 7)]
		public IfcText? @Qualifier 
		{ 
			get 
			{
				if(_activated) return _qualifier;
				Activate();
				return _qualifier;
			} 
			set
			{
				SetValue( v =>  _qualifier = v, _qualifier, value,  "Qualifier", 7);
			} 
		}	
		[EntityAttribute(8, EntityAttributeState.Optional, EntityAttributeType.Class, EntityAttributeType.None, null, null, 8)]
		public IfcActorSelect @RequestingApproval 
		{ 
			get 
			{
				if(_activated) return _requestingApproval;
				Activate();
				return _requestingApproval;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _requestingApproval = v, _requestingApproval, value,  "RequestingApproval", 8);
			} 
		}	
		[EntityAttribute(9, EntityAttributeState.Optional, EntityAttributeType.Class, EntityAttributeType.None, null, null, 9)]
		public IfcActorSelect @GivingApproval 
		{ 
			get 
			{
				if(_activated) return _givingApproval;
				Activate();
				return _givingApproval;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _givingApproval = v, _givingApproval, value,  "GivingApproval", 9);
			} 
		}	
		#endregion



		#region Inverse attributes
		[InverseProperty("RelatedResourceObjects")]
		[EntityAttribute(-1, EntityAttributeState.Mandatory, EntityAttributeType.Set, EntityAttributeType.Class, new int [] { 0 }, new int [] { -1 }, 10)]
		public IEnumerable<IfcExternalReferenceRelationship> @HasExternalReferences 
		{ 
			get 
			{
				return Model.Instances.Where<IfcExternalReferenceRelationship>(e => e.RelatedResourceObjects != null &&  e.RelatedResourceObjects.Contains(this), "RelatedResourceObjects", this);
			} 
		}
		[InverseProperty("RelatingApproval")]
		[EntityAttribute(-1, EntityAttributeState.Mandatory, EntityAttributeType.Set, EntityAttributeType.Class, new int [] { 0 }, new int [] { -1 }, 11)]
		public IEnumerable<IfcRelAssociatesApproval> @ApprovedObjects 
		{ 
			get 
			{
				return Model.Instances.Where<IfcRelAssociatesApproval>(e => Equals(e.RelatingApproval), "RelatingApproval", this);
			} 
		}
		[InverseProperty("RelatingApproval")]
		[EntityAttribute(-1, EntityAttributeState.Mandatory, EntityAttributeType.Set, EntityAttributeType.Class, new int [] { 0 }, new int [] { -1 }, 12)]
		public IEnumerable<IfcResourceApprovalRelationship> @ApprovedResources 
		{ 
			get 
			{
				return Model.Instances.Where<IfcResourceApprovalRelationship>(e => Equals(e.RelatingApproval), "RelatingApproval", this);
			} 
		}
		[InverseProperty("RelatedApprovals")]
		[EntityAttribute(-1, EntityAttributeState.Mandatory, EntityAttributeType.Set, EntityAttributeType.Class, new int [] { 0 }, new int [] { -1 }, 13)]
		public IEnumerable<IfcApprovalRelationship> @IsRelatedWith 
		{ 
			get 
			{
				return Model.Instances.Where<IfcApprovalRelationship>(e => e.RelatedApprovals != null &&  e.RelatedApprovals.Contains(this), "RelatedApprovals", this);
			} 
		}
		[InverseProperty("RelatingApproval")]
		[EntityAttribute(-1, EntityAttributeState.Mandatory, EntityAttributeType.Set, EntityAttributeType.Class, new int [] { 0 }, new int [] { -1 }, 14)]
		public IEnumerable<IfcApprovalRelationship> @Relates 
		{ 
			get 
			{
				return Model.Instances.Where<IfcApprovalRelationship>(e => Equals(e.RelatingApproval), "RelatingApproval", this);
			} 
		}
		#endregion

		#region IPersist implementation
		public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
		{
			switch (propIndex)
			{
				case 0: 
					_identifier = value.StringVal;
					return;
				case 1: 
					_name = value.StringVal;
					return;
				case 2: 
					_description = value.StringVal;
					return;
				case 3: 
					_timeOfApproval = value.StringVal;
					return;
				case 4: 
					_status = value.StringVal;
					return;
				case 5: 
					_level = value.StringVal;
					return;
				case 6: 
					_qualifier = value.StringVal;
					return;
				case 7: 
					_requestingApproval = (IfcActorSelect)(value.EntityVal);
					return;
				case 8: 
					_givingApproval = (IfcActorSelect)(value.EntityVal);
					return;
				default:
					throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper()));
			}
		}
		#endregion

		#region Equality comparers and operators
        public bool Equals(@IfcApproval other)
	    {
	        return this == other;
	    }
        #endregion

		#region IContainsEntityReferences
		IEnumerable<IPersistEntity> IContainsEntityReferences.References 
		{
			get 
			{
				if (@RequestingApproval != null)
					yield return @RequestingApproval;
				if (@GivingApproval != null)
					yield return @GivingApproval;
			}
		}
		#endregion

		#region Custom code (will survive code regeneration)
		//## Custom code
		//##
		#endregion
	}
}