/// class PD.Plugins.PluginManager

PD.Plugins.PluginManager =
Class.extend({
    
});

//===================================
// FIELDS
//===================================

PD.Plugins.PluginManager._plugins = {};

//===================================
// PROPERTIES
//===================================

PD.Plugins.PluginManager.get_plugins = function () {
    return _.clone(PD.Plugins.PluginManager._plugins);
};

//===================================
// PUBLIC METHODS
//===================================

PD.Plugins.PluginManager.addPlugin = function (plugin) {

    var plugins = PD.Plugins.PluginManager._plugins;

    if (!(plugin.id in plugins)) {
        plugins[plugin.get_id()] = plugin;
    }

};
    
PD.Plugins.PluginManager.removePlugin = function (id) {

    var plugins = PD.Plugins.PluginManager._plugins;

    if (id in plugins) {
        delete plugins[id];
    }

};

PD.Plugins.PluginManager.getPlugin = function (id) {

    var plugins = PD.Plugins.PluginManager._plugins;
    var result = null;

    if (id != null && id in plugins) {
        result = plugins[id];
    }

    return result;

};

PD.Plugins.PluginManager.getPlugins = function () {

    var plugins = PD.Plugins.PluginManager._plugins;
    var result = [];

    for (key in plugins) {
        result[result.length] = this._plugins[key];
    }

    return result;

};