]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/ProcessObject.cxx
Basic IO architecture within itk-based pipelines
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.cxx
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$