Go to the documentation of this file.00001 #ifndef         __DYNAMIC_LIB_MANAGER_CPP__
00002 #define         __DYNAMIC_LIB_MANAGER_CPP__
00003 
00004 #include        <managers/dynamic_lib_manager.h>
00005 
00006 namespace nitro
00007 {
00008         DEFINE_RELEASE_FUNCTION( DynamicLibManager , Release , Manager );
00009         
00010         DEFINE_RELEASING_DESTRUCTOR( DynamicLibManager , Release );
00011         
00012         DEFINE_SQUARE_BRACE_OPERATOR_REF_LOCATOR( nitro::DynamicLibLoader , DynamicLibManager , Manager );
00013 
00014         void                                            DynamicLibManager::LoadLibrary( const char * LibraryPath )
00015         {
00016                 try
00017                 {
00018                         Manager.AddObject( LibraryPath , new nitro::DynamicLibLoader( LibraryPath ) );
00019                 }
00020                 catch( nitro::exception e )
00021                 {
00022                         throw( nitro::exception( std::string( "DynamicLibManager::LoadLibrary( const str_type & LibraryPath )::" ) + e.what() , e.code() ) );
00023                 }
00024                 catch( ... )
00025                 {
00026                         throw( nitro::exception( std::string( "DynamicLibManager::LoadLibrary( const str_type & LibraryPath )::An error occured" ) , 0 ) );
00027                 }
00028         }
00029         
00030         void                                            DynamicLibManager::LoadLibrary( const std::string & LibraryPath )
00031         {
00032                 try
00033                 {
00034                         LoadLibrary( LibraryPath.c_str() );
00035                 }
00036                 catch( nitro::exception e )
00037                 {
00038                         throw( nitro::exception( std::string( " DynamicLibManager::LoadLibrary( const std::string & LibraryPath )::" ) + e.what() , e.code() ) );
00039                 }
00040                 catch( ... )
00041                 {
00042                         throw( nitro::exception( std::string( " DynamicLibManager::LoadLibrary( const std::string & LibraryPath )::An error occured" ) , 0 ) );
00043                 }
00044         }
00045 
00046         BEGIN_TESTING_SECTION()
00047         
00048                 ENABLE_CLASS_TESTING( DynamicLibManager )
00049                 
00050                 CLASS_MEMBER_FUNCTION_TESTING_1( DynamicLibManager , aliasLoadLibrary , tstLoadLibrary , const char * , void , NO_RET )
00051                 
00052                 #ifdef ENABLE_AUTOTESTING
00053                         NITRO_EXPORTING void    tstManagerLoadLibrary( const char * ObjectName , const char * LibraryName )
00054                         {
00055                                 try
00056                                 {
00057                                         GET_OBJECT( DynamicLibManager , ObjectName ).LoadLibrary( LibraryName );
00058                                 }
00059                                 catch( nitro::exception e )
00060                                 {
00061                                         std::cout<<e.what()<<std::endl;
00062                                 }
00063                                 catch( ... )
00064                                 {
00065                                         std::cout<<"Undefined exception was caught"<<std::endl;
00066                                 }
00067                         }
00068 
00069                         NITRO_EXPORTING void    tstCall( const char * ObjectName , const char * ExceptionObjectName , const char * Param1 , int Param2 )
00070                         {
00071                                 try
00072                                 {
00073                                         
00074                                         ( ( void ( * )( const char * , const char * , int ) )GET_OBJECT( DynamicLibManager , ObjectName )[ "exception.dll" ]->GetResource( "tstSet" ) )( ExceptionObjectName , Param1 , Param2 );
00075                                 }
00076                                 catch( nitro::exception e )
00077                                 {
00078                                         std::cout<<e.what()<<std::endl;
00079                                 }
00080                                 catch( ... )
00081                                 {
00082                                         std::cout<<"Undefined exception was caught"<<std::endl;
00083                                 }
00084                         }
00085                 #endif
00086 
00087         END_TESTING_SECTION()
00088 }
00089 
00090 #endif