X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Ffpa%2FFilters%2FQueueAlgorithm.hxx;fp=lib%2Ffpa%2FFilters%2FQueueAlgorithm.hxx;h=aa51d5d2cccb3afdc0a422a57dcfdc26c0112d99;hb=bd89a1af0c14ed2ac0afeca923103de54283cbaf;hp=0000000000000000000000000000000000000000;hpb=a8ac405fe1422bc0792a810f7f0693096a22c20e;p=FrontAlgorithms.git diff --git a/lib/fpa/Filters/QueueAlgorithm.hxx b/lib/fpa/Filters/QueueAlgorithm.hxx new file mode 100644 index 0000000..aa51d5d --- /dev/null +++ b/lib/fpa/Filters/QueueAlgorithm.hxx @@ -0,0 +1,74 @@ +// ========================================================================= +// @author Leonardo Florez Valencia +// @email florez-l@javeriana.edu.co +// ========================================================================= +#ifndef __fpa__Filters__QueueAlgorithm__hxx__ +#define __fpa__Filters__QueueAlgorithm__hxx__ + +// ------------------------------------------------------------------------- +template< class _TDataInterface > +fpa::Filters::QueueAlgorithm< _TDataInterface >:: +QueueAlgorithm( bool double_buffer ) + : Superclass( ), + m_CurrQueue( 0 ), + m_DoubleBuffer( double_buffer ) +{ +} + +// ------------------------------------------------------------------------- +template< class _TDataInterface > +fpa::Filters::QueueAlgorithm< _TDataInterface >:: +~QueueAlgorithm( ) +{ +} + +// ------------------------------------------------------------------------- +template< class _TDataInterface > +void fpa::Filters::QueueAlgorithm< _TDataInterface >:: +_QueueSwap( ) +{ + if( this->m_DoubleBuffer ) + this->m_CurrQueue = ( this->m_CurrQueue + 1 ) % 2; + else + this->m_CurrQueue = 0; +} + +// ------------------------------------------------------------------------- +template< class _TDataInterface > +void fpa::Filters::QueueAlgorithm< _TDataInterface >:: +_QueueClear( ) +{ + this->m_Queues[ 0 ].clear( ); + this->m_Queues[ 1 ].clear( ); + this->m_CurrQueue = 0; +} + +// ------------------------------------------------------------------------- +template< class _TDataInterface > +typename fpa::Filters::QueueAlgorithm< _TDataInterface >:: +TNode fpa::Filters::QueueAlgorithm< _TDataInterface >:: +_QueuePop( ) +{ + TNode n = this->m_Queues[ this->m_CurrQueue ].front( ); + this->m_Queues[ this->m_CurrQueue ].pop_front( ); + return( n ); +} + +// ------------------------------------------------------------------------- +template< class _TDataInterface > +void fpa::Filters::QueueAlgorithm< _TDataInterface >:: +_QueuePush( const TNode& n ) +{ + this->m_Queues[ this->m_CurrQueue ].push_back( n ); +} + +// ------------------------------------------------------------------------- +template< class _TDataInterface > +unsigned long fpa::Filters::QueueAlgorithm< _TDataInterface >:: +_QueueSize( ) const +{ + return( this->m_Queues[ this->m_CurrQueue ].size( ) ); +} + +#endif // __fpa__Filters__QueueAlgorithm__hxx__ +// eof - $RCSfile$