X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2Fexamples%2Fexample_LoadPlugins.cxx;h=b68087cd655cbc3c662d486f44d772903f67a7ed;hb=ef8b6e12859181d3faa8019ce7319c539c0f86ec;hp=e46a5db137487004897407233402a412596aa6b4;hpb=48412b66ce1d8d8831625f1a3f51f7e78825f9a1;p=cpPlugins.git diff --git a/appli/examples/example_LoadPlugins.cxx b/appli/examples/example_LoadPlugins.cxx index e46a5db..b68087c 100644 --- a/appli/examples/example_LoadPlugins.cxx +++ b/appli/examples/example_LoadPlugins.cxx @@ -1,36 +1,43 @@ #include #include -#include +#include +// ------------------------------------------------------------------------- +typedef cpPlugins::Interface::Plugins TPlugins; +typedef TPlugins::TStringContainer TStringContainer; + +// ------------------------------------------------------------------------- int main( int argc, char* argv[] ) { if( argc < 2 ) { - std::cerr << "Usage: " << argv[ 0 ] << " plugins_file" << std::endl; + std::cerr << "Usage: " << argv[ 0 ] << " plugins_file(s)" << std::endl; return( 1 ); } // fi - std::string plugins_file = argv[ 1 ]; // Create interface - typedef cpPlugins::Interface::Interface TInterface; - typedef TInterface::TClasses TClasses; + cpPlugins::Interface::Plugins plugins; + + for( int i = 1; i < argc; ++i ) + if( !plugins.LoadPlugins( argv[ i ] ) ) + std::cerr + << "Error loading plugins file \"" + << argv[ i ] << "\"" + << std::endl; - TInterface plugins; - if( !plugins.Load( plugins_file ) ) + TStringContainer categories; + plugins.GetLoadedCategories( categories ); + for( auto pIt = categories.begin( ); pIt != categories.end( ); ++pIt ) { - std::cerr << "Error loading plugins file." << std::endl; - return( 1 ); + std::cout << "Category: " << *pIt << std::endl; + const TStringContainer& filters = plugins.GetLoadedFilters( *pIt ); + for( auto fIt = filters.begin( ); fIt != filters.end( ); ++fIt ) + std::cout << "\t" << *fIt << std::endl; + + } // rof - } // fi - - std::cout << "---------------------------------------------" << std::endl; - std::cout << "Loaded classes:" << std::endl; - TClasses::const_iterator cIt = plugins.GetClasses( ).begin( ); - for( ; cIt != plugins.GetClasses( ).end( ); ++cIt ) - std::cout << " := " << cIt->first << std::endl; - std::cout << "---------------------------------------------" << std::endl; return( 0 ); }