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


namespace Xbim.Ifc2x3.SharedBldgServiceElements
{
	[ExpressType("IfcSoundProperties", 474)]
	// ReSharper disable once PartialTypeWithSinglePart
	public  partial class @IfcSoundProperties : IfcPropertySetDefinition, IInstantiableEntity, IContainsEntityReferences, IEquatable<@IfcSoundProperties>
	{

		//internal constructor makes sure that objects are not created outside of the model/ assembly controlled area
		internal IfcSoundProperties(IModel model, int label, bool activated) : base(model, label, activated)  
		{
			_soundValues = new ItemSet<IfcSoundValue>( this, 8,  7);
		}

		#region Explicit attribute fields
		private IfcBoolean _isAttenuating;
		private IfcSoundScaleEnum? _soundScale;
		private readonly ItemSet<IfcSoundValue> _soundValues;
		#endregion
	
		#region Explicit attribute properties
		[EntityAttribute(5, EntityAttributeState.Mandatory, EntityAttributeType.None, EntityAttributeType.None, null, null, 8)]
		public IfcBoolean @IsAttenuating 
		{ 
			get 
			{
				if(_activated) return _isAttenuating;
				Activate();
				return _isAttenuating;
			} 
			set
			{
				SetValue( v =>  _isAttenuating = v, _isAttenuating, value,  "IsAttenuating", 5);
			} 
		}	
		[EntityAttribute(6, EntityAttributeState.Optional, EntityAttributeType.Enum, EntityAttributeType.None, null, null, 9)]
		public IfcSoundScaleEnum? @SoundScale 
		{ 
			get 
			{
				if(_activated) return _soundScale;
				Activate();
				return _soundScale;
			} 
			set
			{
				SetValue( v =>  _soundScale = v, _soundScale, value,  "SoundScale", 6);
			} 
		}	
		[EntityAttribute(7, EntityAttributeState.Mandatory, EntityAttributeType.List, EntityAttributeType.Class, new int [] { 1 }, new int [] { 8 }, 10)]
		public IItemSet<IfcSoundValue> @SoundValues 
		{ 
			get 
			{
				if(_activated) return _soundValues;
				Activate();
				return _soundValues;
			} 
		}	
		#endregion




		#region IPersist implementation
		public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex)
		{
			switch (propIndex)
			{
				case 0: 
				case 1: 
				case 2: 
				case 3: 
					base.Parse(propIndex, value, nestedIndex); 
					return;
				case 4: 
					_isAttenuating = value.BooleanVal;
					return;
				case 5: 
                    _soundScale = (IfcSoundScaleEnum) System.Enum.Parse(typeof (IfcSoundScaleEnum), value.EnumVal, true);
					return;
				case 6: 
					_soundValues.InternalAdd((IfcSoundValue)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(@IfcSoundProperties other)
	    {
	        return this == other;
	    }
        #endregion

		#region IContainsEntityReferences
		IEnumerable<IPersistEntity> IContainsEntityReferences.References 
		{
			get 
			{
				if (@OwnerHistory != null)
					yield return @OwnerHistory;
				foreach(var entity in @SoundValues)
					yield return entity;
			}
		}
		#endregion

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