1 // =========================================================================
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // =========================================================================
5 #include <cpPlugins/Filter.h>
7 // -------------------------------------------------------------------------
8 void cpPlugins::Filter::
9 SetFunctor( const std::string& name, cpPlugins::Functor* functor )
11 TFunctors::iterator i = this->m_Functors.find( name );
12 if( i != this->m_Functors.end( ) )
14 if( !( i->second.Set( functor ) ) )
16 this, << "Functor \"" << name << "\" does not match to input data."
21 this, << "Functor \"" << name << "\" does not belong to this filter."
25 // -------------------------------------------------------------------------
26 cpPlugins::DataObject* cpPlugins::Filter::
27 GetOutput( const std::string& name )
29 TOutputs::iterator i = this->m_Outputs.find( name );
30 if( i != this->m_Outputs.end( ) )
31 return( i->second.Get( ) );
34 this, << "Output \"" << name << "\" does not belong to this filter."
38 // -------------------------------------------------------------------------
39 const cpPlugins::DataObject* cpPlugins::Filter::
40 GetOutput( const std::string& name ) const
42 TOutputs::const_iterator i = this->m_Outputs.find( name );
43 if( i != this->m_Outputs.end( ) )
44 return( i->second.Get( ) );
47 this, << "Output \"" << name << "\" does not belong to this filter."
51 // -------------------------------------------------------------------------
52 bool cpPlugins::Filter::
53 HasOutput( const std::string& name ) const
55 TOutputs::const_iterator i = this->m_Outputs.find( name );
56 return( i != this->m_Outputs.end( ) );
59 // -------------------------------------------------------------------------
60 cpPlugins::Functor* cpPlugins::Filter::
61 GetFunctor( const std::string& name )
63 TFunctors::iterator i = this->m_Functors.find( name );
64 if( i != this->m_Functors.end( ) )
65 return( i->second.Get( ) );
68 this, << "Functor \"" << name << "\" does not belong to this filter."
72 // -------------------------------------------------------------------------
73 const cpPlugins::Functor* cpPlugins::Filter::
74 GetFunctor( const std::string& name ) const
76 TFunctors::const_iterator i = this->m_Functors.find( name );
77 if( i != this->m_Functors.end( ) )
78 return( i->second.Get( ) );
81 this, << "Functor \"" << name << "\" does not belong to this filter."
85 // -------------------------------------------------------------------------
86 std::set< std::string > cpPlugins::Filter::
87 GetOutputsNames( ) const
89 std::set< std::string > n;
90 TOutputs::const_iterator i = this->m_Outputs.begin( );
91 for( ; i != this->m_Outputs.end( ); ++i )
96 // -------------------------------------------------------------------------
97 std::set< std::string > cpPlugins::Filter::
98 GetFunctorsNames( ) const
100 std::set< std::string > n;
101 TFunctors::const_iterator i = this->m_Functors.begin( );
102 for( ; i != this->m_Functors.end( ); ++i )
103 n.insert( i->first );
107 // -------------------------------------------------------------------------
108 std::set< std::string > cpPlugins::Filter::
109 GetAllInputsNames( ) const
111 std::set< std::string > r = this->Superclass::GetAllInputsNames( );
112 std::set< std::string > iFunctors = this->GetFunctorsNames( );
113 for( const std::string& s: iFunctors )
118 // -------------------------------------------------------------------------
119 std::set< std::string > cpPlugins::Filter::
120 GetAllOutputsNames( ) const
122 std::set< std::string > r = this->Superclass::GetAllOutputsNames( );
123 std::set< std::string > oNames = this->GetOutputsNames( );
124 for( const std::string& s: oNames )
129 // -------------------------------------------------------------------------
136 // -------------------------------------------------------------------------
142 // -------------------------------------------------------------------------
143 bool cpPlugins::Filter::
146 bool is_updated = this->Superclass::_BeforeUpdate( );
147 for( TFunctors::value_type& fIt: this->m_Functors )
149 cpPlugins::Functor* f = fIt.second.Get( )->Cast< cpPlugins::Functor >( );
152 if( !( f->IsUpdated( ) ) )
160 return( is_updated );