]> Creatis software - cpPlugins.git/commitdiff
Basic IO architecture within itk-based pipelines
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 8 Dec 2014 21:23:50 +0000 (22:23 +0100)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Mon, 8 Dec 2014 21:23:50 +0000 (22:23 +0100)
12 files changed:
appli/examples/example_ReadWriteImage.cxx
lib/cpPlugins/Interface/DataObject.cxx
lib/cpPlugins/Interface/DataObject.h
lib/cpPlugins/Interface/Image.h
lib/cpPlugins/Interface/ProcessObject.cxx
lib/cpPlugins/Interface/ProcessObject.h
lib/cpPlugins/Interface/SinkObject.h
lib/cpPlugins/Interface/SourceObject.cxx
lib/cpPlugins/Plugins/ImageReader.cxx
lib/cpPlugins/Plugins/ImageReader.h
lib/cpPlugins/Plugins/ImageWriter.cxx
lib/cpPlugins/Plugins/ImageWriter.h

index 4d5987b715a1298d9ec5c8cfbcd969577ef6804c..e07761c07a0a8d93b21d2ddf6be5a913bfae2037 100644 (file)
@@ -67,6 +67,19 @@ int main( int argc, char* argv[] )
   reader_params[ "IsColorImage" ].second = ( is_color )? "1": "0";
   reader->SetParameters( reader_params );
 
+  // Configure reader
+  TParameters writer_params = writer->GetDefaultParameters( );
+  writer_params[ "FileName" ].second = output_image_file;
+  writer->SetParameters( writer_params );
+
+  // Connect pipeline
+  writer->SetInput( 0, reader->GetOutput( 0 ) );
+
+  std::string msg = writer->Update( );
+
+  if( msg != "" )
+    std::cerr << "ERROR: " << msg << std::endl;
+
   // Free memory
   delete writer;
   delete reader;
index 0b64bec5d93f5d4f757cb8ec5f0ce9a87321371c..9c15346370e3d4b970f3672208fa802d5133c7e5 100644 (file)
@@ -21,9 +21,23 @@ GetClassName( ) const
   return( "cpPlugins::Interface::DataObject" );
 }
 
+// -------------------------------------------------------------------------
+itk::DataObject* cpPlugins::Interface::DataObject::
+GetDataObject( ) const
+{
+  return( this->m_DataObject );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::DataObject::
+SetDataObject( itk::DataObject* src )
+{
+  this->m_DataObject = src;
+}
+
 // -------------------------------------------------------------------------
 cpPlugins::Interface::ProcessObject* cpPlugins::Interface::DataObject::
-GetSource( ProcessObject* src ) const
+GetSource( ) const
 {
   return( this->m_Source );
 }
@@ -35,6 +49,4 @@ SetSource( cpPlugins::Interface::ProcessObject* src )
   this->m_Source = src;
 }
 
-#endif // __CPPLUGINS__INTERFACE__DATAOBJECT__H__
-
 // eof - $RCSfile$
index 359b2b4007f156260135cdf32a4c37834a2e5808..9a8901e0c54e8c7f030fc5c2f4a41fd791ec83ed 100644 (file)
@@ -28,7 +28,7 @@ namespace cpPlugins
       virtual std::string GetClassName( ) const;
 
       itk::DataObject* GetDataObject( ) const;
-      void SetDataObject( itk::DataObject* src );
+      virtual void SetDataObject( itk::DataObject* src );
 
       ProcessObject* GetSource( ) const;
       void SetSource( ProcessObject* src );
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..360da0168821d1543cfb65767a24e2983ea53678 100644 (file)
@@ -0,0 +1,35 @@
+#ifndef __CPPLUGINS__INTERFACE__IMAGE__H__
+#define __CPPLUGINS__INTERFACE__IMAGE__H__
+
+#include <map>
+#include <string>
+#include <itkProcessObject.h>
+#include <cpPlugins/Interface/DataObject.h>
+
+namespace cpPlugins
+{
+  namespace Interface
+  {
+    /**
+     */
+    class Image
+      : public DataObject
+    {
+    public:
+      typedef Image      Self;
+      typedef DataObject Superclass;
+
+    public:
+      Image( );
+      virtual ~Image( );
+
+      virtual std::string GetClassName( ) const;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__INTERFACE__IMAGE__H__
+
+// eof - $RCSfile$
index cd88ea67ba637162b0938bd3474eb5a37cc9294b..79fc2ab7f84880c3cdb59bdd002d38e8abc94f34 100644 (file)
@@ -1,4 +1,5 @@
 #include <cpPlugins/Interface/ProcessObject.h>
+#include <cpPlugins/Interface/DataObject.h>
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::ProcessObject::
@@ -49,6 +50,26 @@ GetNumberOfOutputs( ) const
   return( this->m_Outputs.size( ) );
 }
 
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+SetNumberOfInputs( unsigned int n )
+{
+  this->m_Inputs.clear( );
+  this->m_Inputs.resize( n, NULL );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+SetNumberOfOutputs( unsigned int n )
+{
+  this->m_Outputs.clear( );
+  this->m_Outputs.resize( n );
+
+  // Sync outputs with this source
+  for( unsigned int odx = 0; odx < this->m_Outputs.size( ); ++odx )
+    this->m_Outputs[ odx ].SetSource( this );
+}
+
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::ProcessObject::
 SetInput(
@@ -61,10 +82,10 @@ SetInput(
 
 // -------------------------------------------------------------------------
 cpPlugins::Interface::DataObject* cpPlugins::Interface::ProcessObject::
-GetOutput( unsigned int idx ) const
+GetOutput( unsigned int idx )
 {
   if( idx < this->m_Outputs.size( ) )
-    return( this->m_Outputs[ idx ] );
+    return( &( this->m_Outputs[ idx ] ) );
   else
     return( NULL );
 }
@@ -75,17 +96,31 @@ Update( )
 {
   // Force upstream updates
   for( unsigned int idx = 0; idx < this->m_Inputs.size( ); ++idx )
-    this->m_Inputs->GetSource( )->Update( );
+    this->m_Inputs[ idx ]->GetSource( )->Update( );
 
   // Current update
   std::string ret = this->_GenerateData( );
 
-  // Sync outputs
-  for( unsigned int odx = 0; odx < this->m_Outputs.size( ); ++odx )
-    this->m_Outputs->SetSource( this );
-
+  // Return error description, if any
   return( ret );
 }
 
+// -------------------------------------------------------------------------
+itk::DataObject* cpPlugins::Interface::ProcessObject::
+_GetInput( unsigned int idx )
+{
+  if( idx < this->m_Inputs.size( ) )
+    return( this->m_Inputs[ idx ]->GetDataObject( ) );
+  else
+    return( NULL );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::ProcessObject::
+_SetOutput( unsigned int idx, itk::DataObject* dobj )
+{
+  if( idx < this->m_Outputs.size( ) )
+    this->m_Outputs[ idx ].SetDataObject( dobj );
+}
 
 // eof - $RCSfile$
index 31379136eeb73f5d519420f9e8795c38593629ed..362cd762461234eeefcd53ae2e8300dda9db9829 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <map>
 #include <string>
+#include <itkDataObject.h>
 #include <cpPlugins/Interface/Object.h>
 
 namespace cpPlugins
@@ -34,12 +35,17 @@ namespace cpPlugins
       virtual unsigned int GetNumberOfInputs( ) const;
       virtual unsigned int GetNumberOfOutputs( ) const;
 
+      virtual void SetNumberOfInputs( unsigned int n );
+      virtual void SetNumberOfOutputs( unsigned int n );
+
       virtual void SetInput( unsigned int idx, const DataObject* dobj );
-      virtual DataObject* GetOutput( unsigned int idx ) const;
+      virtual DataObject* GetOutput( unsigned int idx );
 
       virtual std::string Update( );
 
     protected:
+      virtual itk::DataObject* _GetInput( unsigned int idx );
+      virtual void _SetOutput( unsigned int idx, itk::DataObject* dobj );
       virtual std::string _GenerateData( ) = 0;
 
     protected:
@@ -47,7 +53,7 @@ namespace cpPlugins
       TParameters m_Parameters;
 
       std::vector< const DataObject* > m_Inputs;
-      std::vector< DataObject* > m_Outputs;
+      std::vector< DataObject >        m_Outputs;
     };
 
   } // ecapseman
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..38801df80196fd0f465bb083b63767281af7dded 100644 (file)
@@ -0,0 +1,35 @@
+#ifndef __CPPLUGINS__INTERFACE__SINKOBJECT__H__
+#define __CPPLUGINS__INTERFACE__SINKOBJECT__H__
+
+#include <cpPlugins/Interface/ProcessObject.h>
+
+namespace cpPlugins
+{
+  namespace Interface
+  {
+    /**
+     */
+    class SinkObject
+      : public ProcessObject
+    {
+    public:
+      typedef SinkObject    Self;
+      typedef ProcessObject Superclass;
+
+      typedef Superclass::TParameter  TParameter;
+      typedef Superclass::TParameters TParameters;
+
+    public:
+      SinkObject( );
+      virtual ~SinkObject( );
+
+      virtual std::string GetClassName( ) const;
+    };
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__INTERFACE__SINKOBJECT__H__
+
+// eof - $RCSfile$
index b798def5bf2a672bec192db10bba99ca1f8c4866..b4499dbbf16a9c6dc0363272362c6ce7f372d24c 100644 (file)
@@ -5,6 +5,7 @@ cpPlugins::Interface::SourceObject::
 SourceObject( )
   : Superclass( )
 {
+  this->SetNumberOfInputs( 0 );
 }
 
 // -------------------------------------------------------------------------
index 5bc182ed530bb2f0e4fbf2c71e586d2ed0cb06e6..feca19b52bb063cb79c3f5a23164b41d40e39385 100644 (file)
@@ -10,6 +10,8 @@ cpPlugins::Plugins::ImageReader::
 ImageReader( )
   : Superclass( )
 {
+  this->SetNumberOfOutputs( 1 );
+
   this->m_DefaultParameters[ "FileName" ] =
     TParameter( "string", "no_file_name" );
   this->m_DefaultParameters[ "PixelType" ] = TParameter( "type", "uchar" );
@@ -31,8 +33,8 @@ GetClassName( ) const
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Plugins::ImageReader::
-Update( )
+std::string cpPlugins::Plugins::ImageReader::
+_GenerateData( )
 {
   TParameters::const_iterator dIt;
 
@@ -41,19 +43,19 @@ Update( )
   if( dIt == this->m_Parameters.end( ) )
     dIt = this->m_DefaultParameters.find( "ImageDimension" );
 
-  bool ret = false;
-  if     ( dIt->second.second == "1" ) ret = this->_Update0< 1 >( );
-  else if( dIt->second.second == "2" ) ret = this->_Update0< 2 >( );
-  else if( dIt->second.second == "3" ) ret = this->_Update0< 3 >( );
-  else if( dIt->second.second == "4" ) ret = this->_Update0< 4 >( );
+  std::string ret = "itk::Image dimension not supported.";
+  if     ( dIt->second.second == "1" ) ret = this->_GenerateData0< 1 >( );
+  else if( dIt->second.second == "2" ) ret = this->_GenerateData0< 2 >( );
+  else if( dIt->second.second == "3" ) ret = this->_GenerateData0< 3 >( );
+  else if( dIt->second.second == "4" ) ret = this->_GenerateData0< 4 >( );
 
   return( ret );
 }
 
 // -------------------------------------------------------------------------
 template< unsigned int D >
-bool cpPlugins::Plugins::ImageReader::
-_Update0( )
+std::string cpPlugins::Plugins::ImageReader::
+_GenerateData0( )
 {
   TParameters::const_iterator tIt, cIt;
 
@@ -65,60 +67,60 @@ _Update0( )
   if( cIt == this->m_Parameters.end( ) )
     cIt = this->m_DefaultParameters.find( "IsColorImage" );
 
-  bool ret = false;
+  std::string ret = "itk::Image pixel type not supported";
   if( cIt->second.second == "0" )
   {
     if( tIt->second.second == "char" )
-      ret = this->_Update1< char, D >( );
+      ret = this->_GenerateData1< char, D >( );
     else if( tIt->second.second == "short" )
-      ret = this->_Update1< short, D >( );
+      ret = this->_GenerateData1< short, D >( );
     else if( tIt->second.second == "int" )
-      ret = this->_Update1< int, D >( );
+      ret = this->_GenerateData1< int, D >( );
     else if( tIt->second.second == "long" )
-      ret = this->_Update1< long, D >( );
+      ret = this->_GenerateData1< long, D >( );
     else if( tIt->second.second == "uchar" )
-      ret = this->_Update1< unsigned char, D >( );
+      ret = this->_GenerateData1< unsigned char, D >( );
     else if( tIt->second.second == "ushort" )
-      ret = this->_Update1< unsigned short, D >( );
+      ret = this->_GenerateData1< unsigned short, D >( );
     else if( tIt->second.second == "uint" )
-      ret = this->_Update1< unsigned int, D >( );
+      ret = this->_GenerateData1< unsigned int, D >( );
     else if( tIt->second.second == "ulong" )
-      ret = this->_Update1< unsigned long, D >( );
+      ret = this->_GenerateData1< unsigned long, D >( );
     else if( tIt->second.second == "float" )
-      ret = this->_Update1< float, D >( );
+      ret = this->_GenerateData1< float, D >( );
     else if( tIt->second.second == "double" )
-      ret = this->_Update1< double, D >( );
+      ret = this->_GenerateData1< double, D >( );
   }
   else if( cIt->second.second == "1" )
   {
     if( tIt->second.second == "char" )
-      ret = this->_Update1< itk::RGBPixel< char >, D >( );
+      ret = this->_GenerateData1< itk::RGBPixel< char >, D >( );
     else if( tIt->second.second == "short" )
-      ret = this->_Update1< itk::RGBPixel< short >, D >( );
+      ret = this->_GenerateData1< itk::RGBPixel< short >, D >( );
     else if( tIt->second.second == "int" )
-      ret = this->_Update1< itk::RGBPixel< int >, D >( );
+      ret = this->_GenerateData1< itk::RGBPixel< int >, D >( );
     else if( tIt->second.second == "long" )
-      ret = this->_Update1< itk::RGBPixel< long >, D >( );
+      ret = this->_GenerateData1< itk::RGBPixel< long >, D >( );
     else if( tIt->second.second == "uchar" )
-      ret = this->_Update1< itk::RGBPixel< unsigned char >, D >( );
+      ret = this->_GenerateData1< itk::RGBPixel< unsigned char >, D >( );
     else if( tIt->second.second == "ushort" )
-      ret = this->_Update1< itk::RGBPixel< unsigned short >, D >( );
+      ret = this->_GenerateData1< itk::RGBPixel< unsigned short >, D >( );
     else if( tIt->second.second == "uint" )
-      ret = this->_Update1< itk::RGBPixel< unsigned int >, D >( );
+      ret = this->_GenerateData1< itk::RGBPixel< unsigned int >, D >( );
     else if( tIt->second.second == "ulong" )
-      ret = this->_Update1< itk::RGBPixel< unsigned long >, D >( );
+      ret = this->_GenerateData1< itk::RGBPixel< unsigned long >, D >( );
     else if( tIt->second.second == "float" )
-      ret = this->_Update1< itk::RGBPixel< float >, D >( );
+      ret = this->_GenerateData1< itk::RGBPixel< float >, D >( );
     else if( tIt->second.second == "double" )
-      ret = this->_Update1< itk::RGBPixel< double >, D >( );
+      ret = this->_GenerateData1< itk::RGBPixel< double >, D >( );
   } // fi
   return( ret );
 }
 
 // -------------------------------------------------------------------------
 template< class P, unsigned int D >
-bool cpPlugins::Plugins::ImageReader::
-_Update1( )
+std::string cpPlugins::Plugins::ImageReader::
+_GenerateData1( )
 {
   TParameters::const_iterator fIt;
 
@@ -145,10 +147,11 @@ _Update1( )
   }
   catch( itk::ExceptionObject& err )
   {
-    return( false );
+    return( err.GetDescription( ) );
 
   } // yrt
-  return( true );
+  this->_SetOutput( 0, reader->GetOutput( ) );
+  return( "" );
 }
 
 // eof - $RCSfile$
index 6110c928f276cdfee78234b139ebcebea20298d6..4ecdfab820c488fd63d9252f1516c3f33fabeaa7 100644 (file)
@@ -28,13 +28,13 @@ namespace cpPlugins
 
     protected:
 
-      virtual bool _GenerateData( );
+      virtual std::string _GenerateData( );
 
       template< unsigned int D >
-      bool _GenerateData0( );
+      std::string _GenerateData0( );
 
       template< class P, unsigned int D >
-      bool _GenerateData1( );
+      std::string _GenerateData1( );
 
     protected:
       itk::ProcessObject::Pointer m_Reader;
index 3dd319afef43ec75ef6d6476aa57ce70db4c23fc..e4af224e204ec0cb1c6a236a67a48e127f0d9a1f 100644 (file)
@@ -1,10 +1,34 @@
 #include <cpPlugins/Plugins/ImageWriter.h>
 
+// TODO: interesting... #define ITK_MANUAL_INSTANTIATION
+#include <itkImage.h>
+#include <itkImageFileWriter.h>
+#include <itkRGBPixel.h>
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Plugins_ImageWriter_Dimension( ret, d, dobj, func )   \
+  if( dynamic_cast< itk::ImageBase< d >* >( dobj ) != NULL )            \
+    ret = this->func< d >( )
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Plugins_ImageWriter_Pixel( ret, p, d, dobj, func )    \
+  if( dynamic_cast< itk::Image< p, d >* >( dobj ) != NULL )             \
+    ret = this->func< p, d >( )
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Plugins_ImageWriter_RGB( ret, p, d, dobj, func )      \
+  if( dynamic_cast< itk::Image< itk::RGBPixel< p >, d >* >( dobj ) != NULL ) \
+    ret = this->func< itk::RGBPixel< p >, d >( )
+
 // -------------------------------------------------------------------------
 cpPlugins::Plugins::ImageWriter::
 ImageWriter( )
   : Superclass( )
 {
+  this->SetNumberOfInputs( 1 );
+
+  this->m_DefaultParameters[ "FileName" ] =
+    TParameter( "string", "no_file_name" );
 }
 
 // -------------------------------------------------------------------------
@@ -21,10 +45,88 @@ GetClassName( ) const
 }
 
 // -------------------------------------------------------------------------
-bool cpPlugins::Plugins::ImageWriter::
-Update( )
+std::string cpPlugins::Plugins::ImageWriter::
+_GenerateData( )
+{
+  itk::DataObject* dobj = this->_GetInput( 0 );
+
+  std::string ret = "itk::Image dimension not supported.";
+  cpPlugins_Plugins_ImageWriter_Dimension( ret, 1, dobj, _GenerateData0 );
+  else cpPlugins_Plugins_ImageWriter_Dimension( ret, 2, dobj, _GenerateData0 );
+  else cpPlugins_Plugins_ImageWriter_Dimension( ret, 3, dobj, _GenerateData0 );
+  else cpPlugins_Plugins_ImageWriter_Dimension( ret, 4, dobj, _GenerateData0 );
+
+  return( ret );
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int D >
+std::string cpPlugins::Plugins::ImageWriter::
+_GenerateData0( )
+{
+  itk::ImageBase< D >* img =
+    dynamic_cast< itk::ImageBase< D >* >( this->_GetInput( 0 ) );
+
+  std::string ret = "itk::Image pixel type not supported";
+  cpPlugins_Plugins_ImageWriter_Pixel( ret, char, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_Pixel( ret, short, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_Pixel( ret, int, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_Pixel( ret, long, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_Pixel( ret, unsigned char, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_Pixel( ret, unsigned short, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_Pixel( ret, unsigned int, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_Pixel( ret, unsigned long, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_Pixel( ret, float, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_Pixel( ret, double, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_RGB( ret, char, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_RGB( ret, short, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_RGB( ret, int, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_RGB( ret, long, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_RGB( ret, unsigned char, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_RGB( ret, unsigned short, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_RGB( ret, unsigned int, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_RGB( ret, unsigned long, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_RGB( ret, float, D, img, _GenerateData1 );
+  else cpPlugins_Plugins_ImageWriter_RGB( ret, double, D, img, _GenerateData1 );
+
+  return( ret );
+}
+
+// -------------------------------------------------------------------------
+template< class P, unsigned int D >
+std::string cpPlugins::Plugins::ImageWriter::
+_GenerateData1( )
 {
-  return( false );
+  typedef itk::Image< P, D > _TImage;
+  typedef itk::ImageFileWriter< _TImage > _TImageWriter;
+
+  TParameters::const_iterator fIt;
+
+  // Get image pixelType
+  fIt = this->m_Parameters.find( "FileName" );
+  if( fIt == this->m_Parameters.end( ) )
+    fIt = this->m_DefaultParameters.find( "FileName" );
+
+  _TImageWriter* writer =
+    dynamic_cast< _TImageWriter* >( this->m_Writer.GetPointer( ) );
+  if( writer == NULL )
+  {
+    this->m_Writer = _TImageWriter::New( );
+    writer = dynamic_cast< _TImageWriter* >( this->m_Writer.GetPointer( ) );
+
+  } // fi
+  writer->SetFileName( fIt->second.second );
+  writer->SetInput( dynamic_cast< _TImage* >( this->_GetInput( 0 ) ) );
+  try
+  {
+    writer->Update( );
+  }
+  catch( itk::ExceptionObject& err )
+  {
+    return( err.GetDescription( ) );
+
+  } // yrt
+  return( "" );
 }
 
 // eof - $RCSfile$
index af80058b2081bc457600f4649bfdec067e292776..78f00efc0985c3da4772dcff57e99acc12dd9328 100644 (file)
@@ -1,7 +1,8 @@
 #ifndef __CPPLUGINS__PLUGINS__IMAGEWRITER__H__
 #define __CPPLUGINS__PLUGINS__IMAGEWRITER__H__
 
-#include <cpPlugins/Interface/SourceObject.h>
+#include <cpPlugins/Interface/SinkObject.h>
+#include <itkProcessObject.h>
 
 namespace cpPlugins
 {
@@ -10,11 +11,11 @@ namespace cpPlugins
     /**
      */
     class ImageWriter
-      : public cpPlugins::Interface::SourceObject
+      : public cpPlugins::Interface::SinkObject
     {
     public:
-      typedef ImageWriter                        Self;
-      typedef cpPlugins::Interface::SourceObject Superclass;
+      typedef ImageWriter                      Self;
+      typedef cpPlugins::Interface::SinkObject Superclass;
 
       typedef Superclass::TParameter  TParameter;
       typedef Superclass::TParameters TParameters;
@@ -24,7 +25,18 @@ namespace cpPlugins
       virtual ~ImageWriter( );
 
       virtual std::string GetClassName( ) const;
-      virtual bool Update( );
+
+    protected:
+      virtual std::string _GenerateData( );
+
+      template< unsigned int D >
+      std::string _GenerateData0( );
+
+      template< class P, unsigned int D >
+      std::string _GenerateData1( );
+
+    protected:
+      itk::ProcessObject::Pointer m_Writer;
     };
 
     // ---------------------------------------------------------------------