]> Creatis software - cpPlugins.git/blob - appli/examples/plugins/example_LoadPluginsDirectory.cxx
...
[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
9       << "Usage: " << argv[ 0 ] << " plugins_libraries_dir" << std::endl;
10     return( 1 );
11
12   } // fi
13
14   // Load interface
15   cpPlugins::Interface* interface = NULL;
16   try
17   {
18     interface = new cpPlugins::Interface( );
19     interface->LoadPluginDir( argv[ 1 ] );
20   }
21   catch( std::exception& err )
22   {
23     if( interface != NULL )
24       delete interface;
25     std::cerr
26       << "Error caught: "
27       << err.what( )
28       << std::endl;
29     return( 1 );
30
31   } // yrt
32
33   // Show loaded plugins
34   auto plugins = interface->GetPlugins( );
35   for( auto pIt = plugins.begin( ); pIt != plugins.end( ); ++pIt )
36     std::cout << "Plugin: " << *pIt << std::endl;
37   std::cout << std::endl;
38
39   // Show loaded filters
40   auto filters = interface->GetFilters( );
41   for( auto cIt = filters.begin( ); cIt != filters.end( ); ++cIt )
42   {
43     std::cout << "Category: " << cIt->first << std::endl;
44     for( auto nIt = cIt->second.begin( ); nIt != cIt->second.end( ); ++nIt )
45       std::cout
46         << "\tFilter: " << *nIt
47         << std::endl;
48
49   } // rof
50
51   // Free all and finish
52   delete interface;
53   return( 0 );
54 }
55
56 // eof - $RCSfile$