]> Creatis software - cpPlugins.git/blobdiff - appli/examples/plugins/example_GuessPlugins.cxx
...
[cpPlugins.git] / appli / examples / plugins / example_GuessPlugins.cxx
index 8a54b748f16077fa582fb2a49d411a9531772098..72b5f157906cef2fea866d61c8052ab7c555f968 100644 (file)
@@ -4,17 +4,32 @@
 int main( int argc, char* argv[] )
 {
   // Load interface
-  cpPlugins::Interface interface;
-  interface.GuessAccesiblePlugins( );
+  cpPlugins::Interface* interface = NULL;
+  try
+  {
+    interface = new cpPlugins::Interface( );
+    interface->GuessAccesiblePlugins( );
+  }
+  catch( std::exception& err )
+  {
+    if( interface != NULL )
+      delete interface;
+    std::cerr
+      << "Error caught: "
+      << err.what( )
+      << std::endl;
+    return( 1 );
+
+  } // yrt
 
   // Show loaded plugins
-  auto plugins = interface.GetPlugins( );
+  auto plugins = interface->GetPlugins( );
   for( auto pIt = plugins.begin( ); pIt != plugins.end( ); ++pIt )
     std::cout << "Plugin: " << *pIt << std::endl;
   std::cout << std::endl;
 
   // Show loaded filters
-  auto filters = interface.GetFilters( );
+  auto filters = interface->GetFilters( );
   for( auto cIt = filters.begin( ); cIt != filters.end( ); ++cIt )
   {
     std::cout << "Category: " << cIt->first << std::endl;
@@ -24,6 +39,9 @@ int main( int argc, char* argv[] )
         << std::endl;
 
   } // rof
+
+  // Free all and finish
+  delete interface;
   return( 0 );
 }