]> Creatis software - cpPlugins.git/blobdiff - appli/examples/example_LoadPluginsFromPath.cxx
More on graph editor
[cpPlugins.git] / appli / examples / example_LoadPluginsFromPath.cxx
index 3747995dcb6c5f97b4a1a6432b2fe947cfccbd59..ba684ce52e9eeb39d704cfa9678fa72468747aa0 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,31 +16,26 @@ int main( int argc, char* argv[] )
 
   } // fi
 
-  // Create interface
-  cpPlugins::Interface::Plugins plugins;
-
-  if( !plugins.LoadPluginsPath( argv[ 1 ] ) )
-    std::cerr
-      << "Error loading plugins from folder \""
-      << argv[ 1 ] << "\""
-      << std::endl;
-
-  const TStringContainer& loaded_plugins = plugins.GetLoadedPlugins( );
-  auto pIt = loaded_plugins.begin( );
-  for( ; pIt != loaded_plugins.end( ); ++pIt )
-    std::cout << "Plugin: " << *pIt << std::endl;
-  
-  TStringContainer categories;
-  plugins.GetLoadedCategories( categories );
-  for( auto cIt = categories.begin( ); cIt != categories.end( ); ++cIt )
+  // Create interface and load plugins
+  TInterface interface;
+  interface.LoadFromFolder( argv[ 1 ], true );
+
+  // Show info
+  auto i = interface.GetLoadedPlugins( ).begin( );
+  for( ; i != interface.GetLoadedPlugins( ).end( ); ++i )
   {
-    std::cout << "Category: " << *cIt << std::endl;
-    const TStringContainer& filters = plugins.GetLoadedFilters( *cIt );
-    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 c = interface.GetClasses( ).begin( );
+  for( ; c != interface.GetClasses( ).end( ); ++c )
+    std::cout << "Class -> " << c->first << std::endl;
+
   return( 0 );
 }