]> 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 int main( int argc, char* argv[] )
7 {
8   if( argc < 2 )
9   {
10     std::cerr << "Usage: " << argv[ 0 ] << " plugins_file(s)" << std::endl;
11     return( 1 );
12
13   } // fi
14
15   // Create interface
16   typedef cpPlugins::Interface::Interface TInterface;
17   typedef TInterface::TClasses            TClasses;
18
19   TInterface plugins;
20   for( int i = 1; i < argc; ++i )
21     if( !plugins.Load( argv[ i ] ) )
22       std::cerr
23         << "Error loading plugins file \""
24         << argv[ i ] << "\""
25         << std::endl;
26
27   std::cout << "---------------------------------------------" << std::endl;
28   std::cout << "Loaded classes:" << std::endl;
29   TClasses::const_iterator cIt = plugins.GetClasses( ).begin( );
30   for( ; cIt != plugins.GetClasses( ).end( ); ++cIt )
31     std::cout << "  := " << cIt->first << std::endl;
32   std::cout << "---------------------------------------------" << std::endl;
33
34   return( 0 );
35 }
36
37 // eof - $RCSfile$