]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Interface/ProcessObject.h
MAC compilation issues solved... Now some tests please
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.h
index a5404a890e91962279d07dbd61be11108815e6e2..e139c994d5e86f9107963ae6acea31fcd626d564 100644 (file)
@@ -2,18 +2,27 @@
 #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
 
 #include <map>
-#include <string>
+#include <set>
+
 #include <itkDataObject.h>
-#include <itkProcessObject.h>
-#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
-#include <cpPlugins/Interface/Object.h>
-#include <cpPlugins/Interface/DataObject.h>
+#include <cpPlugins/Interface/ProcessObjectPort.h>
+#include <cpPlugins/Interface/Parameters.h>
+
+// Some forward declarations
+class vtkRenderWindowInteractor;
 
 namespace cpPlugins
 {
   namespace Interface
   {
-    class DataObject;
+    // Some forward declarations
+#ifdef cpPlugins_Interface_QT4
+    class ParametersQtDialog;
+    class SimpleMPRWidget;
+#else
+    typedef char ParametersQtDialog;
+    typedef char SimpleMPRWidget;
+#endif // cpPlugins_Interface_QT4
 
     /**
      */
@@ -21,66 +30,103 @@ namespace cpPlugins
       : public Object
     {
     public:
-      typedef ProcessObject Self;
-      typedef Object        Superclass;
+      typedef ProcessObject                   Self;
+      typedef Object                          Superclass;
+      typedef itk::SmartPointer< Self >       Pointer;
+      typedef itk::SmartPointer< const Self > ConstPointer;
 
-      typedef std::pair< std::string, std::string > TParameter;
-      typedef std::map< std::string, TParameter >   TParameters;
+      typedef Parameters TParameters;
+      typedef std::set< vtkRenderWindowInteractor* > TInteractors;
+      typedef bool DialogResult;
 
     public:
-      ProcessObject( );
-      virtual ~ProcessObject( );
-
-      virtual std::string GetClassName( ) const;
-      virtual const TParameters& GetDefaultParameters( ) const;
-      virtual void SetParameters( const TParameters& params );
+      itkTypeMacro( ProcessObject, Object );
+      cpPlugins_Id_Macro( ProcessObject, BaseObject );
 
-      virtual unsigned int GetNumberOfInputs( ) const;
-      virtual unsigned int GetNumberOfOutputs( ) const;
+      itkGetConstObjectMacro( Parameters, TParameters );
 
-      virtual void SetNumberOfInputs( unsigned int n );
-      virtual void SetNumberOfOutputs( unsigned int n );
+      itkGetObjectMacro( Parameters, TParameters );
+      itkGetMacro( ParametersDialog, ParametersQtDialog* );
+      itkGetMacro( SingleInteractor, vtkRenderWindowInteractor* );
+      itkGetMacro( MPRViewer, SimpleMPRWidget* );
 
-      virtual void SetInput( unsigned int idx, const DataObject* dobj );
-      virtual DataObject* GetOutput( unsigned int idx );
+      itkSetObjectMacro( ParametersDialog, ParametersQtDialog );
+      itkSetObjectMacro( SingleInteractor, vtkRenderWindowInteractor );
+      itkSetObjectMacro( MPRViewer, SimpleMPRWidget );
 
+    public:
+      virtual void SetITK( itk::LightObject* o );
+      virtual void SetVTK( vtkObjectBase* o );
+
+      // IO management
+      std::set< std::string > GetInputsNames( ) const;
+      std::set< std::string > GetOutputsNames( ) const;
+      unsigned int GetNumberOfInputs( ) const;
+      unsigned int GetNumberOfOutputs( ) const;
+
+      OutputProcessObjectPort& GetOutput( const std::string& id );
+      const OutputProcessObjectPort& GetOutput( const std::string& id ) const;
+
+      template< class T >
+        inline T* GetInputData( const std::string& id );
+      template< class T >
+        inline const T* GetInputData( const std::string& id ) const;
+      template< class T >
+        inline T* GetOutputData( const std::string& id );
+      template< class T >
+        inline const T* GetOutputData( const std::string& id ) const;
+
+      bool SetInput(
+        const std::string& id, const OutputProcessObjectPort& port
+        );
+
+      void DisconnectInputs( );
+      void DisconnectOutputs( );
+      void Disconnect( );
+
+      // Pipeline execution
+      virtual itk::ModifiedTimeType GetMTime( ) const;
       virtual std::string Update( );
-      virtual void DisconnectOutputs( );
 
     protected:
-      virtual itk::DataObject* _GetInput( unsigned int idx );
-      virtual void _SetOutput( unsigned int idx, itk::DataObject* dobj );
-      virtual void _DeleteOutputs( );
+      ProcessObject( );
+      virtual ~ProcessObject( );
 
+      void _AddInput( const std::string& name, bool required = true );
       template< class O >
-      void _MakeOutput( unsigned int idx )
-        {
-          if( idx >= this->m_Outputs.size( ) )
-            return;
-        
-          if( !( this->m_OutputsDisconnected ) )
-            if( this->m_Outputs[ idx ] != NULL )
-              delete this->m_Outputs[ idx ];
-
-          this->m_Outputs[ idx ] = new O( );
-          this->m_Outputs[ idx ]->SetSource( this );
-        }
+        inline void _AddOutput( const std::string& name );
+      template< class F >
+        inline F* _CreateITK( );
+      template< class F >
+        inline F* _CreateVTK( );
 
       virtual std::string _GenerateData( ) = 0;
 
+    private:
+      // Purposely not implemented
+      ProcessObject( const Self& );
+      Self& operator=( const Self& );
+
     protected:
-      TParameters m_DefaultParameters;
-      TParameters m_Parameters;
+      typedef std::map< std::string, InputProcessObjectPort >  _TInputs;
+      typedef std::map< std::string, OutputProcessObjectPort > _TOutputs;
+      _TInputs  m_Inputs;
+      _TOutputs m_Outputs;
+      Parameters::Pointer m_Parameters;
 
-      std::vector< const DataObject* > m_Inputs;
-      std::vector< DataObject* >       m_Outputs;
-      bool m_OutputsDisconnected;
+      itk::ModifiedTimeType m_LastExecutionTime;
+
+      ParametersQtDialog*        m_ParametersDialog;
+      vtkRenderWindowInteractor* m_SingleInteractor;
+      SimpleMPRWidget*           m_MPRViewer;
     };
 
   } // ecapseman
 
 } // ecapseman
 
+#include <cpPlugins/Interface/ProcessObject.hxx>
+
 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
 
 // eof - $RCSfile$