]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.h
Garbage collector added
[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 <string>
6 #include <itkProcessObject.h>
7 #include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
8 #include <cpPlugins/Interface/Object.h>
9 #include <cpPlugins/Interface/DataObject.h>
10
11 namespace cpPlugins
12 {
13   namespace Interface
14   {
15     /**
16      */
17     class cpPlugins_Interface_EXPORT ProcessObject
18       : public Object
19     {
20     public:
21       typedef ProcessObject                   Self;
22       typedef Object                          Superclass;
23       typedef itk::SmartPointer< Self >       Pointer;
24       typedef itk::SmartPointer< const Self > ConstPointer;
25
26       typedef std::pair< std::string, std::string > TParameter;
27       typedef std::map< std::string, TParameter >   TParameters;
28
29     public:
30       itkTypeMacro( ProcessObject, Object );
31
32     public:
33       virtual std::string GetClassName( ) const;
34       virtual std::string GetClassType( ) const;
35       virtual const TParameters& GetDefaultParameters( ) const;
36       virtual void SetParameters( const TParameters& params );
37
38       virtual unsigned int GetNumberOfInputs( ) const;
39       virtual unsigned int GetNumberOfOutputs( ) const;
40
41       virtual void SetNumberOfInputs( unsigned int n );
42       virtual void SetNumberOfOutputs( unsigned int n );
43
44       virtual void SetInput( unsigned int idx, DataObject* dobj );
45       virtual DataObject* GetOutput( unsigned int idx );
46
47       virtual std::string Update( );
48       virtual void DisconnectOutputs( );
49
50     protected:
51       ProcessObject( );
52       virtual ~ProcessObject( );
53
54       virtual itk::DataObject* _GetInput( unsigned int idx );
55       virtual void _SetOutput( unsigned int idx, itk::DataObject* dobj );
56
57       template< class O >
58       void _MakeOutput( unsigned int idx )
59         {
60           if( idx >= this->m_Outputs.size( ) )
61             return;
62           this->m_Outputs[ idx ] = O::New( );
63           this->m_Outputs[ idx ]->SetSource( this );
64         }
65
66       virtual std::string _GenerateData( ) = 0;
67
68     private:
69       // Purposely not implemented
70       ProcessObject( const Self& );
71       Self& operator=( const Self& );
72
73     protected:
74       itk::ProcessObject::Pointer m_RealProcessObject;
75       TParameters m_DefaultParameters;
76       TParameters m_Parameters;
77
78       std::vector< DataObject::Pointer > m_Inputs;
79       std::vector< DataObject::Pointer > m_Outputs;
80     };
81
82   } // ecapseman
83
84 } // ecapseman
85
86 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
87
88 // eof - $RCSfile$