using System.Collections.Generic;
using Inspectron.Camera.Image;

namespace Inspectron.Camera
{
    public interface ICamera
    {
        /// <summary>
        /// Returns the name of the camera
        /// </summary>
        string Name { get; }

        /// <summary>
        /// Opens the camera
        /// </summary>
        void Open();

        /// <summary>
        ///  Returns true if the camera is opened
        /// </summary>
        bool IsOpen { get; }

        /// <summary>
        /// Closes the camera
        /// </summary>
        void Close();

        /// <summary>
        /// Returns true if the camera is live 
        /// </summary>
        bool IsGrabbingContinuous { get; }

        /// <summary>
        /// Stats live asynchronous acquisition. Images are transmitted the ImageGrabbed Event
        /// </summary>
        void StartGrabContinuous();

        /// <summary>
        /// Stops the asynchronous acquisition.
        /// </summary>
        void StopGrabContinuous();

        /// <summary>
        /// Loads the parameters from a filename
        /// </summary>
        /// <param name="parameters_file"></param>
        void LoadParameters(string parametersFile);

        /// <summary>
        /// Saves the camera parameters to the given filename
        /// </summary>
        /// <param name="parameters_file"></param>
        void SaveParameters(string parametersFile);

        /// <summary>
        /// Saves the parameters to the camera memory
        /// </summary>
        void SaveParametersToDevice();

        /// <summary>
        /// Synchronously grab an image
        /// </summary>
        /// <returns></returns>
        IImage GrabSingle();

        /// <summary>
        /// Event occuring when a new frame is acquired
        /// </summary>
        event ImageGrabbedHandler ImageGrabbed;

        /// <summary>
        /// Returns the capabilities of the camera
        /// </summary>
        ICameraCapabilities Capabilities { get; }

        /// <summary>
        /// Returns a Ienumerable containing all  of the camera
        /// </summary>
        IEnumerable<ICameraParameter> Parameters { get; }

        /// <summary>
        /// Reference to Parent Camera Provider
        /// </summary>
        ICameraProvider Provider { get; }
    }
    /// <summary>
    /// Handler called when an image has been grabbed
    /// </summary>
    /// <param name="image">the grabbed image</param>
    public delegate void ImageGrabbedHandler(ICamera sender, IImage image);
}