1 #ifndef __cpPlugins__BaseObjects__ProcessObject__h__
2 #define __cpPlugins__BaseObjects__ProcessObject__h__
4 #include <cpPlugins/BaseObjects/Object.h>
5 #include <cpPlugins/BaseObjects/Parameters.h>
6 #include <cpPlugins/BaseObjects/Port.h>
9 // -------------------------------------------------------------------------
11 class vtkRenderWindowInteractor;
13 // -------------------------------------------------------------------------
20 class cpPlugins_EXPORT ProcessObject
24 typedef ProcessObject Self;
25 typedef Object Superclass;
26 typedef itk::SmartPointer< Self > Pointer;
27 typedef itk::SmartPointer< const Self > ConstPointer;
30 itkTypeMacro( ProcessObject, Object );
31 cpPlugins_Id_Macro( ProcessObject, Object );
33 itkBooleanMacro( ExplicitExecution );
34 itkBooleanMacro( PrintExecution );
36 itkGetStringMacro( Name );
37 itkGetStringMacro( PluginName );
38 itkGetConstMacro( ExplicitExecution, bool );
39 itkGetConstMacro( LastExecutionSpan, long );
40 itkGetConstMacro( PrintExecution, bool );
42 itkSetStringMacro( Name );
43 itkSetStringMacro( PluginName );
44 itkSetMacro( ExplicitExecution, bool );
45 itkSetMacro( PrintExecution, bool );
46 itkSetObjectMacro( PrintExecutionStream, std::ofstream );
49 Parameters* GetParameters( );
50 const Parameters* GetParameters( ) const;
52 virtual void SetITK( itk::LightObject* o ) final;
53 virtual void SetVTK( vtkObjectBase* o ) final;
56 std::set< std::string > GetInputsNames( ) const;
57 std::set< std::string > GetOutputsNames( ) const;
59 unsigned int GetNumberOfInputs( ) const;
60 unsigned int GetNumberOfOutputs( ) const;
61 unsigned int GetInputSize( const std::string& n ) const;
62 bool IsInputMultiple( const std::string& n ) const;
64 template< class _TType = DataObject >
65 _TType* GetInput( const std::string& n, unsigned int i = 0 );
67 template< class _TType = DataObject >
68 const _TType* GetInput(
69 const std::string& n, unsigned int i = 0
72 template< class _TType = itk::LightObject >
73 _TType* GetInputData( const std::string& n, unsigned int i = 0 );
75 template< class _TType = itk::LightObject >
76 const _TType* GetInputData(
77 const std::string& n, unsigned int i = 0
80 template< class _TType = DataObject >
81 _TType* GetOutput( const std::string& n );
83 template< class _TType = DataObject >
84 const _TType* GetOutput( const std::string& n ) const;
86 template< class _TType = itk::LightObject >
87 _TType* GetOutputData( const std::string& n );
89 template< class _TType = itk::LightObject >
90 const _TType* GetOutputData( const std::string& n ) const;
93 virtual void AddInput( const std::string& n, DataObject* o );
94 virtual void SetInput( const std::string& n, DataObject* o );
96 // Other interesting methods
97 void DisconnectInputs( );
98 void DisconnectOutputs( );
101 // Pipeline execution
102 virtual void Modified( ) const cpPlugins_OVERRIDE;
103 virtual itk::ModifiedTimeType GetMTime( ) const cpPlugins_OVERRIDE;
104 virtual void Update( );
106 // Qt dialog creation
107 virtual QDialog* CreateQDialog( );
108 virtual void AddInteractor( vtkRenderWindowInteractor* i );
109 virtual bool IsInteractive( );
113 virtual ~ProcessObject( );
115 // Error handling method
116 void _Error( const std::string& error );
118 // For configuration purposes
119 template< class _TType = DataObject >
120 void _ConfigureInput(
121 const std::string& name, bool required, bool multiple
124 template< class _TType = DataObject >
125 void _ConfigureOutput( const std::string& name );
127 template< class _TFilter >
128 _TFilter* _CreateITK( );
130 template< class _TFilter >
131 _TFilter* _CreateVTK( );
133 virtual void _GenerateData( ) = 0;
136 // Purposely not implemented
137 ProcessObject( const Self& );
138 Self& operator=( const Self& );
141 Parameters m_Parameters;
143 std::string m_PluginName;
144 bool m_ExplicitExecution;
146 std::map< std::string, Port* > m_Inputs;
147 std::map< std::string, Port* > m_Outputs;
149 itk::ModifiedTimeType m_LastExecutionTime;
150 mutable long m_LastExecutionSpan;
152 bool m_PrintExecution;
153 std::ostream* m_PrintExecutionStream;
155 typedef vtkSmartPointer< vtkRenderWindowInteractor > _TInteractor;
156 struct _TInteractorCmp
159 const _TInteractor& a, const _TInteractor& b
161 { return( a.GetPointer( ) < b.GetPointer( ) ); }
163 std::set< _TInteractor, _TInteractorCmp > m_Interactors;
170 #include <cpPlugins/BaseObjects/ProcessObject.hxx>
172 #endif // __cpPlugins__BaseObjects__ProcessObject__h__