using System;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.Xna.Framework.Content;

namespace ECOT.Engine
{
    /// <summary>
    /// 
    /// </summary>
    public class MediaManager
    {
        #region Initialization

        public MediaManager(ContentManager contentManager)
        {
           // Debug.Assert(contentManager != null);
            this.contentManager = contentManager;
        }

        #endregion

        #region Methods

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="filename"></param>
        /// <returns></returns>
        public T Get<T>(string filename)
        {
            if (!m_MediaMap.ContainsKey(filename))
                m_MediaMap.Add(filename, this.contentManager.Load<T>(filename));

            return ((T)m_MediaMap[filename]);
        }

        #endregion

        #region Properties

        public ContentManager ContentManager
        {
            get { return this.contentManager; }
        }

        public string RootDirectory
        {
            get { return this.contentManager.RootDirectory; }
        }

        #endregion

        #region Fields

        /// <summary>
        /// 
        /// </summary>
        private Dictionary<string, object> m_MediaMap = new Dictionary<string, object>();

        /// <summary>
        /// 
        /// </summary>
        private ContentManager contentManager;

        #endregion
    }
}
