]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.h
...
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.h
1 #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
2 #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
3
4 #include <map>
5 #include <set>
6
7 #include <itkDataObject.h>
8 #include <cpPlugins/Interface/ProcessObjectPort.h>
9 #include <cpPlugins/Interface/Parameters.h>
10
11 // Some forward declarations
12 class vtkRenderWindowInteractor;
13
14 namespace cpPlugins
15 {
16   namespace Interface
17   {
18     // Some forward declarations
19 #ifdef cpPlugins_Interface_QT4
20     class ParametersQtDialog;
21     class SimpleMPRWidget;
22 #else
23     typedef char ParametersQtDialog;
24     typedef char SimpleMPRWidget;
25 #endif // cpPlugins_Interface_QT4
26
27     /**
28      */
29     class cpPlugins_Interface_EXPORT ProcessObject
30       : public Object
31     {
32     public:
33       typedef ProcessObject                   Self;
34       typedef Object                          Superclass;
35       typedef itk::SmartPointer< Self >       Pointer;
36       typedef itk::SmartPointer< const Self > ConstPointer;
37
38       typedef Parameters TParameters;
39       typedef std::set< vtkRenderWindowInteractor* > TInteractors;
40       typedef bool DialogResult;
41
42     public:
43       itkTypeMacro( ProcessObject, Object );
44       cpPlugins_Id_Macro( ProcessObject, BaseObject );
45
46       itkGetConstObjectMacro( Parameters, TParameters );
47
48       itkGetObjectMacro( Parameters, TParameters );
49       itkGetMacro( ParametersDialog, ParametersQtDialog* );
50       itkGetMacro( SingleInteractor, vtkRenderWindowInteractor* );
51       itkGetMacro( MPRViewer, SimpleMPRWidget* );
52
53       itkSetObjectMacro( ParametersDialog, ParametersQtDialog );
54       itkSetObjectMacro( SingleInteractor, vtkRenderWindowInteractor );
55       itkSetObjectMacro( MPRViewer, SimpleMPRWidget );
56
57     public:
58       // IO management
59       std::set< std::string > GetInputsNames( ) const;
60       std::set< std::string > GetOutputsNames( ) const;
61       unsigned int GetNumberOfInputs( ) const;
62       unsigned int GetNumberOfOutputs( ) const;
63
64       OutputProcessObjectPort& GetOutput( const std::string& id );
65       const OutputProcessObjectPort& GetOutput( const std::string& id ) const;
66
67       template< class T >
68         inline T* GetInputData( const std::string& id );
69       template< class T >
70         inline const T* GetInputData( const std::string& id ) const;
71       template< class T >
72         inline T* GetOutputData( const std::string& id );
73       template< class T >
74         inline const T* GetOutputData( const std::string& id ) const;
75
76       bool SetInput(
77         const std::string& id, const OutputProcessObjectPort& port
78         );
79
80       void DisconnectInputs( );
81       void DisconnectOutputs( );
82       void Disconnect( );
83
84       // Pipeline execution
85       virtual itk::ModifiedTimeType GetMTime( ) const;
86       virtual std::string Update( );
87
88     protected:
89       ProcessObject( );
90       virtual ~ProcessObject( );
91
92       void _AddInput( const std::string& name, bool required );
93       template< class O >
94         inline void _AddOutput( const std::string& name );
95       template< class F >
96         inline F* _CreateITK( );
97       template< class F >
98         inline F* _CreateVTK( );
99
100       virtual std::string _GenerateData( ) = 0;
101
102     private:
103       // Purposely not implemented
104       ProcessObject( const Self& );
105       Self& operator=( const Self& );
106
107     protected:
108       typedef std::map< std::string, InputProcessObjectPort >  _TInputs;
109       typedef std::map< std::string, OutputProcessObjectPort > _TOutputs;
110       _TInputs  m_Inputs;
111       _TOutputs m_Outputs;
112       Parameters::Pointer m_Parameters;
113
114       itk::ModifiedTimeType m_LastExecutionTime;
115
116       ParametersQtDialog*        m_ParametersDialog;
117       vtkRenderWindowInteractor* m_SingleInteractor;
118       SimpleMPRWidget*           m_MPRViewer;
119     };
120
121   } // ecapseman
122
123 } // ecapseman
124
125 #include <cpPlugins/Interface/ProcessObject.hxx>
126
127 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
128
129 // eof - $RCSfile$