Открытые статические члены | Закрытые статические данные

Класс nitro::PluginInterface

Класс для создания плагинов. Подробнее...

#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


Методы

template<class type1 >
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 ) );
                }
        }
        

Граф вызовов:

template<class type1 >
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 ) );
                }
        }
        

Граф вызовов:

template<class type1 >
bool nitro::PluginInterface::InterfaceExported ( nitro::DynamicLibLoader Plugin  )  [static]

Функция проверки экспортируемости интерфейса.

Аргументы:
Plugin - Плагин, экспортирующий интерфейс.
Возвращает:
true если экспортирует.
Исключения:
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 - Проверяемый модуль.
Возвращает:
true если плагин.
Исключения:
nitro::exception Строка с описанием возникшей ошибки.
Автор:
Додонов А.А.
Примеры:
is_plugin.cpp.

См. определение в файле 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 ) );
                }
        }
}

Граф вызовов:

template<class type1 >
void nitro::PluginInterface::ReleaseInterface ( nitro::DynamicLibLoader Plugin,
type1 *  Interface 
) [static]

Функция получения экспортируемого интерфейса.

Аргументы:
Plugin - Плагин, экспортирующий интерфейс.
Interface - Интерфейс.
Возвращает:
Указатель на экспортируемый интерфейс.
Исключения:
nitro::exception Строка с описанием возникшей ошибки.
Автор:
Додонов А.А.
Примеры:
release_interface.cpp.

См. определение в файле 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().


Объявления и описания членов классов находятся в файлах:

Generated by  doxygen 1.6.1