]> Creatis software - cpPlugins.git/blob - appli/examples/example_LoadPluginsFromPath.cxx
...
[cpPlugins.git] / appli / examples / example_LoadPluginsFromPath.cxx
1 #include <iostream>
2 #include <string>
3
4 #include <cpPlugins/Interface/Plugins.h>
5
6 // -------------------------------------------------------------------------
7 typedef cpPlugins::Interface::Plugins TPlugins;
8 typedef TPlugins::TStringContainer    TStringContainer;
9
10 // -------------------------------------------------------------------------
11 int main( int argc, char* argv[] )
12 {
13   if( argc < 2 )
14   {
15     std::cerr << "Usage: " << argv[ 0 ] << " plugins_file(s)" << std::endl;
16     return( 1 );
17
18   } // fi
19
20   // Create interface
21   cpPlugins::Interface::Plugins plugins;
22
23   if( !plugins.LoadPluginsPath( argv[ 1 ] ) )
24     std::cerr
25       << "Error loading plugins from folder \""
26       << argv[ 1 ] << "\""
27       << std::endl;
28
29   const TStringContainer& loaded_plugins = plugins.GetLoadedPlugins( );
30   auto pIt = loaded_plugins.begin( );
31   for( ; pIt != loaded_plugins.end( ); ++pIt )
32     std::cout << "Plugin: " << *pIt << std::endl;
33   
34   TStringContainer categories;
35   plugins.GetLoadedCategories( categories );
36   for( auto cIt = categories.begin( ); cIt != categories.end( ); ++cIt )
37   {
38     std::cout << "Category: " << *cIt << std::endl;
39     const TStringContainer& filters = plugins.GetLoadedFilters( *cIt );
40     for( auto fIt = filters.begin( ); fIt != filters.end( ); ++fIt )
41       std::cout << "\t" << *fIt << std::endl;
42
43   } // rof
44
45   return( 0 );
46 }
47
48 // eof - $RCSfile$