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;
63 template< class _TType = DataObject >
64 _TType* GetInput( const std::string& n, unsigned int i = 0 );
66 template< class _TType = DataObject >
67 const _TType* GetInput(
68 const std::string& n, unsigned int i = 0
71 template< class _TType = itk::LightObject >
72 _TType* GetInputData( const std::string& n, unsigned int i = 0 );
74 template< class _TType = itk::LightObject >
75 const _TType* GetInputData(
76 const std::string& n, unsigned int i = 0
79 template< class _TType = DataObject >
80 _TType* GetOutput( const std::string& n );
82 template< class _TType = DataObject >
83 const _TType* GetOutput( const std::string& n ) const;
85 template< class _TType = itk::LightObject >
86 _TType* GetOutputData( const std::string& n );
88 template< class _TType = itk::LightObject >
89 const _TType* GetOutputData( const std::string& n ) const;
92 virtual void AddInput( const std::string& n, DataObject* o );
93 virtual void SetInput( const std::string& n, DataObject* o );
95 // Other interesting methods
96 void DisconnectInputs( );
97 void DisconnectOutputs( );
100 // Pipeline execution
101 virtual void Modified( ) const cpPlugins_OVERRIDE;
102 virtual itk::ModifiedTimeType GetMTime( ) const cpPlugins_OVERRIDE;
103 virtual void Update( );
105 // Qt dialog creation
106 virtual QDialog* CreateQDialog( );
107 virtual void AddInteractor( vtkRenderWindowInteractor* i );
108 virtual bool IsInteractive( );
112 virtual ~ProcessObject( );
114 // Error handling method
115 void _Error( const std::string& error );
117 // For configuration purposes
118 template< class _TType = DataObject >
119 void _ConfigureInput(
120 const std::string& name, bool required, bool multiple
123 template< class _TType = DataObject >
124 void _ConfigureOutput( const std::string& name );
126 template< class _TFilter >
127 _TFilter* _CreateITK( );
129 template< class _TFilter >
130 _TFilter* _CreateVTK( );
132 virtual void _GenerateData( ) = 0;
135 // Purposely not implemented
136 ProcessObject( const Self& );
137 Self& operator=( const Self& );
140 Parameters m_Parameters;
142 std::string m_PluginName;
143 bool m_ExplicitExecution;
145 std::map< std::string, Port* > m_Inputs;
146 std::map< std::string, Port* > m_Outputs;
148 itk::ModifiedTimeType m_LastExecutionTime;
149 mutable long m_LastExecutionSpan;
151 bool m_PrintExecution;
152 std::ostream* m_PrintExecutionStream;
154 typedef vtkSmartPointer< vtkRenderWindowInteractor > _TInteractor;
155 struct _TInteractorCmp
158 const _TInteractor& a, const _TInteractor& b
160 { return( a.GetPointer( ) < b.GetPointer( ) ); }
162 std::set< _TInteractor, _TInteractorCmp > m_Interactors;
169 #include <cpPlugins/BaseObjects/ProcessObject.hxx>
171 #endif // __cpPlugins__BaseObjects__ProcessObject__h__