X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FInterface%2FProcessObject.cxx;h=61eaf96e661763080ed48470bfabf069bca4e8b5;hb=aa6a578004bddb5b0bb07b780483fda0ecc6cb5e;hp=a595e0ec3f71d60df5c583d4d7d9b29bd72d0696;hpb=1adce86c283e253ec41f762652bc477d56d617a5;p=cpPlugins.git diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index a595e0e..61eaf96 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -1,31 +1,22 @@ #include -#include // ------------------------------------------------------------------------- -cpPlugins::Interface::ProcessObject:: -ProcessObject( ) - : Superclass( ), - m_OutputsDisconnected( false ) -{ -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::ProcessObject:: -~ProcessObject( ) +std::string cpPlugins::Interface::ProcessObject:: +GetClassName( ) const { - this->_DeleteOutputs( ); + return( "cpPlugins::Interface::ProcessObject" ); } // ------------------------------------------------------------------------- std::string cpPlugins::Interface::ProcessObject:: -GetClassName( ) const +GetClassType( ) const { - return( "cpPlugins::Interface::ProcessObject" ); + return( "ProcessObject" ); } // ------------------------------------------------------------------------- -const cpPlugins::Interface::ProcessObject:: -TParameters& cpPlugins::Interface::ProcessObject:: +const cpPlugins::Interface::Parameters& +cpPlugins::Interface::ProcessObject:: GetDefaultParameters( ) const { return( this->m_DefaultParameters ); @@ -33,9 +24,10 @@ GetDefaultParameters( ) const // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: -SetParameters( const TParameters& params ) +SetParameters( const cpPlugins::Interface::Parameters& params ) { this->m_Parameters = params; + this->Modified( ); } // ------------------------------------------------------------------------- @@ -57,27 +49,29 @@ 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( ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: SetNumberOfOutputs( unsigned int n ) { - this->_DeleteOutputs( ); this->m_Outputs.clear( ); - this->m_Outputs.resize( n, NULL ); - this->m_OutputsDisconnected = false; + this->m_Outputs.resize( n ); + 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 } // ------------------------------------------------------------------------- @@ -94,26 +88,45 @@ 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( ); - this->m_OutputsDisconnected = false; + if( r == "" ) + r = this->_GenerateData( ); // Return error description, if any - return( ret ); + return( r ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: DisconnectOutputs( ) { - this->m_OutputsDisconnected = true; for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx ) - if( this->m_Outputs[ idx ] != NULL ) - this->m_Outputs[ idx ]->GetDataObject( )->DisconnectPipeline( ); + if( this->m_Outputs[ idx ].IsNotNull( ) ) + this->m_Outputs[ idx ]->DisconnectPipeline( ); +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::ProcessObject:: +ProcessObject( ) + : Superclass( ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::ProcessObject:: +~ProcessObject( ) +{ } // ------------------------------------------------------------------------- @@ -121,7 +134,7 @@ itk::DataObject* cpPlugins::Interface::ProcessObject:: _GetInput( unsigned int idx ) { if( idx < this->m_Inputs.size( ) ) - return( this->m_Inputs[ idx ]->GetDataObject( ) ); + return( this->m_Inputs[ idx ]->GetRealDataObject( ) ); else return( NULL ); } @@ -131,18 +144,8 @@ void cpPlugins::Interface::ProcessObject:: _SetOutput( unsigned int idx, itk::DataObject* dobj ) { if( idx < this->m_Outputs.size( ) ) - if( this->m_Outputs[ idx ] != NULL ) - this->m_Outputs[ idx ]->SetDataObject( dobj ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::ProcessObject:: -_DeleteOutputs( ) -{ - if( !( this->m_OutputsDisconnected ) ) - for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx ) - if( this->m_Outputs[ idx ] != NULL ) - delete this->m_Outputs[ idx ]; + if( this->m_Outputs[ idx ].IsNotNull( ) ) + this->m_Outputs[ idx ]->SetRealDataObject( dobj ); } // eof - $RCSfile$