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

namespace Xbim.Ifc4.Interfaces
{
	/// <summary>
    /// Readonly interface for IfcDerivedProfileDef
    /// </summary>
	// ReSharper disable once PartialTypeWithSinglePart
	public partial interface @IIfcDerivedProfileDef : IIfcProfileDef
	{
		IIfcProfileDef @ParentProfile { get;  set; }
		IIfcCartesianTransformationOperator2D @Operator { get;  set; }
		IfcLabel? @Label { get;  set; }
	
	}
}

namespace Xbim.Ifc4.ProfileResource
{
	[ExpressType("IfcDerivedProfileDef", 390)]
	// ReSharper disable once PartialTypeWithSinglePart
	public  partial class @IfcDerivedProfileDef : IfcProfileDef, IInstantiableEntity, IIfcDerivedProfileDef, IContainsEntityReferences, IEquatable<@IfcDerivedProfileDef>
	{
		#region IIfcDerivedProfileDef explicit implementation
		IIfcProfileDef IIfcDerivedProfileDef.ParentProfile { 
 
 
			get { return @ParentProfile; } 
			set { ParentProfile = value as IfcProfileDef;}
		}	
		IIfcCartesianTransformationOperator2D IIfcDerivedProfileDef.Operator { 
 
 
			get { return @Operator; } 
			set { Operator = value as IfcCartesianTransformationOperator2D;}
		}	
		IfcLabel? IIfcDerivedProfileDef.Label { 
 
			get { return @Label; } 
			set { Label = value;}
		}	
		#endregion

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

		#region Explicit attribute fields
		private IfcProfileDef _parentProfile;
		private IfcCartesianTransformationOperator2D _operator;
		private IfcLabel? _label;
		#endregion
	
		#region Explicit attribute properties
		[EntityAttribute(3, EntityAttributeState.Mandatory, EntityAttributeType.Class, EntityAttributeType.None, null, null, 5)]
		public IfcProfileDef @ParentProfile 
		{ 
			get 
			{
				if(_activated) return _parentProfile;
				Activate();
				return _parentProfile;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _parentProfile = v, _parentProfile, value,  "ParentProfile", 3);
			} 
		}	
		[EntityAttribute(4, EntityAttributeState.Mandatory, EntityAttributeType.Class, EntityAttributeType.None, null, null, 6)]
		public virtual IfcCartesianTransformationOperator2D @Operator 
		{ 
			get 
			{
				if(_activated) return _operator;
				Activate();
				return _operator;
			} 
			set
			{
				if (value != null && !(ReferenceEquals(Model, value.Model)))
					throw new XbimException("Cross model entity assignment.");
				SetValue( v =>  _operator = v, _operator, value,  "Operator", 4);
			} 
		}	
		[EntityAttribute(5, EntityAttributeState.Optional, EntityAttributeType.None, EntityAttributeType.None, null, null, 7)]
		public IfcLabel? @Label 
		{ 
			get 
			{
				if(_activated) return _label;
				Activate();
				return _label;
			} 
			set
			{
				SetValue( v =>  _label = v, _label, value,  "Label", 5);
			} 
		}	
		#endregion




		#region IPersist implementation
		public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
		{
			switch (propIndex)
			{
				case 0: 
				case 1: 
					base.Parse(propIndex, value, nestedIndex); 
					return;
				case 2: 
					_parentProfile = (IfcProfileDef)(value.EntityVal);
					return;
				case 3: 
					_operator = (IfcCartesianTransformationOperator2D)(value.EntityVal);
					return;
				case 4: 
					_label = value.StringVal;
					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(@IfcDerivedProfileDef other)
	    {
	        return this == other;
	    }
        #endregion

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

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