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