Класс для создания плагинов. Подробнее...
#include <utilities/plugin_interface.h>
Открытые статические члены | |
| static bool | IsPlugin (nitro::DynamicLibLoader &Module) |
| template<class type1 > | |
| static bool | InterfaceExported (nitro::DynamicLibLoader &Plugin) |
| template<class type1 > | |
| static type1 * | GetInterface (nitro::DynamicLibLoader &Plugin, const std::string &ObjectName="") |
| template<class type1 > | |
| static type1 * | GetNewInterface (nitro::DynamicLibLoader &Plugin) |
| template<class type1 > | |
| static void | ReleaseInterface (nitro::DynamicLibLoader &Plugin, type1 *Interface) |
Закрытые статические данные | |
| static std::size_t | ObjectInterfaceCounter = 0 |
Класс для создания плагинов.
См. определение в файле plugin_interface.h строка 94
| type1 * nitro::PluginInterface::GetInterface | ( | nitro::DynamicLibLoader & | Plugin, | |
| const std::string & | ObjectName = "" | |||
| ) | [static] |
Функция получения экспортируемого интерфейса.
| Plugin | - Плагин, экспортирующий интерфейс. | |
| ObjectName | - Название объекта. |
| nitro::exception | Строка с описанием возникшей ошибки. |
См. определение в файле plugin_interface.h строка 305
Перекрестные ссылки nitro::exception::code(), nitro::DynamicLibLoader::GetResource(), nitro::DynamicLibLoader::ResourceExists() и nitro::exception::what().
{
try
{
if( Plugin.ResourceExists( "GetInterface" ) == false )
{
throw( nitro::exception( "Loaded module is not a plugin" , 1 ) );
}
void * ( * _GetInterface )( const char * , const char * );
_GetInterface = ( void * ( * )( const char * , const char * ) )Plugin.GetResource( "GetInterface" );
return( ( type1 * )_GetInterface( typeid( type1 ).name() , ObjectName.c_str() ) );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "PluginInterface::GetInterface( nitro::DynamicLibLoader & Plugin , const std::string & ObjectName )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "PluginInterface::GetInterface( nitro::DynamicLibLoader & Plugin , const std::string & ObjectName )::An error occured" ) , 1 ) );
}
}

| type1 * nitro::PluginInterface::GetNewInterface | ( | nitro::DynamicLibLoader & | Plugin | ) | [static] |
Функция получения экспортируемого интерфейса.
| Plugin | - Плагин, экспортирующий интерфейс. |
| nitro::exception | Строка с описанием возникшей ошибки. |
См. определение в файле plugin_interface.h строка 339
Перекрестные ссылки nitro::exception::code(), nitro::DynamicLibLoader::GetResource(), ObjectInterfaceCounter, nitro::DynamicLibLoader::ResourceExists() и nitro::exception::what().
{
try
{
if( Plugin.ResourceExists( "GetInterface" ) == false )
{
throw( nitro::exception( "Loaded module is not a plugin" , 1 ) );
}
void * ( * _GetInterface )( const char * , const char * );
_GetInterface = ( void * ( * )( const char * , const char * ) )Plugin.GetResource( "GetInterface" );
std::size_t CurrentCursor( PluginInterface::ObjectInterfaceCounter++ );
std::string ObjectInterfaceCursor( nitro::Convertes::itoa( CurrentCursor ) );
std::string ObjectName( "" );
ObjectName += "_new_interface[";
ObjectName += ObjectInterfaceCursor;
ObjectName += "]";
return( ( type1 * )_GetInterface( typeid( type1 ).name() , ObjectName.c_str() ) );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "PluginInterface::GetNewInterface( nitro::DynamicLibLoader & Plugin )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "PluginInterface::GetNewInterface( nitro::DynamicLibLoader & Plugin )::An error occured" ) , 1 ) );
}
}

| bool nitro::PluginInterface::InterfaceExported | ( | nitro::DynamicLibLoader & | Plugin | ) | [static] |
Функция проверки экспортируемости интерфейса.
| Plugin | - Плагин, экспортирующий интерфейс. |
| nitro::exception | Строка с описанием возникшей ошибки. |
См. определение в файле plugin_interface.h строка 261
Перекрестные ссылки nitro::exception::code(), nitro::DynamicLibLoader::GetResource(), nitro::DynamicLibLoader::ResourceExists() и nitro::exception::what().
{
void * ( * _GetInterface )( const char * , const char * );
try
{
if( Plugin.ResourceExists( "GetInterface" ) == false )
{
throw( nitro::exception( "Loaded module is not a plugin" , 1 ) );
}
_GetInterface = ( void * ( * )( const char * , const char * ) )Plugin.GetResource( "GetInterface" );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "PluginInterface::InterfaceExported( nitro::DynamicLibLoader & Plugin )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "PluginInterface::InterfaceExported( nitro::DynamicLibLoader & Plugin )::An error occured" ) , 1 ) );
}
try
{
_GetInterface( typeid( type1 ).name() , "" );
return( true );
}
catch( ... )
{
return( false );
}
}

| bool nitro::PluginInterface::IsPlugin | ( | nitro::DynamicLibLoader & | Module | ) | [static] |
Функция проверки экспортируемости интерфейса.
| Module | - Проверяемый модуль. |
| nitro::exception | Строка с описанием возникшей ошибки. |
См. определение в файле plugin_interface.cpp строка 18
Перекрестные ссылки nitro::exception::code() и nitro::exception::what().
{
try
{
if( Plugin.ResourceExists( "GetInterface" ) == false )
{
return( false );
}
return( true );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "PluginInterface::IsPlugin( nitro::DynamicLibLoader & Module )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "PluginInterface::IsPlugin( nitro::DynamicLibLoader & Module )::An error occured" ) , 1 ) );
}
}
}

| void nitro::PluginInterface::ReleaseInterface | ( | nitro::DynamicLibLoader & | Plugin, | |
| type1 * | Interface | |||
| ) | [static] |
Функция получения экспортируемого интерфейса.
| Plugin | - Плагин, экспортирующий интерфейс. | |
| Interface | - Интерфейс. |
| nitro::exception | Строка с описанием возникшей ошибки. |
См. определение в файле plugin_interface.h строка 380
Перекрестные ссылки nitro::exception::code(), nitro::DynamicLibLoader::GetResource(), nitro::DynamicLibLoader::ResourceExists() и nitro::exception::what().
{
try
{
if( Plugin.ResourceExists( "ReleaseInterface" ) == false )
{
throw( nitro::exception( "Loaded module is not a plugin" , 1 ) );
}
void ( * _ReleaseInterface )( void * );
_ReleaseInterface = ( void ( * )( void * ) )Plugin.GetResource( "ReleaseInterface" );
_ReleaseInterface( ( void * ) Interface );
}
catch( nitro::exception e )
{
throw( nitro::exception( std::string( "PluginInterface::ReleaseInterface( nitro::DynamicLibLoader & Plugin , type1 * Interface )::" ) + e.what() , e.code() ) );
}
catch( ... )
{
throw( nitro::exception( std::string( "PluginInterface::ReleaseInterface( nitro::DynamicLibLoader & Plugin , type1 * Interface )::An error occured" ) , 1 ) );
}
}
}

std::size_t nitro::PluginInterface::ObjectInterfaceCounter = 0 [static, private] |
Внутренний счётчик.
См. определение в файле plugin_interface.h строка 246
Используется в GetNewInterface().
1.6.1