]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.cxx
...
[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 std::string cpPlugins::Interface::ProcessObject::
65 Update( )
66 {
67   std::string r = "";
68
69   // Force upstream updates
70   for( unsigned int i = 0; i < this->m_Inputs.size( ) && r == ""; ++i )
71   {
72     Self* src = dynamic_cast< Self* >( this->m_Inputs[ i ]->GetSource( ) );
73     if( src != NULL )
74       r = src->Update( );
75
76   } // rof
77
78   // Current update
79   if( r == "" )
80     r = this->_GenerateData( );
81
82   // Return error description, if any
83   return( r );
84 }
85
86 // -------------------------------------------------------------------------
87 void cpPlugins::Interface::ProcessObject::
88 DisconnectOutputs( )
89 {
90   for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx )
91     if( this->m_Outputs[ idx ].IsNotNull( ) )
92       this->m_Outputs[ idx ]->DisconnectPipeline( );
93 }
94
95 // -------------------------------------------------------------------------
96 cpPlugins::Interface::ProcessObject::
97 ProcessObject( )
98   : Superclass( )
99 {
100   this->m_ClassName = "cpPlugins::Interface::ProcessObject";
101   this->m_ClassCategory = "BasicObject";
102 }
103
104 // -------------------------------------------------------------------------
105 cpPlugins::Interface::ProcessObject::
106 ~ProcessObject( )
107 {
108 }
109
110 // eof - $RCSfile$