]> 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 GetInputData( const std::string& id )
8 {
9   auto 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 GetInputData( const std::string& id ) const
20 {
21   auto 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 GetOutputData( const std::string& id )
32 {
33   auto 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 GetOutputData( const std::string& id ) const
44 {
45   auto 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& name )
56 {
57   typedef typename _TDataContainer::value_type _TValue;
58   auto i = this->m_Outputs.find( name );
59   if( i == this->m_Outputs.end( ) )
60   {
61     typename O::Pointer o = O::New( );
62     o->SetSource( this );
63     this->m_Outputs[ name ] = o;
64     this->Modified( );
65
66   } // fi
67 }
68
69 // -------------------------------------------------------------------------
70 template< class F >
71 F* cpPlugins::Interface::ProcessObject::
72 _CreateITK( )
73 {
74   F* filter = this->GetITK< F >( );
75   if( filter == NULL )
76   {
77     typename F::Pointer filter_ptr = F::New( );
78     this->SetITK( filter_ptr.GetPointer( ) );
79     this->SetVTK( NULL );
80     filter = filter_ptr.GetPointer( );
81     this->Modified( );
82
83   } // fi
84   return( filter );
85 }
86
87 // -------------------------------------------------------------------------
88 template< class F >
89 F* cpPlugins::Interface::ProcessObject::
90 _CreateVTK( )
91 {
92   F* filter = this->GetVTK< F >( );
93   if( filter == NULL )
94   {
95     vtkSmartPointer< F > filter_ptr = vtkSmartPointer< F >::New( );
96     this->SetITK( NULL );
97     this->SetVTK( filter_ptr );
98     filter = filter_ptr.GetPointer( );
99     this->Modified( );
100
101   } // fi
102   return( filter );
103 }
104
105 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__HXX__
106
107 // eof - $RCSfile$