import QuestionInfoModel from '../model/QuestionInfoModel';
import PlayerInfoModel  from '../model/PlayerInfoModel';
import BootOptionData   from '../model/BootOptionData';
import ConfigData       from '../model/ConfigData';
import WeekRank         from '../model/WeekRank';
import WeekQuery        from '../model/WeekQuery';

let DataModelManager = (
    function()
    {
        var _modelMap = {};
        var _modelConsturctFun = {};

        var registerModelContruct = function(modelName,constructFun)
        {
            _modelConsturctFun[modelName] = constructFun;
        };

       registerModelContruct('ConfigData',ConfigData);
       registerModelContruct('BootOptionData',BootOptionData);
       registerModelContruct('PlayerInfoModel',PlayerInfoModel);
       registerModelContruct('QuestionInfoModel', QuestionInfoModel);
       registerModelContruct('WeekRank', WeekRank);
       registerModelContruct('WeekQuery', WeekQuery);

        return {
           getModel(modelName)
           { 
               if(_modelMap[modelName])
               {
                   return _modelMap[modelName];
               }
               else
               {
                   if(_modelConsturctFun[modelName])
                   {
                       _modelMap[modelName] =  new _modelConsturctFun[modelName];
                       return  _modelMap[modelName];
                   }
                   else
                   {
                      
                   }
               }
           },
       
           destroyModel(modelName)
           {
             if(_modelMap[modelName])
             {
                _modelMap[modelName].destroy();
                delete _modelMap[modelName];
             }
           }

        };
    }
)();

export default DataModelManager;

