// 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 Riskeer.AssemblyTool.Data;
using Riskeer.Common.Data.AssemblyTool;
using Riskeer.Common.Data.AssessmentSection;
using Riskeer.Common.Data.Exceptions;
using Riskeer.Common.Data.FailureMechanism;
using Riskeer.Common.Data.FailurePath;
namespace Riskeer.Integration.Data.StandAlone.AssemblyFactories
{
///
/// Factory for assembling assembly results for a failure mechanism.
///
public static class FailureMechanismAssemblyFactory
{
///
/// Assembles the section based on the input arguments.
///
/// The section result to assemble.
/// The failure mechanism the section result belongs to.
/// The the section belongs to.
/// A .
/// Thrown when any argument is null.
/// Thrown when the section could not be assembled.
public static FailureMechanismSectionAssemblyResult AssembleSection(NonAdoptableWithProfileProbabilityFailureMechanismSectionResult sectionResult,
IHasGeneralInput failureMechanism,
IAssessmentSection assessmentSection)
{
if (sectionResult == null)
{
throw new ArgumentNullException(nameof(sectionResult));
}
if (failureMechanism == null)
{
throw new ArgumentNullException(nameof(failureMechanism));
}
if (assessmentSection == null)
{
throw new ArgumentNullException(nameof(assessmentSection));
}
return FailureMechanismSectionAssemblyResultFactory.AssembleSection(sectionResult, assessmentSection, failureMechanism.GeneralInput.ApplyLengthEffectInSection);
}
///
/// Assembles the failure mechanism based on its input arguments.
///
/// The failure mechanism to assemble.
/// The the
/// belongs to.
/// A representing the assembly result.
/// The type of failure mechanism to assemble.
/// Thrown when any argument is null.
/// Thrown when the failure mechanism cannot be assembled.
public static double AssembleFailureMechanism(TFailureMechanism failureMechanism,
IAssessmentSection assessmentSection)
where TFailureMechanism : IHasGeneralInput, IFailurePath
{
if (failureMechanism == null)
{
throw new ArgumentNullException(nameof(failureMechanism));
}
if (assessmentSection == null)
{
throw new ArgumentNullException(nameof(assessmentSection));
}
return AssemblyToolHelper.AssemblyFailureMechanism(
failureMechanism, sr => AssembleSection(sr, failureMechanism, assessmentSection),
failureMechanism.GeneralInput.N);
}
}
}