OpenNI 1.5.4
XnQueueT.h
Go to the documentation of this file.
1 #ifndef _XN_QUEUE_T_H_
2 #define _XN_QUEUE_T_H_
3 
4 //---------------------------------------------------------------------------
5 // Includes
6 //---------------------------------------------------------------------------
7 #include <XnListT.h>
8 
9 //---------------------------------------------------------------------------
10 // Code
11 //---------------------------------------------------------------------------
12 template<class T, class TAlloc = XnLinkedNodeDefaultAllocatorT<T> >
13 class XnQueueT : protected XnListT<T, TAlloc>
14 {
15 public:
17 
18  XnQueueT() : Base() {}
19 
20  XnQueueT(const XnQueueT& other) : Base()
21  {
22  *this = other;
23  }
24 
25  XnQueueT& operator=(const XnQueueT& other)
26  {
27  Base::operator=(other);
28  // no other members
29  return *this;
30  }
31 
32  ~XnQueueT() {}
33 
34  using Base::ConstIterator;
35  using Base::IsEmpty;
36 
37  XnStatus Push(T const& value)
38  {
39  return Base::AddLast(value);
40  }
41 
42  XnStatus Pop(T& value)
43  {
44  Iterator it = Begin();
45  if (it == End())
46  {
47  return XN_STATUS_IS_EMPTY;
48  }
49  value = *it;
50  return Base::Remove(it);
51  }
52 
53  T const& Top() const { return *Begin(); }
54  T& Top() { return *Begin(); }
55 
56  using Base::Begin;
57  using Base::End;
58  using Base::Size;
59 };
60 
61 
62 
63 #endif // _XN_QUEUE_T_H_