]> 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 template< class T >
6 T* cpPlugins::Interface::ProcessObject::
7 GetInput( const std::string& id )
8 {
9   _TDataContainer::iterator i = this->m_Inputs.find( id );
10   if( i != this->m_Inputs.end( ) )
11     return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
12   else
13     return( NULL );
14 }
15
16 // -------------------------------------------------------------------------
17 template< class T >
18 const T* cpPlugins::Interface::ProcessObject::
19 GetInput( const std::string& id ) const
20 {
21   _TDataContainer::const_iterator i = this->m_Inputs.find( id );
22   if( i != this->m_Inputs.end( ) )
23     return( dynamic_cast< const T* >( i->second.GetPointer( ) ) );
24   else
25     return( NULL );
26 }
27
28 // -------------------------------------------------------------------------
29 template< class T >
30 T* cpPlugins::Interface::ProcessObject::
31 GetOutput( const std::string& id )
32 {
33   _TDataContainer::iterator i = this->m_Outputs.find( id );
34   if( i != this->m_Outputs.end( ) )
35     return( dynamic_cast< T* >( i->second.GetPointer( ) ) );
36   else
37     return( NULL );
38 }
39
40 // -------------------------------------------------------------------------
41 template< class T >
42 const T* cpPlugins::Interface::ProcessObject::
43 GetOutput( const std::string& id ) const
44 {
45   _TDataContainer::const_iterator i = this->m_Outputs.find( id );
46   if( i != this->m_Outputs.end( ) )
47     return( dynamic_cast< const T* >( i->second.GetPointer( ) ) );
48   else
49     return( NULL );
50 }
51
52 // -------------------------------------------------------------------------
53 template< class O >
54 void cpPlugins::Interface::ProcessObject::
55 _AddOutput( const std::string& id )
56 {
57   this->m_Outputs[ id ] = O::New( );
58   this->m_Outputs[ id ]->SetSource( this );
59   this->Modified( );
60 }
61
62 // -------------------------------------------------------------------------
63 template< class F >
64 F* cpPlugins::Interface::ProcessObject::
65 _CreateITK( )
66 {
67   F* filter = dynamic_cast< F* >( this->m_ITKObject.GetPointer( ) );
68   if( filter == NULL )
69   {
70     typename F::Pointer ptr = F::New( );
71     this->m_ITKObject = ptr;
72     filter = ptr.GetPointer( );
73     this->m_VTKObject = NULL;
74
75   } // fi
76   return( filter );
77 }
78
79 // -------------------------------------------------------------------------
80 template< class F >
81 F* cpPlugins::Interface::ProcessObject::
82 _CreateVTK( )
83 {
84   F* filter = dynamic_cast< F* >( this->m_VTKObject.GetPointer( ) );
85   if( filter == NULL )
86   {
87     filter = F::New( );
88     this->m_VTKObject = filter;
89     this->m_ITKObject = NULL;
90
91   } // fi
92   return( filter );
93 }
94
95 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
96
97 // eof - $RCSfile$