X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2Fexamples%2Fexample_RGBImageToHSVChannels.cxx;fp=appli%2Fexamples%2Fexample_RGBImageToHSVChannels.cxx;h=9a2a46893fd33e684e628ef9f549e2a8337f4920;hb=cb833d2fface96e020fe91584d2206860a8174ee;hp=7266800302c47aa44ebd84b1b82b587d26c3f1e3;hpb=2f1688b7490f99c3cb932344b1d8db51bd821c4b;p=cpPlugins.git diff --git a/appli/examples/example_RGBImageToHSVChannels.cxx b/appli/examples/example_RGBImageToHSVChannels.cxx index 7266800..9a2a468 100644 --- a/appli/examples/example_RGBImageToHSVChannels.cxx +++ b/appli/examples/example_RGBImageToHSVChannels.cxx @@ -18,12 +18,9 @@ void SaveImage( TInterface& plugins, const std::string& fname, TDataObject* image ) { - cpPlugins::Interface::ProcessObject* writer; - writer = - dynamic_cast< TProcessObject* >( - plugins.CreateObject( "cpPlugins::Plugins::ImageWriter" ) - ); - if( writer == NULL ) + TProcessObject::Pointer writer; + writer = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageWriter" ); + if( writer.IsNull( ) ) { std::cerr << "No suitable writer found in plugins." << std::endl; return; @@ -38,7 +35,6 @@ void SaveImage( std::string msg = writer->Update( ); if( msg != "" ) std::cerr << "ERROR: " << msg << std::endl; - delete writer; } // ------------------------------------------------------------------------- @@ -69,24 +65,18 @@ int main( int argc, char* argv[] ) plugins.Load( plugins_file ); // Create objects - cpPlugins::Interface::ProcessObject* reader; - cpPlugins::Interface::ProcessObject* filter; - - reader = - dynamic_cast< TProcessObject* >( - plugins.CreateObject( "cpPlugins::Plugins::ImageReader" ) - ); - if( reader == NULL ) + TProcessObject::Pointer reader; + TProcessObject::Pointer filter; + + reader = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageReader" ); + if( reader.IsNull( ) ) { std::cerr << "No suitable reader found in plugins." << std::endl; return( 1 ); } // fi - filter = - dynamic_cast< TProcessObject* >( - plugins.CreateObject( "cpPlugins::Plugins::RGBImageToHSVChannelsFilter" ) - ); - if( filter == NULL ) + filter = plugins.CreateProcessObject( "cpPlugins::Plugins::RGBImageToHSVChannelsFilter" ); + if( filter.IsNull( ) ) { std::cerr << "No suitable filter found in plugins." << std::endl; return( 1 ); @@ -109,10 +99,6 @@ int main( int argc, char* argv[] ) SaveImage( plugins, output_saturation_image_file, filter->GetOutput( 1 ) ); SaveImage( plugins, output_value_image_file, filter->GetOutput( 2 ) ); - // Free memory - delete filter; - delete reader; - return( 0 ); }