using System;
using System.Collections.Generic;

namespace ZocMonLib
{
    public class RecorderEventTriggerProvider : IRecorderEventTriggerProvider
    {
        private readonly ISystemLogger _logger;
        protected readonly IList<ITriggerListener> _clients;

        public RecorderEventTriggerProvider(ISettings settings)
        {
            _logger = settings.LoggerProvider.CreateLogger(typeof(RecorderEventTriggerProvider));
            _clients = new List<ITriggerListener>();
        }

        public void Register(ITriggerListener listener)
        {
            _logger.Info(() => String.Format("Reduce Event Trigger - Registering '{0}'", listener.GetTypeIfNotNull()));

            _clients.Add(listener);
        }

        public void Execute()
        {
            foreach (var trigger in _clients)
                trigger.Execute();
        }
    }
}