using System;
using System.Collections.Generic;

namespace _09_PredictiveDialer
{
    class ConfigStore
    {
        static ConfigStore _instance = new ConfigStore();

        object _sync;
        List<String> _agentList;
        List<CallInfo> _callList;
        List<String> _freeAgents;

        ConfigStore()
        {
            _sync = new object();
            _callList = new List<CallInfo>();
            _freeAgents = new List<string>();
            _agentList = new List<string>();
        }

        public static ConfigStore Instance
        {
            get { return _instance; }
        }

        public void AddToCallList(CallInfo callInfo)
        {
            lock (_sync)
                _callList.Add(callInfo);
        }

        public List<CallInfo> GetCallList()
        {
            lock (_sync)
                return new List<CallInfo>(_callList);
        }

        public void AddAgent(string agent)
        {
            lock (_sync)
                _agentList.Add(agent);
        }

        public void RemoveFreeAgent(string agent)
        {
            lock (_sync)
                _freeAgents.Remove(agent);
        }

        public void AddFreeAgent(string agent)
        {
            lock (_sync)
                _freeAgents.Add(agent);
        }

        public List<string> GetFreeAgents()
        {
            lock (_sync)
                return new List<string>(_freeAgents);
        }
    }
}
