]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/ProcessObject.hxx
...
[cpPlugins.git] / lib / cpPlugins / Interface / ProcessObject.hxx
1 #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
2 #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
3
4 // -------------------------------------------------------------------------
5 /* TODO
6 template< class T >
7 T* cpPlugins::Interface::ProcessObject::
8 GetInputData( const std::string& id )
9 {
10   auto i = this->m_Inputs.find( id );
11   if( i != this->m_Inputs.end( ) )
12     return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
13   else
14     return( NULL );
15 }
16
17 // -------------------------------------------------------------------------
18 template< class T >
19 const T* cpPlugins::Interface::ProcessObject::
20 GetInputData( const std::string& id ) const
21 {
22   auto i = this->m_Inputs.find( id );
23   if( i != this->m_Inputs.end( ) )
24     return( dynamic_cast< const T* >( i->second.GetPointer( ) ) );
25   else
26     return( NULL );
27 }
28
29 // -------------------------------------------------------------------------
30 template< class T >
31 T* cpPlugins::Interface::ProcessObject::
32 GetOutputData( const std::string& id )
33 {
34   auto i = this->m_Outputs.find( id );
35   if( i != this->m_Outputs.end( ) )
36     return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
37   else
38     return( NULL );
39 }
40
41 // -------------------------------------------------------------------------
42 template< class T >
43 const T* cpPlugins::Interface::ProcessObject::
44 GetOutputData( const std::string& id ) const
45 {
46   auto i = this->m_Outputs.find( id );
47   if( i != this->m_Outputs.end( ) )
48     return( dynamic_cast< const T* >( i->second.GetPointer( ) ) );
49   else
50     return( NULL );
51 }
52 */
53
54 // -------------------------------------------------------------------------
55 template< class O >
56 void cpPlugins::Interface::ProcessObject::
57 _AddOutput( const std::string& name )
58 {
59   auto i = this->m_Outputs.find( name );
60   if( i == this->m_Outputs.end( ) )
61   {
62     typename O::Pointer o = O::New( );
63     o->SetSource( this );
64     this->m_Outputs[ name ] = o;
65     this->Modified( );
66
67   } // fi
68 }
69
70 // -------------------------------------------------------------------------
71 template< class F >
72 F* cpPlugins::Interface::ProcessObject::
73 _CreateITK( )
74 {
75   F* filter = this->GetITK< F >( );
76   if( filter == NULL )
77   {
78     typename F::Pointer filter_ptr = F::New( );
79     this->m_ITKObject = filter_ptr;
80     this->m_VTKObject = NULL;
81     filter = filter_ptr.GetPointer( );
82     this->Modified( );
83
84   } // fi
85   return( filter );
86 }
87
88 // -------------------------------------------------------------------------
89 template< class F >
90 F* cpPlugins::Interface::ProcessObject::
91 _CreateVTK( )
92 {
93   F* filter = this->GetVTK< F >( );
94   if( filter == NULL )
95   {
96     vtkSmartPointer< F > filter_ptr = vtkSmartPointer< F >::New( );
97     this->m_ITKObject = NULL;
98     this->m_VTKObject = filter_ptr;
99     filter = filter_ptr.GetPointer( );
100     this->Modified( );
101
102   } // fi
103   return( filter );
104 }
105
106 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
107
108 // eof - $RCSfile$