Класс для загрузки динамических библиотек. Подробнее...
#include <loaders/dynamic_lib_loader.h>
Открытые члены | |
| DynamicLibLoader (void) | |
| DynamicLibLoader (const char *LibraryPath) | |
| DynamicLibLoader (const std::string &LibraryPath) | |
| void | LoadLibrary (const char *LibraryPath) |
| void | LoadLibrary (const std::string &LibraryPath) |
| void * | GetResource (const char *ResourceName) |
| void * | GetResource (const std::string &ResourceName) |
| bool | ResourceExists (const char *ResourceName) |
| bool | ResourceExists (const std::string &ResourceName) |
| void | Release (void) |
| virtual | ~DynamicLibLoader () |
Закрытые члены | |
| DynamicLibLoader (const DynamicLibLoader &) | |
| DynamicLibLoader | operator= (const DynamicLibLoader &) |
Закрытые данные | |
| void * | Handle |
Класс для загрузки динамических библиотек.
~english Class for loading dynamic libraries.
get_interface.cpp, get_new_interface.cpp, interface_exported.cpp, is_plugin.cpp и release_interface.cpp.
См. определение в файле dynamic_lib_loader.h строка 48
| nitro::DynamicLibLoader::DynamicLibLoader | ( | void | ) |
Конструктор.
См. определение в файле dynamic_lib_loader.cpp строка 17
Перекрестные ссылки nitro::exception::code(), Handle и nitro::exception::what().
{
try
{
Handle = NULL;
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "DynamicLibLoader::DynamicLibLoader( void )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "DynamicLibLoader::DynamicLibLoader( void )::An error occured" ) , 1 ) );
}
}

| nitro::DynamicLibLoader::DynamicLibLoader | ( | const char * | LibraryPath | ) |
Конструктор.
| LibraryPath | - Путь к загружаемой библиотеке. |
| std::string | Строка с описанием возникшей ошибки. |
См. определение в файле dynamic_lib_loader.cpp строка 33
Перекрестные ссылки nitro::exception::code(), Handle, LoadLibrary() и nitro::exception::what().
{
try
{
Handle = NULL;
LoadLibrary( LibraryPath );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "DynamicLibLoader::DynamicLibLoader( const char * LibraryPath )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "DynamicLibLoader::DynamicLibLoader( const char * LibraryPath )::An error occured" ) , 0) );
}
}

| nitro::DynamicLibLoader::DynamicLibLoader | ( | const std::string & | LibraryPath | ) |
Конструктор.
| LibraryPath | - Путь к загружаемой библиотеке. |
| std::string | Строка с описанием возникшей ошибки. |
См. определение в файле dynamic_lib_loader.cpp строка 51
Перекрестные ссылки nitro::exception::code(), Handle, LoadLibrary() и nitro::exception::what().
{
try
{
Handle = NULL;
LoadLibrary( LibraryPath );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "DynamicLibLoader::DynamicLibLoader( const std::string & LibraryPath )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "DynamicLibLoader::DynamicLibLoader( const std::string & LibraryPath )::An error occured" ) , 0) );
}
}

| nitro::DynamicLibLoader::~DynamicLibLoader | ( | ) | [virtual] |
Виртуальный деструктор.
См. определение в файле dynamic_lib_loader.cpp строка 262
Перекрестные ссылки Release().
{
try
{
Release();
}
catch( nitro::exception e )
{
}
catch( ... )
{
}
}

| nitro::DynamicLibLoader::DynamicLibLoader | ( | const DynamicLibLoader & | ) | [inline, private] |
| void * nitro::DynamicLibLoader::GetResource | ( | const char * | ResourceName | ) |
Функция получения ресурса из библиотеки (под ресурсом понимается либо объект либо функция).
| ResourceName | - Имя загружаемого ресурса. |
| std::string | Строка с описанием возникшей ошибки. |
См. определение в файле dynamic_lib_loader.cpp строка 121
Перекрестные ссылки nitro::exception::code(), Handle и nitro::exception::what().
Используется в nitro::PluginInterface::GetInterface(), nitro::PluginInterface::GetNewInterface(), GetResource(), nitro::PluginInterface::InterfaceExported() и nitro::PluginInterface::ReleaseInterface().
{
try
{
if( Handle )
{
#if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
FARPROC Address( NULL );
Address = GetProcAddress( *( ( HMODULE * )Handle ) , ResourceName );
#endif
#if defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
void * Address( NULL );
Address = dlsym( Handle , ResourceName );
#endif
if( Address == NULL )
{
throw( nitro::exception( std::string( "An error occured while getting library resource " ) + ResourceName , 1 ) );
}
return( ( void * )Address );
}
else
{
throw( nitro::exception( std::string( "Library was not loaded" ) , 1 ) );
}
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "DynamicLibLoader::GetResource( const char * ResourceName )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "DynamicLibLoader::GetResource( const char * ResourceName )::An error occured" ) , 1 ) );
}
}

| void * nitro::DynamicLibLoader::GetResource | ( | const std::string & | ResourceName | ) |
Функция получения ресурса из библиотеки (под ресурсом понимается либо объект либо функция).
| ResourceName | - Имя загружаемого ресурса. |
| std::string | Строка с описанием возникшей ошибки. |
См. определение в файле dynamic_lib_loader.cpp строка 161
Перекрестные ссылки nitro::exception::code(), GetResource() и nitro::exception::what().
{
try
{
return( GetResource( ResourceName.c_str() ) );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "DynamicLibLoader::GetResource( const std::string & ResourceName )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "DynamicLibLoader::GetResource( const std::string & ResourceName )::An error occured" ) , 1 ) );
}
}

| void nitro::DynamicLibLoader::LoadLibrary | ( | const std::string & | LibraryPath | ) |
Функция загрузки библиотеки.
| LibraryPath | - Путь к загружаемой библиотеке. |
| std::string | Строка с описанием возникшей ошибки. |
См. определение в файле dynamic_lib_loader.cpp строка 105
Перекрестные ссылки nitro::exception::code(), LoadLibrary() и nitro::exception::what().
{
try
{
LoadLibrary( LibraryPath.c_str() );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "DynamicLibLoader::LoadLibrary( const std::string & LibraryPath )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "DynamicLibLoader::LoadLibrary( const std::string & LibraryPath )::An error occured" ) , 1 ) );
}
}

| void nitro::DynamicLibLoader::LoadLibrary | ( | const char * | LibraryPath | ) |
Функция загрузки библиотеки.
| LibraryPath | - Путь к загружаемой библиотеке. |
| std::string | Строка с описанием возникшей ошибки. |
См. определение в файле dynamic_lib_loader.cpp строка 69
Перекрестные ссылки nitro::exception::code(), Handle, Release() и nitro::exception::what().
Используется в DynamicLibLoader() и LoadLibrary().
{
try
{
Release();
#if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
Handle = ( void * ) new HMODULE;
*( ( HMODULE * )Handle ) = LoadLibraryA( LibraryPath );
if( *( ( HMODULE * )Handle ) == NULL )
{
throw( nitro::exception( std::string( "An error occured while loading library " ) + LibraryPath , 0 ) );
}
#endif
#if defined( NIX_PLARFORM ) || defined( CYGWIN_PLATFORM )
Handle = dlopen( LibraryPath , RTLD_NOW | RTLD_GLOBAL );
if( Handle == NULL )
{
throw( nitro::exception( std::string( "An error occured while loading library " ) + LibraryPath , 0 ) );
}
#endif
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "DynamicLibLoader::LoadLibrary( const char * LibraryPath )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "DynamicLibLoader::LoadLibrary( const char * LibraryPath )::An error occured" ) , 1 ) );
}
}

| DynamicLibLoader nitro::DynamicLibLoader::operator= | ( | const DynamicLibLoader & | ) | [inline, private] |
Закрытый оператор присваивания.
См. определение в файле dynamic_lib_loader.h строка 309
{return( *this );}
| void nitro::DynamicLibLoader::Release | ( | void | ) |
Функция освобождения ресурсов.
| std::string | Строка с описанием возникшей ошибки. |
См. определение в файле dynamic_lib_loader.cpp строка 233
Перекрестные ссылки nitro::exception::code(), Handle и nitro::exception::what().
Используется в LoadLibrary() и ~DynamicLibLoader().
{
try
{
if( Handle )
{
#if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
FreeLibrary( * ( ( HMODULE * )Handle ) );
delete ( HMODULE * )Handle;
#endif
#if defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
dlclose( Handle );
#endif
Handle = NULL;
}
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "DynamicLibLoader::Release( void )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "DynamicLibLoader::Release( void )::An error occured" ) , 1 ) );
}
}

| bool nitro::DynamicLibLoader::ResourceExists | ( | const std::string & | ResourceName | ) |
Проверка ресурса на существование.
| ResourceName | - Имя загружаемого ресурса. |
| std::string | Строка с описанием возникшей ошибки. |
См. определение в файле dynamic_lib_loader.cpp строка 217
Перекрестные ссылки nitro::exception::code(), ResourceExists() и nitro::exception::what().
{
try
{
return( ResourceExists( ResourceName.c_str() ) );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "DynamicLibLoader::ResourceExists( const std::string & ResourceName )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "DynamicLibLoader::ResourceExists( const std::string & ResourceName )::An error occured" ) , 1 ) );
}
}

| bool nitro::DynamicLibLoader::ResourceExists | ( | const char * | ResourceName | ) |
Проверка ресурса на существование.
| ResourceName | - Имя загружаемого ресурса. |
| std::string | Строка с описанием возникшей ошибки. |
См. определение в файле dynamic_lib_loader.cpp строка 177
Перекрестные ссылки nitro::exception::code(), Handle и nitro::exception::what().
Используется в nitro::PluginInterface::GetInterface(), nitro::PluginInterface::GetNewInterface(), nitro::PluginInterface::InterfaceExported(), nitro::PluginInterface::ReleaseInterface() и ResourceExists().
{
try
{
if( Handle )
{
#if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
FARPROC Address( NULL );
Address = GetProcAddress( *( ( HMODULE * )Handle ) , ResourceName );
#endif
#if defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
void * Address( NULL );
Address = dlsym( Handle , ResourceName );
#endif
if( Address == NULL )
{
return( false );
}
return( true );
}
else
{
throw( nitro::exception( std::string( "Library was not loaded" ) , 1 ) );
}
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "DynamicLibLoader::ResourceExists( const char * ResourceName )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "DynamicLibLoader::ResourceExists( const char * ResourceName )::An error occured" ) , 1 ) );
}
}

void* nitro::DynamicLibLoader::Handle [private] |
Хэндл загруженной библиотеки.
См. определение в файле dynamic_lib_loader.h строка 285
Используется в DynamicLibLoader(), GetResource(), LoadLibrary(), Release() и ResourceExists().
1.6.1