]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/ProcessObject.hxx
...
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.hxx
index 6dcbb7de08ddfe6f7024b859096032ebe449e7bb..33b4a2022cb558bc9a943c4be8a8c4240038116d 100644 (file)
@@ -1,15 +1,95 @@
 #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
 #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
 
+// -------------------------------------------------------------------------
+template< class T >
+T* cpPlugins::Interface::ProcessObject::
+GetInput( const std::string& id )
+{
+  _TDataContainer::iterator i = this->m_Inputs.find( id );
+  if( i != this->m_Inputs.end( ) )
+    return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
+  else
+    return( NULL );
+}
+
+// -------------------------------------------------------------------------
+template< class T >
+const T* cpPlugins::Interface::ProcessObject::
+GetInput( const std::string& id ) const
+{
+  _TDataContainer::const_iterator i = this->m_Inputs.find( id );
+  if( i != this->m_Inputs.end( ) )
+    return( dynamic_cast< const T* >( i->second.GetPointer( ) ) );
+  else
+    return( NULL );
+}
+
+// -------------------------------------------------------------------------
+template< class T >
+T* cpPlugins::Interface::ProcessObject::
+GetOutput( const std::string& id )
+{
+  _TDataContainer::iterator i = this->m_Outputs.find( id );
+  if( i != this->m_Outputs.end( ) )
+    return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
+  else
+    return( NULL );
+}
+
+// -------------------------------------------------------------------------
+template< class T >
+const T* cpPlugins::Interface::ProcessObject::
+GetOutput( const std::string& id ) const
+{
+  _TDataContainer::const_iterator 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::
-_MakeOutput( unsigned int idx )
+_AddOutput( const std::string& id )
+{
+  this->m_Outputs[ id ] = O::New( );
+  this->m_Outputs[ id ]->SetSource( this );
+  this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+template< class F >
+F* cpPlugins::Interface::ProcessObject::
+_CreateITK( )
 {
-  if( idx >= this->m_Outputs.size( ) )
-    return;
-  this->m_Outputs[ idx ] = O::New( );
-  this->m_Outputs[ idx ]->SetSource( this );
+  F* filter = dynamic_cast< F* >( this->m_ITKObject.GetPointer( ) );
+  if( filter == NULL )
+  {
+    typename F::Pointer ptr = F::New( );
+    this->m_ITKObject = ptr;
+    filter = ptr.GetPointer( );
+    this->m_VTKObject = NULL;
+
+  } // fi
+  return( filter );
+}
+
+// -------------------------------------------------------------------------
+template< class F >
+F* cpPlugins::Interface::ProcessObject::
+_CreateVTK( )
+{
+  F* filter = dynamic_cast< F* >( this->m_VTKObject.GetPointer( ) );
+  if( filter == NULL )
+  {
+    filter = F::New( );
+    this->m_VTKObject = filter;
+    this->m_ITKObject = NULL;
+
+  } // fi
+  return( filter );
 }
 
 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__