]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/ProcessObject.hxx
XML IO added. Workspace singleton added to simplify pipeline definition and execution.
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.hxx
index a4a417bde2fbe6f289fdf62e55491c4a1df0642e..10b4dbe99fcc7a66fb02a42d978523e57b3e5c61 100644 (file)
@@ -2,23 +2,45 @@
 #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
 
 // -------------------------------------------------------------------------
-template< class O >
-void cpPlugins::Interface::ProcessObject::
-_MakeOutput( unsigned int idx )
+template< class T >
+T* cpPlugins::Interface::ProcessObject::
+GetITK( )
+{
+  return( dynamic_cast< T* >( this->m_ITKObject.GetPointer( ) ) );
+}
+
+// -------------------------------------------------------------------------
+template< class T >
+const T* cpPlugins::Interface::ProcessObject::
+GetITK( ) const
+{
+  return( dynamic_cast< const T* >( this->m_ITKObject.GetPointer( ) ) );
+}
+
+// -------------------------------------------------------------------------
+template< class T >
+T* cpPlugins::Interface::ProcessObject::
+GetVTK( )
+{
+  return( dynamic_cast< T* >( this->m_VTKObject.GetPointer( ) ) );
+}
+
+// -------------------------------------------------------------------------
+template< class T >
+const T* cpPlugins::Interface::ProcessObject::
+GetVTK( ) const
 {
-  if( idx >= this->m_Outputs.size( ) )
-    return;
-  this->m_Outputs[ idx ] = O::New( );
-  this->m_Outputs[ idx ]->SetSource( this );
+  return( dynamic_cast< const T* >( this->m_VTKObject.GetPointer( ) ) );
 }
 
 // -------------------------------------------------------------------------
 template< class T >
 T* cpPlugins::Interface::ProcessObject::
-_Input( unsigned int idx )
+GetInput( const std::string& id )
 {
-  if( idx < this->m_Inputs.size( ) )
-    return( dynamic_cast< T* >( this->m_Inputs[ idx ].GetPointer( ) ) );
+  _TDataContainer::iterator i = this->m_Inputs.find( id );
+  if( i != this->m_Inputs.end( ) )
+    return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
   else
     return( NULL );
 }
@@ -26,12 +48,11 @@ _Input( unsigned int idx )
 // -------------------------------------------------------------------------
 template< class T >
 const T* cpPlugins::Interface::ProcessObject::
-_Input( unsigned int idx ) const
+GetInput( const std::string& id ) const
 {
-  if( idx < this->m_Inputs.size( ) )
-    return(
-      dynamic_cast< const T* >( this->m_Inputs[ idx ].GetPointer( ) )
-      );
+  _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 );
 }
@@ -39,10 +60,11 @@ _Input( unsigned int idx ) const
 // -------------------------------------------------------------------------
 template< class T >
 T* cpPlugins::Interface::ProcessObject::
-_Output( unsigned int idx )
+GetOutput( const std::string& id )
 {
-  if( idx < this->m_Outputs.size( ) )
-    return( dynamic_cast< T* >( this->m_Outputs[ idx ].GetPointer( ) ) );
+  _TDataContainer::iterator i = this->m_Outputs.find( id );
+  if( i != this->m_Outputs.end( ) )
+    return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
   else
     return( NULL );
 }
@@ -50,16 +72,58 @@ _Output( unsigned int idx )
 // -------------------------------------------------------------------------
 template< class T >
 const T* cpPlugins::Interface::ProcessObject::
-_Output( unsigned int idx ) const
+GetOutput( const std::string& id ) const
 {
-  if( idx < this->m_Outputs.size( ) )
-    return(
-      dynamic_cast< const T* >( this->m_Outputs[ idx ].GetPointer( ) )
-      );
+  _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 F >
+F* cpPlugins::Interface::ProcessObject::
+_CreateITK( )
+{
+  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 );
+}
+
+// -------------------------------------------------------------------------
+template< class O >
+void cpPlugins::Interface::ProcessObject::
+_MakeOutput( const std::string& id )
+{
+  this->m_Outputs[ id ] = O::New( );
+  this->m_Outputs[ id ]->SetSource( this );
+  this->Modified( );
+}
+
 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
 
 // eof - $RCSfile$