00001 #include "AIDA_FilterRange.h" 00002 #include "AIDA_Dev/IDevTuple.h" 00003 #include "AIDA_Dev/ITupleHeader.h" 00004 #include <typeinfo> 00005 #include <cmath> 00006 00007 Anaphe::AIDA_Tuple_native::AIDA_FilterRange::AIDA_FilterRange( CompiledExpressionManager& manager, 00008 const std::string& expression, 00009 int numberOfRows, 00010 int startingRow ): 00011 Anaphe::AIDA_Tuple_native::AIDA_Filter( manager, expression ), 00012 m_startingRow( std::abs( startingRow ) ), 00013 m_endingRow( m_startingRow + std::abs( numberOfRows ) -1 ), 00014 m_header( 0 ) 00015 {} 00016 00017 00018 bool 00019 Anaphe::AIDA_Tuple_native::AIDA_FilterRange::initialize( AIDA::ITuple & tuple ) 00020 { 00021 if ( ! this->Anaphe::AIDA_Tuple_native::AIDA_Filter::initialize( tuple ) ) return false; 00022 try{ 00023 AIDA::Dev::IDevTuple& tp = dynamic_cast<AIDA::Dev::IDevTuple&>( tuple ); 00024 m_header = &( tp.header() ); 00025 return true; 00026 } 00027 catch( std::bad_cast ) { 00028 return false; 00029 } 00030 } 00031 00032 00033 bool 00034 Anaphe::AIDA_Tuple_native::AIDA_FilterRange::accept() const 00035 { 00036 if ( ! m_header ) return false; 00037 const int currentRow = m_header->currentRowNumber(); 00038 if ( currentRow < m_startingRow || currentRow > m_endingRow ) return false; 00039 return this->Anaphe::AIDA_Tuple_native::AIDA_Filter::accept(); 00040 }