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