// ------------------------------------------------------------------------------
// <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.Ifc4x3.MeasureResource;
using System;
using System.Collections.Generic;
using System.Linq;
using Xbim.Common;
using Xbim.Common.Exceptions;
using Xbim.Ifc4x3.GeometryResource;
//## Custom using statements
//##


namespace Xbim.Ifc4x3.GeometryResource
{
	[ExpressType("IfcPolynomialCurve", 1470)]
	// ReSharper disable once PartialTypeWithSinglePart
	public  partial class @IfcPolynomialCurve : IfcCurve, IInstantiableEntity, IContainsEntityReferences, IEquatable<@IfcPolynomialCurve>
	{

		//internal constructor makes sure that objects are not created outside of the model/ assembly controlled area
		internal IfcPolynomialCurve(IModel model, int label, bool activated) : base(model, label, activated)  
		{
			_coefficientsX = new OptionalItemSet<IfcReal>( this, 0,  2);
			_coefficientsY = new OptionalItemSet<IfcReal>( this, 0,  3);
			_coefficientsZ = new OptionalItemSet<IfcReal>( this, 0,  4);
		}

		#region Explicit attribute fields
		private IfcPlacement _position;
		private readonly OptionalItemSet<IfcReal> _coefficientsX;
		private readonly OptionalItemSet<IfcReal> _coefficientsY;
		private readonly OptionalItemSet<IfcReal> _coefficientsZ;
		#endregion
	
		#region Explicit attribute properties
		[EntityAttribute(1, EntityAttributeState.Mandatory, EntityAttributeType.Class, EntityAttributeType.None, null, null, 3)]
		public IfcPlacement @Position 
		{ 
			get 
			{
				if(_activated) return _position;
				Activate();
				return _position;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _position = v, _position, value,  "Position", 1);
			} 
		}	
		[EntityAttribute(2, EntityAttributeState.Optional, EntityAttributeType.List, EntityAttributeType.None, new int [] { 2 }, new int [] { -1 }, 4)]
		public IOptionalItemSet<IfcReal> @CoefficientsX 
		{ 
			get 
			{
				if(_activated) return _coefficientsX;
				Activate();
				return _coefficientsX;
			} 
		}	
		[EntityAttribute(3, EntityAttributeState.Optional, EntityAttributeType.List, EntityAttributeType.None, new int [] { 2 }, new int [] { -1 }, 5)]
		public IOptionalItemSet<IfcReal> @CoefficientsY 
		{ 
			get 
			{
				if(_activated) return _coefficientsY;
				Activate();
				return _coefficientsY;
			} 
		}	
		[EntityAttribute(4, EntityAttributeState.Optional, EntityAttributeType.List, EntityAttributeType.None, new int [] { 2 }, new int [] { -1 }, 6)]
		public IOptionalItemSet<IfcReal> @CoefficientsZ 
		{ 
			get 
			{
				if(_activated) return _coefficientsZ;
				Activate();
				return _coefficientsZ;
			} 
		}	
		#endregion




		#region IPersist implementation
		public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
		{
			switch (propIndex)
			{
				case 0: 
					_position = (IfcPlacement)(value.EntityVal);
					return;
				case 1: 
					_coefficientsX.InternalAdd(value.RealVal);
					return;
				case 2: 
					_coefficientsY.InternalAdd(value.RealVal);
					return;
				case 3: 
					_coefficientsZ.InternalAdd(value.RealVal);
					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(@IfcPolynomialCurve other)
	    {
	        return this == other;
	    }
        #endregion

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

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