#include "Plugin.h" #include namespace LifeGraphics { Plugin::Plugin(const std::string& fileName) { g_hDLL = ::LoadLibraryA(fileName.c_str()); if(!g_hDLL) throw std::runtime_error("Could not load library"); try { g_pfnGetPluginVersion = reinterpret_cast(::GetProcAddress(g_hDLL, "getPluginVersion")); g_pfnGetEngineVersion = reinterpret_cast(::GetProcAddress(g_hDLL, "getEngineVersion")); g_pfnRegisterPlugin = reinterpret_cast(::GetProcAddress(g_hDLL, "registerPlugin")); //g_pfnGetPluginName = reinterpret_cast(::GetProcAddress(g_hDLL, "getPluginName")); if(!g_pfnGetPluginVersion || !g_pfnGetEngineVersion || !g_pfnRegisterPlugin) throw std::runtime_error("Plugin is not valid"); } catch(...) { ::FreeModule(g_hDLL); throw std::runtime_error("Plugin is not valid"); } } Plugin::~Plugin() { if(g_referenceCount<=0 && g_hDLL != NULL) ::FreeModule(g_hDLL); } }