using System;

namespace Volpe.Cafe.Reporting
{
    /// <summary>
    /// Provides support for creating <see cref="IReporter"/> objects.
    /// </summary>
    [Serializable]
    public static class ReporterFactory
    {
        /// <summary>
        /// Returns a default <see cref="IReporter"/> using the specified path for report files, or an
        /// <see cref="EmptyReporter"/> if <paramref name="reportingLevel"/> is <see cref="ReportingLevel.Disabled"/>.
        /// </summary>
        /// <inheritdoc cref="Reporter(ReportingLevel, string)" path="/param"/>
        /// <inheritdoc cref="Reporter(ReportingLevel, string)" path="/remarks"/>
        public static IReporter CreateReporter(ReportingLevel reportingLevel, string reportPath)
        {
            return reportingLevel.IsDisabled()
                ? GetEmptyReporter()
                : GetDefaultReporter(reportingLevel, reportPath);
        }

        /// <summary>
        /// Returns a default <see cref="IReporter"/> using the specified path for report files.
        /// </summary>
        /// <inheritdoc cref="Reporter(ReportingLevel, string)" path="/param"/>
        /// <inheritdoc cref="Reporter(ReportingLevel, string)" path="/remarks"/>
        public static IReporter GetDefaultReporter(ReportingLevel reportingLevel, string reportPath)
        {
            return new Reporter(reportingLevel, reportPath);
        }

        /// <summary>
        /// Returns an <see cref="EmptyReporter"/> that suppresses all reporting capability.
        /// </summary>
        public static IReporter GetEmptyReporter()
        {
            return new EmptyReporter();
        }

    }
}
