]> Creatis software - cpPlugins.git/blob - appli/examples/plugins/example_LoadPluginsDirectory.cxx
803d3909b89c2ad7b66a6a8a55c734e0ca7f6b4a
[cpPlugins.git] / appli / examples / plugins / example_LoadPluginsDirectory.cxx
1 #include <iostream>
2 #include <cpPlugins/Interface.h>
3
4 int main( int argc, char* argv[] )
5 {
6   if( argc < 2 )
7   {
8     std::cerr << "Usage: " << argv[ 0 ] << " plugins_libraries_dir" << std::endl;
9     return( 1 );
10
11   } // fi
12
13   // Load interface
14   cpPlugins::Interface interface;
15   try
16   {
17     interface.LoadPluginDir( argv[ 1 ] );
18   }
19   catch( std::exception& err )
20   {
21     std::cerr << "Error caught: " << err.what( ) << std::endl;
22     return( 1 );
23
24   } // yrt
25
26   // Show loaded plugins
27   auto plugins = interface.GetPlugins( );
28   for( auto pIt = plugins.begin( ); pIt != plugins.end( ); ++pIt )
29     std::cout << "Plugin: " << *pIt << std::endl;
30   std::cout << std::endl;
31
32   // Show loaded filters
33   auto filters = interface.GetFilters( );
34   for( auto cIt = filters.begin( ); cIt != filters.end( ); ++cIt )
35   {
36     std::cout << "Category: " << cIt->first << std::endl;
37     for( auto nIt = cIt->second.begin( ); nIt != cIt->second.end( ); ++nIt )
38       std::cout
39         << "\tFilter: " << *nIt
40         << std::endl;
41
42   } // rof
43   return( 0 );
44 }
45
46 // eof - $RCSfile$