1 #ifndef __CPPLUGINS__PROCESSOBJECT__H__
2 #define __CPPLUGINS__PROCESSOBJECT__H__
6 #include <cpPlugins/Object.h>
7 #include <cpPlugins/Parameters.h>
8 #include <cpPlugins/Port.h>
14 class cpPlugins_EXPORT ProcessObject
18 typedef ProcessObject Self;
19 typedef Object Superclass;
20 typedef itk::SmartPointer< Self > Pointer;
21 typedef itk::SmartPointer< const Self > ConstPointer;
24 itkTypeMacro( ProcessObject, Object );
25 cpPlugins_Id_Macro( ProcessObject, Object );
27 itkBooleanMacro( ExplicitReExecution );
28 itkBooleanMacro( PrintExecution );
30 itkGetConstMacro( ExplicitReExecution, bool );
31 itkGetConstMacro( CouldHaveExplicitReExecution, bool );
32 itkGetConstMacro( LastExecutionSpan, long );
33 itkGetConstMacro( PrintExecution, bool );
35 itkSetMacro( ExplicitReExecution, bool );
36 itkSetMacro( PrintExecution, bool );
37 itkSetObjectMacro( PrintExecutionStream, std::ofstream );
40 Parameters* GetParameters( );
41 const Parameters* GetParameters( ) const;
43 virtual void SetITK( itk::LightObject* o ) final;
44 virtual void SetVTK( vtkObjectBase* o ) final;
47 std::set< std::string > GetInputsNames( ) const;
48 std::set< std::string > GetOutputsNames( ) const;
49 unsigned int GetNumberOfInputs( ) const;
50 unsigned int GetNumberOfOutputs( ) const;
52 OutputPort& GetOutputPort( const std::string& id );
53 const OutputPort& GetOutputPort( const std::string& id ) const;
55 template< class _TType = DataObject >
56 inline _TType* GetInput( const std::string& id );
58 template< class _TType = DataObject >
59 inline const _TType* GetInput( const std::string& id ) const;
61 template< class _TType = DataObject >
62 inline _TType* GetOutput( const std::string& id );
64 template< class _TType = DataObject >
65 inline const _TType* GetOutput( const std::string& id ) const;
67 template< class _TType >
68 inline _TType* GetInputData( const std::string& name );
70 template< class _TType >
71 inline _TType* GetOutputData( const std::string& name );
73 bool SetInputPort( const std::string& id, const OutputPort& port );
75 void DisconnectInputs( );
76 void DisconnectOutputs( );
80 virtual void Modified( ) const ITK_OVERRIDE;
81 virtual itk::ModifiedTimeType GetMTime( ) const ITK_OVERRIDE;
82 virtual void Update( );
85 virtual ParametersQtDialog* CreateQtDialog( );
86 virtual bool IsInteractive( );
87 virtual void SetInteractionObjects( const std::vector< void* >& objs );
91 virtual ~ProcessObject( );
93 void _AddInput( const std::string& name, bool required = true );
94 void _Error( const std::string& error );
97 inline void _AddOutput( const std::string& name );
100 inline F* _CreateITK( );
102 inline F* _CreateVTK( );
104 virtual void _GenerateData( ) = 0;
107 // Purposely not implemented
108 ProcessObject( const Self& );
109 Self& operator=( const Self& );
112 Parameters m_Parameters;
113 bool m_CouldHaveExplicitReExecution;
114 bool m_ExplicitReExecution;
116 typedef std::map< std::string, InputPort > _TInputs;
117 typedef std::map< std::string, OutputPort > _TOutputs;
121 itk::ModifiedTimeType m_LastExecutionTime;
122 mutable long m_LastExecutionSpan;
124 bool m_PrintExecution;
125 std::ostream* m_PrintExecutionStream;
130 #include <cpPlugins/ProcessObject.hxx>
132 #endif // __CPPLUGINS__PROCESSOBJECT__H__