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