]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.cxx
Basic IO architecture within itk-based pipelines
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.cxx
1 #include <cpPlugins/Interface/ProcessObject.h>
2 #include <cpPlugins/Interface/DataObject.h>
3
4 // -------------------------------------------------------------------------
5 cpPlugins::Interface::ProcessObject::
6 ProcessObject( )
7   : Superclass( )
8 {
9 }
10
11 // -------------------------------------------------------------------------
12 cpPlugins::Interface::ProcessObject::
13 ~ProcessObject( )
14 {
15 }
16
17 // -------------------------------------------------------------------------
18 std::string cpPlugins::Interface::ProcessObject::
19 GetClassName( ) const
20 {
21   return( "cpPlugins::Interface::ProcessObject" );
22 }
23
24 // -------------------------------------------------------------------------
25 const cpPlugins::Interface::ProcessObject::
26 TParameters& cpPlugins::Interface::ProcessObject::
27 GetDefaultParameters( ) const
28 {
29   return( this->m_DefaultParameters );
30 }
31
32 // -------------------------------------------------------------------------
33 void cpPlugins::Interface::ProcessObject::
34 SetParameters( const TParameters& params )
35 {
36   this->m_Parameters = params;
37 }
38
39 // -------------------------------------------------------------------------
40 unsigned int cpPlugins::Interface::ProcessObject::
41 GetNumberOfInputs( ) const
42 {
43   return( this->m_Inputs.size( ) );
44 }
45
46 // -------------------------------------------------------------------------
47 unsigned int cpPlugins::Interface::ProcessObject::
48 GetNumberOfOutputs( ) const
49 {
50   return( this->m_Outputs.size( ) );
51 }
52
53 // -------------------------------------------------------------------------
54 void cpPlugins::Interface::ProcessObject::
55 SetNumberOfInputs( unsigned int n )
56 {
57   this->m_Inputs.clear( );
58   this->m_Inputs.resize( n, NULL );
59 }
60
61 // -------------------------------------------------------------------------
62 void cpPlugins::Interface::ProcessObject::
63 SetNumberOfOutputs( unsigned int n )
64 {
65   this->m_Outputs.clear( );
66   this->m_Outputs.resize( n );
67
68   // Sync outputs with this source
69   for( unsigned int odx = 0; odx < this->m_Outputs.size( ); ++odx )
70     this->m_Outputs[ odx ].SetSource( this );
71 }
72
73 // -------------------------------------------------------------------------
74 void cpPlugins::Interface::ProcessObject::
75 SetInput(
76   unsigned int idx, const cpPlugins::Interface::DataObject* dobj
77   )
78 {
79   if( idx < this->m_Inputs.size( ) )
80     this->m_Inputs[ idx ] = dobj;
81 }
82
83 // -------------------------------------------------------------------------
84 cpPlugins::Interface::DataObject* cpPlugins::Interface::ProcessObject::
85 GetOutput( unsigned int idx )
86 {
87   if( idx < this->m_Outputs.size( ) )
88     return( &( this->m_Outputs[ idx ] ) );
89   else
90     return( NULL );
91 }
92
93 // -------------------------------------------------------------------------
94 std::string cpPlugins::Interface::ProcessObject::
95 Update( )
96 {
97   // Force upstream updates
98   for( unsigned int idx = 0; idx < this->m_Inputs.size( ); ++idx )
99     this->m_Inputs[ idx ]->GetSource( )->Update( );
100
101   // Current update
102   std::string ret = this->_GenerateData( );
103
104   // Return error description, if any
105   return( ret );
106 }
107
108 // -------------------------------------------------------------------------
109 itk::DataObject* cpPlugins::Interface::ProcessObject::
110 _GetInput( unsigned int idx )
111 {
112   if( idx < this->m_Inputs.size( ) )
113     return( this->m_Inputs[ idx ]->GetDataObject( ) );
114   else
115     return( NULL );
116 }
117
118 // -------------------------------------------------------------------------
119 void cpPlugins::Interface::ProcessObject::
120 _SetOutput( unsigned int idx, itk::DataObject* dobj )
121 {
122   if( idx < this->m_Outputs.size( ) )
123     this->m_Outputs[ idx ].SetDataObject( dobj );
124 }
125
126 // eof - $RCSfile$