]> Creatis software - cpPlugins.git/blob - appli/examples/example_LoadPlugins.cxx
...
[cpPlugins.git] / appli / examples / example_LoadPlugins.cxx
1 #include <iostream>
2 #include <string>
3
4 #include <cpPlugins/Interface/Interface.h>
5
6 // -------------------------------------------------------------------------
7 typedef cpPlugins::Interface::Interface TInterface;
8
9 // -------------------------------------------------------------------------
10 int main( int argc, char* argv[] )
11 {
12   if( argc < 2 )
13   {
14     std::cerr << "Usage: " << argv[ 0 ] << " plugins_file(s)" << std::endl;
15     return( 1 );
16
17   } // fi
18
19   // Create interface and load plugins
20   TInterface interface;
21
22   for( int i = 1; i < argc; ++i )
23     if( !interface.Load( argv[ i ] ) )
24       std::cerr
25         << "Error loading plugins file \""
26         << argv[ i ] << "\""
27         << std::endl;
28
29   // Show info
30   auto i = interface.GetLoadedPlugins( ).begin( );
31   for( ; i != interface.GetLoadedPlugins( ).end( ); ++i )
32   {
33     std::cout << "Folder: " << i->first << std::endl;
34     auto j = i->second.begin( );
35     for( ; j != i->second.end( ); ++j )
36       std::cout << "\tPlugin: " << *j << std::endl;
37
38   } // rof
39
40   // Show loaded classes
41   auto cat = interface.GetClasses( ).begin( );
42   for( ; cat != interface.GetClasses( ).end( ); ++cat )
43   {
44     std::cout << "Catergory -> " << cat->first << std::endl;
45     auto cla = cat->second.begin( );
46     for( ; cla != cat->second.end( ); ++cla )
47       std::cout << "\tClass -> " << cla->first << std::endl;
48
49   } // rof
50
51   return( 0 );
52 }
53
54 // eof - $RCSfile$