]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/ProcessObject.h
First dump for version 0.1.0
[cpPlugins.git] / lib / cpPlugins / ProcessObject.h
1 #ifndef __CPPLUGINS__PROCESSOBJECT__H__
2 #define __CPPLUGINS__PROCESSOBJECT__H__
3
4 #include <map>
5 #include <set>
6 #include <cpPlugins/Object.h>
7 #include <cpPlugins/Parameters.h>
8 #include <cpPlugins/Port.h>
9
10 namespace cpPlugins
11 {
12   // Forward declaration
13   /* TODO
14      class ParametersQtDialog;
15   */
16
17   /**
18    */
19   class cpPlugins_EXPORT ProcessObject
20     : public Object
21   {
22   public:
23     typedef ProcessObject                   Self;
24     typedef Object                          Superclass;
25     typedef itk::SmartPointer< Self >       Pointer;
26     typedef itk::SmartPointer< const Self > ConstPointer;
27
28   public:
29     itkTypeMacro( ProcessObject, Object );
30     cpPlugins_Id_Macro( ProcessObject, Object );
31
32   public:
33     Parameters* GetParameters( );
34     const Parameters* GetParameters( ) const;
35
36     virtual void SetITK( itk::LightObject* o ) final;
37     virtual void SetVTK( vtkObjectBase* o ) final;
38
39     // IO management
40     std::set< std::string > GetInputsNames( ) const;
41     std::set< std::string > GetOutputsNames( ) const;
42     unsigned int GetNumberOfInputs( ) const;
43     unsigned int GetNumberOfOutputs( ) const;
44
45     OutputPort& GetOutput( const std::string& id );
46     const OutputPort& GetOutput( const std::string& id ) const;
47
48     DataObject* GetInputData( const std::string& id );
49     const DataObject* GetInputData( const std::string& id ) const;
50     DataObject* GetOutputData( const std::string& id );
51     const DataObject* GetOutputData( const std::string& id ) const;
52
53     bool SetInput( const std::string& id, const OutputPort& port );
54
55     void DisconnectInputs( );
56     void DisconnectOutputs( );
57     void Disconnect( );
58
59     // Pipeline execution
60     virtual itk::ModifiedTimeType GetMTime( ) const;
61     virtual std::string Update( );
62
63     // Qt dialog creation
64     virtual ParametersQtDialog* CreateQtDialog( );
65
66   protected:
67     ProcessObject( );
68     virtual ~ProcessObject( );
69
70     void _AddInput( const std::string& name, bool required = true );
71
72     template< class O >
73       inline void _AddOutput( const std::string& name );
74
75     template< class F >
76       inline F* _CreateITK( );
77     template< class F >
78       inline F* _CreateVTK( );
79
80     virtual std::string _GenerateData( ) = 0;
81
82   private:
83     // Purposely not implemented
84     ProcessObject( const Self& );
85     Self& operator=( const Self& );
86
87   protected:
88     Parameters m_Parameters;
89
90     typedef std::map< std::string, InputPort >  _TInputs;
91     typedef std::map< std::string, OutputPort > _TOutputs;
92     _TInputs  m_Inputs;
93     _TOutputs m_Outputs;
94
95     itk::ModifiedTimeType m_LastExecutionTime;
96   };
97
98 } // ecapseman
99
100 #include <cpPlugins/ProcessObject.hxx>
101
102 #endif // __CPPLUGINS__PROCESSOBJECT__H__
103
104 // eof - $RCSfile$