#pragma once

#include "../Interfaces/IPluginManager.h"


class k_PluginManager
	: public IPluginManager
{
public:
	k_PluginManager();
	~k_PluginManager();

	// IObject
	void* QueryInterface(const GUID& ar_InterfaceGuid);

	// IService
	virtual void Initialize(IServiceLocator& ar_ServiceLocator);
	virtual void Deinitialize();
	virtual bool get_IsInitialized() const;

	// IPluginManager
	virtual void LoadPlugins();
	virtual void UnloadPlugins();
	
	virtual std::vector<IDirect3D9BasePlugin*> get_Plugins() const;

protected:
	void RegisterPlugin(const std::wstring as_DllFileName);
	void AddPlugin(IDirect3D9BasePlugin* ar_Plugin_, HINSTANCE ah_Library);
	void UnloadPlugin(IDirect3D9BasePlugin* ar_Plugin_);

private:
	bool mb_Initialized;
	IServiceLocator* mr_ServiceLocator_;

	std::vector<IDirect3D9BasePlugin*> mk_Plugins;
	std::vector<HINSTANCE> mk_PluginLibraries;
};