using System;
using System.IO;
using Volpe.Cafe.ModelSettings;

namespace Volpe.Cafe.Reporting
{
    /// <summary>
    /// Defines a reporter object used for generating modeling reports for the compliance model.
    /// </summary>
    public interface IReporter : IDisposable
    {
        /// <summary>
        /// Occurs when the <see cref="IsRunning"/> property value changes.
        /// </summary>
        event EventHandler RunningChanged;

        /// <summary>
        /// Occurs when the <see cref="Status"/> property value changes.
        /// </summary>
        event EventHandler StatusChanged;

        /// <summary>
        /// Gets an object that can be used to synchronize access to the <see cref="IReporter"/>.
        /// </summary>
        object SyncRoot { get; }

        /// <summary>
        /// Gets whether the <see cref="IReporter"/> is disposed.
        /// </summary>
        bool IsDisposed { get; }

        /// <summary>
        /// Gets the level of reporting associated with this <see cref="IReporter"/>.
        /// </summary>
        ReportingLevel ReportingLevel { get; }

        /// <summary>
        /// Gets the root path where all report files are located.
        /// </summary>
        string ReportPath { get; }

        /// <summary>
        /// Gets whether modeling reports are currently being generated.
        /// </summary>
        bool IsRunning { get; }

        /// <summary>
        /// Gets the status string representing the last action of the <see cref="IReporter"/>.
        /// </summary>
        string Status { get; }

        /// <inheritdoc cref="Dispose()"/>
        void Close();

        /// <summary>
        /// Closes all open report files and disposes of this <see cref="IReporter"/> object.
        /// </summary>
        /// <exception cref="IOException">An I/O error has occurred.</exception>
        /// <inheritdoc cref="StreamWriter.Close()" path="/exception"/>
        new void Dispose();

        /// <summary>
        /// Generates modeling reports for the specified scenario, using the specified reporting data.
        /// </summary>
        /// <param name="scen">The compliance scenario being analyzed.</param>
        /// <param name="data">The modeling and effects data to report on.</param>
        /// <param name="settings">The modeling settings used for analysis.</param>
        void GenerateReports(Scenario scen, ReportingData data, ModelingSettings settings);

        /// <summary>
        /// Generates modeling reports for the specified scenario, using the specified reporting data, in a thread-safe
        /// context.
        /// </summary>
        /// <inheritdoc cref="GenerateReports(Scenario, ReportingData, ModelingSettings)" path="/param"/>
        void SafeGenerateReports(Scenario scen, ReportingData data, ModelingSettings settings);

        /// <summary>
        /// Requests to cancel the current report generating operation.
        /// </summary>
        void CancelReporting();

    }
}
