]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/ProcessObject.cxx
...
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.cxx
index 79fc2ab7f84880c3cdb59bdd002d38e8abc94f34..0f8f2885bfb9b9aac979ade6093decb6006b4b1c 100644 (file)
@@ -1,29 +1,8 @@
 #include <cpPlugins/Interface/ProcessObject.h>
-#include <cpPlugins/Interface/DataObject.h>
 
 // -------------------------------------------------------------------------
+const cpPlugins::Interface::Parameters&
 cpPlugins::Interface::ProcessObject::
-ProcessObject( )
-  : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Interface::ProcessObject::
-~ProcessObject( )
-{
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Interface::ProcessObject::
-GetClassName( ) const
-{
-  return( "cpPlugins::Interface::ProcessObject" );
-}
-
-// -------------------------------------------------------------------------
-const cpPlugins::Interface::ProcessObject::
-TParameters& cpPlugins::Interface::ProcessObject::
 GetDefaultParameters( ) const
 {
   return( this->m_DefaultParameters );
@@ -31,9 +10,10 @@ GetDefaultParameters( ) const
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::ProcessObject::
-SetParameters( const TParameters& params )
+SetParameters( const cpPlugins::Interface::Parameters& params )
 {
   this->m_Parameters = params;
+  this->Modified( );
 }
 
 // -------------------------------------------------------------------------
@@ -55,7 +35,8 @@ void cpPlugins::Interface::ProcessObject::
 SetNumberOfInputs( unsigned int n )
 {
   this->m_Inputs.clear( );
-  this->m_Inputs.resize( n, NULL );
+  this->m_Inputs.resize( n );
+  this->Modified( );
 }
 
 // -------------------------------------------------------------------------
@@ -64,20 +45,19 @@ 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 );
+  this->Modified( );
 }
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::ProcessObject::
-SetInput(
-  unsigned int idx, const cpPlugins::Interface::DataObject* dobj
-  )
+SetInput( unsigned int idx, cpPlugins::Interface::DataObject* dobj )
 {
   if( idx < this->m_Inputs.size( ) )
+  {
     this->m_Inputs[ idx ] = dobj;
+    this->Modified( );
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
@@ -85,7 +65,7 @@ cpPlugins::Interface::DataObject* cpPlugins::Interface::ProcessObject::
 GetOutput( unsigned int idx )
 {
   if( idx < this->m_Outputs.size( ) )
-    return( &( this->m_Outputs[ idx ] ) );
+    return( this->m_Outputs[ idx ] );
   else
     return( NULL );
 }
@@ -94,33 +74,47 @@ GetOutput( unsigned int idx )
 std::string cpPlugins::Interface::ProcessObject::
 Update( )
 {
+  std::string r = "";
+
   // Force upstream updates
-  for( unsigned int idx = 0; idx < this->m_Inputs.size( ); ++idx )
-    this->m_Inputs[ idx ]->GetSource( )->Update( );
+  for( unsigned int i = 0; i < this->m_Inputs.size( ) && r == ""; ++i )
+  {
+    Self* src = dynamic_cast< Self* >( this->m_Inputs[ i ]->GetSource( ) );
+    if( src != NULL )
+      r = src->Update( );
+
+  } // rof
 
   // Current update
-  std::string ret = this->_GenerateData( );
+  if( r == "" )
+    r = this->_GenerateData( );
 
   // Return error description, if any
-  return( ret );
+  return( r );
 }
 
 // -------------------------------------------------------------------------
-itk::DataObject* cpPlugins::Interface::ProcessObject::
-_GetInput( unsigned int idx )
+void cpPlugins::Interface::ProcessObject::
+DisconnectOutputs( )
 {
-  if( idx < this->m_Inputs.size( ) )
-    return( this->m_Inputs[ idx ]->GetDataObject( ) );
-  else
-    return( NULL );
+  for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx )
+    if( this->m_Outputs[ idx ].IsNotNull( ) )
+      this->m_Outputs[ idx ]->DisconnectPipeline( );
 }
 
 // -------------------------------------------------------------------------
-void cpPlugins::Interface::ProcessObject::
-_SetOutput( unsigned int idx, itk::DataObject* dobj )
+cpPlugins::Interface::ProcessObject::
+ProcessObject( )
+  : Superclass( )
+{
+  this->m_ClassName = "cpPlugins::Interface::ProcessObject";
+  this->m_ClassCategory = "BasicObject";
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::ProcessObject::
+~ProcessObject( )
 {
-  if( idx < this->m_Outputs.size( ) )
-    this->m_Outputs[ idx ].SetDataObject( dobj );
 }
 
 // eof - $RCSfile$