*
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#include "Plugin.h"
|
||||
#include <stdexcept>
|
||||
|
||||
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<fn_getPluginVersion>(::GetProcAddress(g_hDLL, "getPluginVersion"));
|
||||
g_pfnGetEngineVersion = reinterpret_cast<fn_getEngineVersion>(::GetProcAddress(g_hDLL, "getEngineVersion"));
|
||||
g_pfnRegisterPlugin = reinterpret_cast<fn_registerPlugin>(::GetProcAddress(g_hDLL, "registerPlugin"));
|
||||
//g_pfnGetPluginName = reinterpret_cast<fn_getPluginName>(::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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user