#include <iostream>
#include <string>
-#include <cpPlugins/Interface/Interface.h>
-#include <cpPlugins/Interface/ProcessObject.h>
+#include <cpPlugins/Interface/Plugins.h>
-#include <cpPlugins/Interface/Image.h>
+// -------------------------------------------------------------------------
+typedef cpPlugins::Interface::Plugins TPlugins;
+// -------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
if( argc < 4 )
} // fi
- // Create interface
- typedef cpPlugins::Interface::Interface TInterface;
- typedef TInterface::TClasses TClasses;
- TInterface plugins;
- if( !plugins.Load( argv[ 1 ] ) )
+ // Load plugins
+ cpPlugins::Interface::Plugins plugins;
+ if( !plugins.LoadPlugins( argv[ 1 ] ) )
{
std::cerr << "Failed to load plugins." << std::endl;
return( 1 );
} // fi
- // Create objects
- typedef cpPlugins::Interface::ProcessObject TProcessObject;
- typedef cpPlugins::Interface::DataObject TDataObject;
- typedef cpPlugins::Interface::Parameters TParameters;
- cpPlugins::Interface::ProcessObject::Pointer reader, writer;
- reader = plugins.CreateProcessObject( "cpPlugins::ImageReader" );
- if( reader.IsNull( ) )
- {
- std::cerr << "No suitable reader found in plugins." << std::endl;
- return( 1 );
-
- } // fi
- writer = plugins.CreateProcessObject( "cpPlugins::ImageWriter" );
- if( writer.IsNull( ) )
- {
- std::cerr << "No suitable writer found in plugins." << std::endl;
- return( 1 );
-
- } // fi
-
- // Configure reader
- TParameters reader_params = reader->GetDefaultParameters( );
+ // Associate filenames
+ std::vector< std::string > fnames;
for( int i = 2; i < argc - 1; ++i )
- reader_params.AddValueToStringList( "FileNames", argv[ i ] );
- reader->SetParameters( reader_params );
-
- // Configure writer
- TParameters writer_params = writer->GetDefaultParameters( );
- writer_params.SetValueAsString( "FileName", argv[ argc - 1 ] );
- writer->SetParameters( writer_params );
-
- // Connect pipeline
- writer->SetInput( 0, reader->GetOutput< TDataObject >( 0 ) );
-
- // Execute pipeline
- std::string err = writer->Update( );
- if( err != "" )
+ fnames.push_back( argv[ i ] );
+
+ // Read image
+ try
{
- std::cerr << "ERROR: " << err << std::endl;
+ std::string name = plugins.ReadImage( fnames, "" );
+ plugins.WriteDataObject( argv[ argc - 1 ], name );
+ }
+ catch( std::exception& err )
+ {
+ std::cerr << err.what( ) << std::endl;
return( 1 );
- } // fi
-
+ } // yrt
return( 0 );
}