X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2Fexamples%2Fplugins%2Fexample_LoadPluginsDirectory.cxx;h=99f4b62a4c553eaf0a533eca4c3567042acc3018;hb=adb38e2972e7c2e287e73c7b03db344807729219;hp=4e9366db072ab0e5a137d4cd0833fdedfea5b88d;hpb=b67cad9ff3c38b4e99ac48a4852e9e94cb879c6a;p=cpPlugins.git diff --git a/appli/examples/plugins/example_LoadPluginsDirectory.cxx b/appli/examples/plugins/example_LoadPluginsDirectory.cxx index 4e9366d..99f4b62 100644 --- a/appli/examples/plugins/example_LoadPluginsDirectory.cxx +++ b/appli/examples/plugins/example_LoadPluginsDirectory.cxx @@ -5,26 +5,39 @@ int main( int argc, char* argv[] ) { if( argc < 2 ) { - std::cerr << "Usage: " << argv[ 0 ] << " plugins_libraries_dir" << std::endl; + std::cerr + << "Usage: " << argv[ 0 ] << " plugins_libraries_dir" << std::endl; return( 1 ); } // fi // Load interface - cpPlugins::Interface interface; + cpPlugins::Interface* interface = NULL; try { - interface.LoadPluginDir( argv[ 1 ] ); + interface = new cpPlugins::Interface( ); + interface->LoadPluginDir( argv[ 1 ] ); } catch( std::exception& err ) { - std::cerr << "Error caught: " << err.what( ) << std::endl; + if( interface != NULL ) + delete interface; + std::cerr + << "Error caught: " + << err.what( ) + << std::endl; return( 1 ); } // yrt + // Show loaded plugins + auto plugins = interface->GetPlugins( ); + for( auto pIt = plugins.begin( ); pIt != plugins.end( ); ++pIt ) + std::cout << "Plugin: " << *pIt << std::endl; + std::cout << std::endl; + // Show loaded filters - auto filters = interface.GetFilters( ); + auto filters = interface->GetFilters( ); for( auto cIt = filters.begin( ); cIt != filters.end( ); ++cIt ) { std::cout << "Category: " << cIt->first << std::endl; @@ -34,6 +47,9 @@ int main( int argc, char* argv[] ) << std::endl; } // rof + + // Free all and finish + delete interface; return( 0 ); }