]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/ProcessObject.hxx
MAC compilation issues solved... Now some tests please
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.hxx
index 7b4e080c5245aec6ab6aafc80c9d6ee43e4ab807..54c2f37bb8ede077d0f7238dbf760f5ac3382ec3 100644 (file)
@@ -1,24 +1,14 @@
 #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
 #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
 
-// -------------------------------------------------------------------------
-template< class O >
-void cpPlugins::Interface::ProcessObject::
-_MakeOutput( unsigned int idx )
-{
-  if( idx >= this->m_Outputs.size( ) )
-    return;
-  this->m_Outputs[ idx ] = O::New( );
-  this->m_Outputs[ idx ]->SetSource( this );
-}
-
 // -------------------------------------------------------------------------
 template< class T >
 T* cpPlugins::Interface::ProcessObject::
-_Input( unsigned int idx )
+GetInputData( const std::string& id )
 {
-  if( idx < this->m_Inputs.size( ) )
-    return( dynamic_cast< T* >( this->m_Inputs[ idx ].GetPointer( ) ) );
+  auto i = this->m_Inputs.find( id );
+  if( i != this->m_Inputs.end( ) )
+    return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
   else
     return( NULL );
 }
@@ -26,10 +16,11 @@ _Input( unsigned int idx )
 // -------------------------------------------------------------------------
 template< class T >
 const T* cpPlugins::Interface::ProcessObject::
-_Input( unsigned int idx ) const
+GetInputData( const std::string& id ) const
 {
-  if( idx < this->m_Inputs.size( ) )
-    return( dynamic_cast< const T* >( this->m_Inputs[ idx ].GetPointer( ) ) );
+  auto i = this->m_Inputs.find( id );
+  if( i != this->m_Inputs.end( ) )
+    return( dynamic_cast< const T* >( i->second.GetPointer( ) ) );
   else
     return( NULL );
 }
@@ -37,10 +28,11 @@ _Input( unsigned int idx ) const
 // -------------------------------------------------------------------------
 template< class T >
 T* cpPlugins::Interface::ProcessObject::
-_Output( unsigned int idx )
+GetOutputData( const std::string& id )
 {
-  if( idx < this->m_Outputs.size( ) )
-    return( dynamic_cast< T* >( this->m_Outputs[ idx ].GetPointer( ) ) );
+  auto i = this->m_Outputs.find( id );
+  if( i != this->m_Outputs.end( ) )
+    return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
   else
     return( NULL );
 }
@@ -48,14 +40,67 @@ _Output( unsigned int idx )
 // -------------------------------------------------------------------------
 template< class T >
 const T* cpPlugins::Interface::ProcessObject::
-_Output( unsigned int idx ) const
+GetOutputData( const std::string& id ) const
 {
-  if( idx < this->m_Outputs.size( ) )
-    return( dynamic_cast< const T* >( this->m_Outputs[ idx ].GetPointer( ) ) );
+  auto i = this->m_Outputs.find( id );
+  if( i != this->m_Outputs.end( ) )
+    return( dynamic_cast< const T* >( i->second.GetPointer( ) ) );
   else
     return( NULL );
 }
 
+// -------------------------------------------------------------------------
+template< class O >
+void cpPlugins::Interface::ProcessObject::
+_AddOutput( const std::string& name )
+{
+  auto i = this->m_Outputs.find( name );
+  if( i == this->m_Outputs.end( ) )
+  {
+    typename O::Pointer o = O::New( );
+    o->SetSource( this );
+    this->m_Outputs[ name ] = o;
+    this->Modified( );
+
+  } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class F >
+F* cpPlugins::Interface::ProcessObject::
+_CreateITK( )
+{
+  F* filter = this->GetITK< F >( );
+  if( filter == NULL )
+  {
+    typename F::Pointer filter_ptr = F::New( );
+    this->m_ITKObject = filter_ptr;
+    this->m_VTKObject = NULL;
+    filter = filter_ptr.GetPointer( );
+    this->Modified( );
+
+  } // fi
+  return( filter );
+}
+
+// -------------------------------------------------------------------------
+template< class F >
+F* cpPlugins::Interface::ProcessObject::
+_CreateVTK( )
+{
+  F* filter = this->GetVTK< F >( );
+  if( filter == NULL )
+  {
+    vtkSmartPointer< F > filter_ptr = vtkSmartPointer< F >::New( );
+    this->m_ITKObject = NULL;
+    this->m_VTKObject = filter_ptr;
+    filter = filter_ptr.GetPointer( );
+    this->Modified( );
+
+  } // fi
+  return( filter );
+}
+
 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
 
 // eof - $RCSfile$