]> Creatis software - cpPlugins.git/blobdiff - appli/examples/example_LoadPlugins.cxx
...
[cpPlugins.git] / appli / examples / example_LoadPlugins.cxx
index b68087cd655cbc3c662d486f44d772903f67a7ed..9b4018312cf8c08d977359bde3ceb346360ba005 100644 (file)
@@ -1,11 +1,10 @@
 #include <iostream>
 #include <string>
 
-#include <cpPlugins/Interface/Plugins.h>
+#include <cpPlugins/Interface/Interface.h>
 
 // -------------------------------------------------------------------------
-typedef cpPlugins::Interface::Plugins TPlugins;
-typedef TPlugins::TStringContainer    TStringContainer;
+typedef cpPlugins::Interface::Interface TInterface;
 
 // -------------------------------------------------------------------------
 int main( int argc, char* argv[] )
@@ -17,24 +16,35 @@ int main( int argc, char* argv[] )
 
   } // fi
 
-  // Create interface
-  cpPlugins::Interface::Plugins plugins;
+  // Create interface and load plugins
+  TInterface interface;
 
   for( int i = 1; i < argc; ++i )
-    if( !plugins.LoadPlugins( argv[ i ] ) )
+    if( !interface.Load( argv[ i ] ) )
       std::cerr
         << "Error loading plugins file \""
         << argv[ i ] << "\""
         << std::endl;
 
-  TStringContainer categories;
-  plugins.GetLoadedCategories( categories );
-  for( auto pIt = categories.begin( ); pIt != categories.end( ); ++pIt )
+  // Show info
+  auto i = interface.GetLoadedPlugins( ).begin( );
+  for( ; i != interface.GetLoadedPlugins( ).end( ); ++i )
   {
-    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;
+    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