// Copyright (C) Stichting Deltares 2021. All rights reserved.
//
// This file is part of Riskeer.
//
// Riskeer is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System;
using System.Collections.Generic;
using Core.Common.Base;
using Riskeer.Common.Data.Calculation;
using Riskeer.Common.Data.FailureMechanism;
using Riskeer.DuneErosion.Data.Properties;
namespace Riskeer.DuneErosion.Data
{
///
/// Model containing input and output needed to perform different levels of the
/// Dune Erosion failure mechanism.
///
public class DuneErosionFailureMechanism : FailureMechanismBase
{
private readonly ObservableList sectionResults;
private readonly ObservableList calculationsForMechanismSpecificFactorizedSignalingNorm = new ObservableList();
private readonly ObservableList calculationsForMechanismSpecificSignalingNorm = new ObservableList();
private readonly ObservableList calculationsForMechanismSpecificLowerLimitNorm = new ObservableList();
private readonly ObservableList calculationsForLowerLimitNorm = new ObservableList();
private readonly ObservableList calculationsForFactorizedLowerLimitNorm = new ObservableList();
private readonly ObservableList duneLocationCollection = new ObservableList();
///
/// Initializes a new instance of the class.
///
public DuneErosionFailureMechanism()
: base(Resources.DuneErosionFailureMechanism_DisplayName, Resources.DuneErosionFailureMechanism_Code, 3)
{
sectionResults = new ObservableList();
GeneralInput = new GeneralDuneErosionInput();
}
///
/// Gets the general dune erosion calculation input parameters that apply to each calculation.
///
public GeneralDuneErosionInput GeneralInput { get; }
///
/// Gets the dune locations.
///
public IObservableEnumerable DuneLocations
{
get
{
return duneLocationCollection;
}
}
///
/// Gets the calculations corresponding to the mechanism specific factorized signaling norm.
///
public IObservableEnumerable CalculationsForMechanismSpecificFactorizedSignalingNorm
{
get
{
return calculationsForMechanismSpecificFactorizedSignalingNorm;
}
}
///
/// Gets the calculations corresponding to the mechanism specific signaling norm.
///
public IObservableEnumerable CalculationsForMechanismSpecificSignalingNorm
{
get
{
return calculationsForMechanismSpecificSignalingNorm;
}
}
///
/// Gets the calculations corresponding to the mechanism specific lower limit norm.
///
public IObservableEnumerable CalculationsForMechanismSpecificLowerLimitNorm
{
get
{
return calculationsForMechanismSpecificLowerLimitNorm;
}
}
///
/// Gets the calculations corresponding to the lower limit norm.
///
public IObservableEnumerable CalculationsForLowerLimitNorm
{
get
{
return calculationsForLowerLimitNorm;
}
}
///
/// Gets the calculations corresponding to the factorized lower limit norm.
///
public IObservableEnumerable CalculationsForFactorizedLowerLimitNorm
{
get
{
return calculationsForFactorizedLowerLimitNorm;
}
}
public override IEnumerable Calculations
{
get
{
yield break;
}
}
///
/// Sets dune locations and calculations for the failure mechanism.
///
/// The dune locations to add to the failure mechanism.
/// Thrown when is null.
public void SetDuneLocations(IEnumerable duneLocations)
{
if (duneLocations == null)
{
throw new ArgumentNullException(nameof(duneLocations));
}
ClearDuneLocationData();
duneLocationCollection.AddRange(duneLocations);
foreach (DuneLocation duneLocation in duneLocationCollection)
{
AddCalculationsForDuneLocation(duneLocation);
}
}
protected override void AddSectionResult(FailureMechanismSection section)
{
base.AddSectionResult(section);
sectionResults.Add(new DuneErosionFailureMechanismSectionResult(section));
}
private void ClearDuneLocationData()
{
duneLocationCollection.Clear();
calculationsForMechanismSpecificFactorizedSignalingNorm.Clear();
calculationsForMechanismSpecificSignalingNorm.Clear();
calculationsForMechanismSpecificLowerLimitNorm.Clear();
calculationsForLowerLimitNorm.Clear();
calculationsForFactorizedLowerLimitNorm.Clear();
}
private void AddCalculationsForDuneLocation(DuneLocation duneLocation)
{
calculationsForMechanismSpecificFactorizedSignalingNorm.Add(new DuneLocationCalculation(duneLocation));
calculationsForMechanismSpecificSignalingNorm.Add(new DuneLocationCalculation(duneLocation));
calculationsForMechanismSpecificLowerLimitNorm.Add(new DuneLocationCalculation(duneLocation));
calculationsForLowerLimitNorm.Add(new DuneLocationCalculation(duneLocation));
calculationsForFactorizedLowerLimitNorm.Add(new DuneLocationCalculation(duneLocation));
}
}
}