XnCyclicQueueT.h
Go to the documentation of this file.
#ifndef _XN_CYCLIC_QUEUE_T_H_
#define _XN_CYCLIC_QUEUE_T_H_
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include "XnQueueT.h"
//---------------------------------------------------------------------------
// Code
//---------------------------------------------------------------------------
template<class T, XnUInt32 TDefaultMaxDepth, class TAlloc = XnLinkedNodeDefaultAllocatorT<T> >
class XnCyclicQueueT : protected XnQueueT<T, TAlloc>
{
public:
typedef XnQueueT<T, TAlloc> Base;
XnCyclicQueueT(XnUInt32 nMaxDepth = TDefaultMaxDepth) : Base(), m_nMaxDepth(nMaxDepth) {}
XnCyclicQueueT(const XnCyclicQueueT& other) : Base(other)
{
*this = other;
}
XnCyclicQueueT& operator=(const XnCyclicQueueT& other)
{
Base::operator=(other);
m_nMaxDepth = other.m_nMaxDepth;
return *this;
}
~XnCyclicQueueT() {}
using Base::ConstIterator;
using Base::IsEmpty;
using Base::Size;
XnStatus SetMaxSize(XnUInt32 nMaxSize)
{
XnStatus nRetVal = XN_STATUS_OK;
while (Size() > nMaxSize)
{
nRetVal = Remove(this->Begin());
XN_IS_STATUS_OK(nRetVal);
}
m_nMaxDepth = nMaxSize;
return (XN_STATUS_OK);
}
XnStatus Push(T const& value)
{
XnStatus nRetVal = XN_STATUS_OK;
if (Size() == m_nMaxDepth)
{
nRetVal = Remove(this->Begin());
XN_IS_STATUS_OK(nRetVal);
}
nRetVal = Base::Push(value);
XN_IS_STATUS_OK(nRetVal);
return (XN_STATUS_OK);
}
using Base::Pop;
using Base::Top;
using Base::Begin;
using Base::End;
protected:
XnUInt32 m_nMaxDepth;
};
#endif // _XN_CYCLIC_QUEUE_T_H_
XN_IS_STATUS_OK
#define XN_IS_STATUS_OK(x)
Definition XnMacros.h:60
XnQueueT.h
XnStatus
XnUInt32 XnStatus
Definition XnStatus.h:34
XN_STATUS_OK
#define XN_STATUS_OK
Definition XnStatus.h:37
XnCyclicQueueT::Base
XnQueueT< T, TAlloc > Base
Definition XnCyclicQueueT.h:17
XnCyclicQueueT::SetMaxSize
XnStatus SetMaxSize(XnUInt32 nMaxSize)
Definition XnCyclicQueueT.h:39
XnCyclicQueueT::Push
XnStatus Push(T const &value)
Definition XnCyclicQueueT.h:54
XnCyclicQueueT::XnCyclicQueueT
XnCyclicQueueT(XnUInt32 nMaxDepth=TDefaultMaxDepth)
Definition XnCyclicQueueT.h:19
XnCyclicQueueT::m_nMaxDepth
XnUInt32 m_nMaxDepth
Definition XnCyclicQueueT.h:75
XnCyclicQueueT::operator=
XnCyclicQueueT & operator=(const XnCyclicQueueT &other)
Definition XnCyclicQueueT.h:26
XnCyclicQueueT::XnCyclicQueueT
XnCyclicQueueT(const XnCyclicQueueT &other)
Definition XnCyclicQueueT.h:21
XnCyclicQueueT::~XnCyclicQueueT
~XnCyclicQueueT()
Definition XnCyclicQueueT.h:33
XnListT::Remove
XnStatus Remove(ConstIterator where)
Definition XnListT.h:426
XnQueueT< T, TAlloc >::Size
XnUInt32 Size() const
XnQueueT< T, TAlloc >::Push
XnStatus Push(T const &value)
Definition XnQueueT.h:37
XnQueueT< T, TAlloc >::Pop
XnStatus Pop(T &value)
Definition XnQueueT.h:42
XnQueueT< T, TAlloc >::operator=
XnQueueT & operator=(const XnQueueT &other)
Definition XnQueueT.h:25
XnQueueT< T, TAlloc >::End
Iterator End()
XnQueueT::Begin
Iterator Begin()
Definition XnListT.h:265
XnQueueT< T, TAlloc >::Top
T const & Top() const
Definition XnQueueT.h:53
XnQueueT< T, TAlloc >::IsEmpty
XnBool IsEmpty() const
XnQueueT::XnQueueT
XnQueueT()
Definition XnQueueT.h:18