]> Creatis software - cpPlugins.git/blobdiff - appli/examples/example_LoadPlugins.cxx
...
[cpPlugins.git] / appli / examples / example_LoadPlugins.cxx
index edbb600cc60f4576f4e2bfff6e2f0b6a250e77e2..9b4018312cf8c08d977359bde3ceb346360ba005 100644 (file)
@@ -3,31 +3,51 @@
 
 #include <cpPlugins/Interface/Interface.h>
 
+// -------------------------------------------------------------------------
+typedef cpPlugins::Interface::Interface TInterface;
+
+// -------------------------------------------------------------------------
 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;
-
-  TInterface plugins;
-  plugins.Load( plugins_file );
-
-  std::cout << "---------------------------------------------" << std::endl;
-  std::cout << "Loaded classes:" << std::endl;
-  TClasses::const_iterator cIt = plugins.GetClasses( ).begin( );
-  TClasses::const_iterator end_cIt = plugins.GetClasses( ).end( );
-  for( ; cIt != end_cIt; ++cIt )
-    std::cout << "\t:= " << cIt->first << std::endl;
-  std::cout << "---------------------------------------------" << std::endl;
-  
+
+  // Create interface and load plugins
+  TInterface interface;
+
+  for( int i = 1; i < argc; ++i )
+    if( !interface.Load( argv[ i ] ) )
+      std::cerr
+        << "Error loading plugins file \""
+        << argv[ i ] << "\""
+        << std::endl;
+
+  // Show info
+  auto i = interface.GetLoadedPlugins( ).begin( );
+  for( ; i != interface.GetLoadedPlugins( ).end( ); ++i )
+  {
+    std::cout << "Folder: " << i->first << std::endl;
+    auto j = i->second.begin( );
+    for( ; j != i->second.end( ); ++j )
+      std::cout << "\tPlugin: " << *j << std::endl;
+
+  } // rof
+
+  // Show loaded classes
+  auto cat = interface.GetClasses( ).begin( );
+  for( ; cat != interface.GetClasses( ).end( ); ++cat )
+  {
+    std::cout << "Catergory -> " << cat->first << std::endl;
+    auto cla = cat->second.begin( );
+    for( ; cla != cat->second.end( ); ++cla )
+      std::cout << "\tClass -> " << cla->first << std::endl;
+
+  } // rof
+
   return( 0 );
 }