]> Creatis software - cpPlugins.git/blob - appli/examples/example_LoadPlugins.cxx
e46a5db137487004897407233402a412596aa6b4
[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" << std::endl;
11     return( 1 );
12
13   } // fi
14   std::string plugins_file = argv[ 1 ];
15
16   // Create interface
17   typedef cpPlugins::Interface::Interface TInterface;
18   typedef TInterface::TClasses            TClasses;
19
20   TInterface plugins;
21   if( !plugins.Load( plugins_file ) )
22   {
23     std::cerr << "Error loading plugins file." << std::endl;
24     return( 1 );
25
26   } // fi
27   
28   std::cout << "---------------------------------------------" << std::endl;
29   std::cout << "Loaded classes:" << std::endl;
30   TClasses::const_iterator cIt = plugins.GetClasses( ).begin( );
31   for( ; cIt != plugins.GetClasses( ).end( ); ++cIt )
32     std::cout << "  := " << cIt->first << std::endl;
33   std::cout << "---------------------------------------------" << std::endl;
34   return( 0 );
35 }
36
37 // eof - $RCSfile$