From a0e33d8a43c431e3df4c9aba45839a324b3ac0bc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Thu, 1 Dec 2016 09:31:05 -0500 Subject: [PATCH] debug finished --- appli/bash/CreateInstances.cxx | 2 +- appli/bash/CreatePlugins.cxx | 2 +- lib/cpBaseQtApplication/Pipeline/Block.h | 2 +- lib/cpInstances/BoundingBox.h | 2 +- lib/cpInstances/Image.cxx | 7 ----- lib/cpInstances/Image.h | 2 +- lib/cpInstances/Mesh.h | 2 +- lib/cpInstances/PolyLineParametricPath.h | 2 +- lib/cpInstances/Simple3DCurve.h | 2 +- lib/cpInstances/Skeleton.h | 2 +- lib/cpPlugins/BaseObjects/DataObject.h | 2 +- lib/cpPlugins/BaseObjects/ProcessObject.cxx | 1 - lib/cpPlugins/Config.h.in | 23 +++++++++++++++- lib/cpPlugins/Interface/Plugins.cxx | 27 ------------------- lib/cpPlugins/Interface/Workspace.cxx | 29 --------------------- lib/cpPlugins/Interface/Workspace.h | 6 +---- 16 files changed, 33 insertions(+), 80 deletions(-) diff --git a/appli/bash/CreateInstances.cxx b/appli/bash/CreateInstances.cxx index b68c087..cf73c63 100644 --- a/appli/bash/CreateInstances.cxx +++ b/appli/bash/CreateInstances.cxx @@ -22,7 +22,7 @@ int main( int argc, char* argv[] ) std::string definitions_buffer; if( !( cpPlugins_bash::Read( definitions_buffer, definitions_filename ) ) ) { - std::cout + std::cerr << argv[ 0 ] << ": Error reading definitions file \"" << definitions_filename << "\"" << std::endl; diff --git a/appli/bash/CreatePlugins.cxx b/appli/bash/CreatePlugins.cxx index 2184347..918f6f2 100644 --- a/appli/bash/CreatePlugins.cxx +++ b/appli/bash/CreatePlugins.cxx @@ -23,7 +23,7 @@ int main( int argc, char* argv[] ) std::string definitions_buffer; if( !( cpPlugins_bash::Read( definitions_buffer, definitions_filename ) ) ) { - std::cout + std::cerr << argv[ 0 ] << ": Error reading definitions file \"" << definitions_filename << "\"" << std::endl; diff --git a/lib/cpBaseQtApplication/Pipeline/Block.h b/lib/cpBaseQtApplication/Pipeline/Block.h index 73b31f8..14e59b3 100644 --- a/lib/cpBaseQtApplication/Pipeline/Block.h +++ b/lib/cpBaseQtApplication/Pipeline/Block.h @@ -35,7 +35,7 @@ namespace cpBaseQtApplication public: typedef itk::SmartPointer< _TFilterObserver > Pointer; typedef itk::SmartPointer< const _TFilterObserver > ConstPointer; - itkNewMacro( _TFilterObserver ); + cpPluginsNewMacro( _TFilterObserver ); public: void Execute( itk::Object* c, const itk::EventObject& e ) { this->Execute( const_cast< const itk::Object* >( c ), e ); } diff --git a/lib/cpInstances/BoundingBox.h b/lib/cpInstances/BoundingBox.h index c210b0a..8bb529c 100644 --- a/lib/cpInstances/BoundingBox.h +++ b/lib/cpInstances/BoundingBox.h @@ -21,7 +21,7 @@ namespace cpInstances typedef itk::SmartPointer< const Self > ConstPointer; public: - itkNewMacro( Self ); + cpPluginsNewMacro( Self ); itkTypeMacro( BoundingBox, DataObject ); cpPlugins_Id_Macro( BoundingBox, Object ); cpPlugins_Compatibility_Macro; diff --git a/lib/cpInstances/Image.cxx b/lib/cpInstances/Image.cxx index 6cdae03..b34abea 100644 --- a/lib/cpInstances/Image.cxx +++ b/lib/cpInstances/Image.cxx @@ -147,13 +147,6 @@ _ITK_2_VTK_1( _TImage* image ) const f = nf.GetPointer( ); } // fi - - std::string name = ""; - if( this->m_Source != NULL ) - name = this->m_Source->GetName( ); - - std::cout << "HOLALALAL: " << name << " " << image << " " << f->GetInput( ) << std::endl; - f->SetInput( image ); f->Update( ); diff --git a/lib/cpInstances/Image.h b/lib/cpInstances/Image.h index bcffabe..2ca3df4 100644 --- a/lib/cpInstances/Image.h +++ b/lib/cpInstances/Image.h @@ -22,7 +22,7 @@ namespace cpInstances typedef itk::SmartPointer< const Self > ConstPointer; public: - itkNewMacro( Self ); + cpPluginsNewMacro( Self ); itkTypeMacro( Image, cpPlugins::BaseObjects::DataObject ); cpPlugins_Id_Macro( Image, Object ); cpPlugins_Compatibility_Macro; diff --git a/lib/cpInstances/Mesh.h b/lib/cpInstances/Mesh.h index e40579b..f516f78 100644 --- a/lib/cpInstances/Mesh.h +++ b/lib/cpInstances/Mesh.h @@ -19,7 +19,7 @@ namespace cpInstances typedef itk::SmartPointer< const Self > ConstPointer; public: - itkNewMacro( Self ); + cpPluginsNewMacro( Self ); itkTypeMacro( Mesh, DataObject ); cpPlugins_Id_Macro( Mesh, Object ); cpPlugins_Compatibility_Macro; diff --git a/lib/cpInstances/PolyLineParametricPath.h b/lib/cpInstances/PolyLineParametricPath.h index c510d4c..4d1fed0 100644 --- a/lib/cpInstances/PolyLineParametricPath.h +++ b/lib/cpInstances/PolyLineParametricPath.h @@ -22,7 +22,7 @@ namespace cpInstances typedef itk::SmartPointer< const Self > ConstPointer; public: - itkNewMacro( Self ); + cpPluginsNewMacro( Self ); itkTypeMacro( PolyLineParametricPath, cpPlugins::BaseObjects::DataObject ); cpPlugins_Id_Macro( PolyLineParametricPath, Object ); cpPlugins_Compatibility_Macro; diff --git a/lib/cpInstances/Simple3DCurve.h b/lib/cpInstances/Simple3DCurve.h index cd2bad2..5056ae8 100644 --- a/lib/cpInstances/Simple3DCurve.h +++ b/lib/cpInstances/Simple3DCurve.h @@ -25,7 +25,7 @@ namespace cpInstances typedef itk::SmartPointer< const Self > ConstPointer; public: - itkNewMacro( Self ); + cpPluginsNewMacro( Self ); itkTypeMacro( Simple3DCurve, cpPlugins::BaseObjects::DataObject ); cpPlugins_Id_Macro( Simple3DCurve, Object ); cpPlugins_Compatibility_Macro; diff --git a/lib/cpInstances/Skeleton.h b/lib/cpInstances/Skeleton.h index faae876..b86aed0 100644 --- a/lib/cpInstances/Skeleton.h +++ b/lib/cpInstances/Skeleton.h @@ -22,7 +22,7 @@ namespace cpInstances typedef itk::SmartPointer< const Self > ConstPointer; public: - itkNewMacro( Self ); + cpPluginsNewMacro( Self ); itkTypeMacro( Skeleton, cpPlugins::BaseObjects::DataObject ); cpPlugins_Id_Macro( Skeleton, Object ); cpPlugins_Compatibility_Macro; diff --git a/lib/cpPlugins/BaseObjects/DataObject.h b/lib/cpPlugins/BaseObjects/DataObject.h index daf9ff5..acb8213 100644 --- a/lib/cpPlugins/BaseObjects/DataObject.h +++ b/lib/cpPlugins/BaseObjects/DataObject.h @@ -24,7 +24,7 @@ namespace cpPlugins typedef itk::SmartPointer< const Self > ConstPointer; public: - itkNewMacro( Self ); + cpPluginsNewMacro( Self ); itkTypeMacro( DataObject, Object ); cpPlugins_Id_Macro( DataObject, Object ); diff --git a/lib/cpPlugins/BaseObjects/ProcessObject.cxx b/lib/cpPlugins/BaseObjects/ProcessObject.cxx index 0192ea6..35b95ff 100644 --- a/lib/cpPlugins/BaseObjects/ProcessObject.cxx +++ b/lib/cpPlugins/BaseObjects/ProcessObject.cxx @@ -206,7 +206,6 @@ Disconnect( ) void cpPlugins::BaseObjects::ProcessObject:: Modified( ) const { - std::cout << "Modified: " << this->m_Name << std::endl; this->Superclass::Modified( ); cpPlugins::BaseObjects::Events::Modified evt; diff --git a/lib/cpPlugins/Config.h.in b/lib/cpPlugins/Config.h.in index 1eb05a3..c58039c 100644 --- a/lib/cpPlugins/Config.h.in +++ b/lib/cpPlugins/Config.h.in @@ -95,6 +95,27 @@ * ========================================================================= */ +#define cpPluginsNewMacro( x ) \ + static Pointer New( ) \ + { \ + Pointer smartPtr = new x( ); \ + smartPtr->UnRegister( ); \ + return( smartPtr ); \ + } \ + virtual itk::LightObject::Pointer \ + CreateAnother( ) const cpPlugins_OVERRIDE \ + { \ + itk::LightObject::Pointer smartPtr; \ + smartPtr = x::New( ).GetPointer( ); \ + return( smartPtr ); \ + } \ + Pointer Clone( ) const \ + { \ + Pointer rval = \ + dynamic_cast< x* >( this->InternalClone( ).GetPointer( ) ); \ + return( rval ); \ + } + #define cpPlugins_Id_Macro( _class, _category ) \ public: \ virtual const char* GetClassName( ) const cpPlugins_OVERRIDE \ @@ -109,7 +130,7 @@ typedef itk::SmartPointer< Self > Pointer; \ typedef itk::SmartPointer< const Self > ConstPointer; \ public: \ - itkNewMacro( Self ); \ + cpPluginsNewMacro( Self ); \ itkTypeMacro( _cls, _scls ); \ public: \ virtual const char* GetClassName( ) const cpPlugins_OVERRIDE \ diff --git a/lib/cpPlugins/Interface/Plugins.cxx b/lib/cpPlugins/Interface/Plugins.cxx index 1543d31..9da2f70 100644 --- a/lib/cpPlugins/Interface/Plugins.cxx +++ b/lib/cpPlugins/Interface/Plugins.cxx @@ -123,76 +123,49 @@ cpPlugins::BaseObjects::ProcessObject::Pointer cpPlugins::Interface::Plugins:: CreateFilter( const std::string& category, const std::string& name ) { - std::cout << "1" << std::endl; typedef void* ( *_TCreator )( ); - std::cout << "2" << std::endl; typedef cpPlugins::BaseObjects::ProcessObject::Pointer _TPtr; - std::cout << "3" << std::endl; _TPtr o = NULL; - std::cout << "4" << std::endl; auto cat = this->m_Filters.find( category ); - std::cout << "5" << std::endl; if( cat != this->m_Filters.end( ) ) { - std::cout << "6" << std::endl; auto nam = cat->second.find( name ); - std::cout << "7" << std::endl; if( nam != cat->second.end( ) ) { - std::cout << "8" << std::endl; void* l_hnd = nam->second.second.first; - std::cout << "9" << std::endl; void* f_hnd = nam->second.second.second; - std::cout << "10" << std::endl; if( l_hnd == NULL ) { - std::cout << "11" << std::endl; l_hnd = cpPlugins::OS::DLLManager::LoadPlugins( nam->second.first ); - std::cout << "12" << std::endl; nam->second.second.first = l_hnd; - std::cout << "13" << std::endl; } // fi if( f_hnd == NULL ) { - std::cout << "14" << std::endl; f_hnd = cpPlugins::OS::DLLManager::LoadCreator( l_hnd, category, name ); - std::cout << "15" << std::endl; nam->second.second.second = f_hnd; - std::cout << "16" << std::endl; } // fi - std::cout << "17" << std::endl; _TCreator creator = reinterpret_cast< _TCreator >( f_hnd ); - std::cout << "18" << std::endl; if( creator != NULL ) { - std::cout << "19 " << creator << " " << f_hnd << std::endl; void* a = creator( ); - std::cout << "20" << std::endl; - std::cout << "20 " << creator << " " << a << std::endl; - std::cout << "21" << std::endl; o = reinterpret_cast< _TPtr* >( a )->GetPointer( ); - std::cout << "22" << std::endl; o->SetName( name ); - std::cout << "23" << std::endl; o->SetPluginName( nam->second.first ); - std::cout << "24" << std::endl; } // fi } // fi } // fi - std::cout << "25" << std::endl; if( o.IsNull( ) ) throw std::runtime_error( std::string( "Could not create a valid ProcessObject of type \"" ) + category + std::string( ":" ) + name + std::string( "\"" ) ); - std::cout << "26" << std::endl; return( o ); } diff --git a/lib/cpPlugins/Interface/Workspace.cxx b/lib/cpPlugins/Interface/Workspace.cxx index 8eca620..5b80a36 100644 --- a/lib/cpPlugins/Interface/Workspace.cxx +++ b/lib/cpPlugins/Interface/Workspace.cxx @@ -1,35 +1,6 @@ #include #include -// ------------------------------------------------------------------------- -cpPlugins::Interface::Workspace:: -Pointer cpPlugins::Interface::Workspace:: -New( ) -{ - Pointer smartPtr = new Self; - smartPtr->UnRegister( ); - return( smartPtr ); -} - -// ------------------------------------------------------------------------- -itk::LightObject::Pointer cpPlugins::Interface::Workspace:: -CreateAnother( ) const -{ - itk::LightObject::Pointer smartPtr; - smartPtr = Self::New( ).GetPointer( ); - return( smartPtr ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::Workspace:: -Pointer cpPlugins::Interface::Workspace:: -Clone( ) const -{ - Pointer rval = - dynamic_cast< Self* >( this->InternalClone( ).GetPointer( ) ); - return( rval ); -} - // ------------------------------------------------------------------------- void cpPlugins::Interface::Workspace:: Clear( ) diff --git a/lib/cpPlugins/Interface/Workspace.h b/lib/cpPlugins/Interface/Workspace.h index 7d76c05..2925a06 100644 --- a/lib/cpPlugins/Interface/Workspace.h +++ b/lib/cpPlugins/Interface/Workspace.h @@ -38,14 +38,10 @@ namespace cpPlugins */ public: + cpPluginsNewMacro( Self ); itkTypeMacro( Workspace, itk::Object ); public: - // Factory methods - static Pointer New( ); - virtual itk::LightObject::Pointer CreateAnother( ) const cpPlugins_OVERRIDE; - Pointer Clone( ) const; - // Workspace IO void Load( const std::string& fname ); void Save( const std::string& fname ) const; -- 2.45.0