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_
XnQueueT::Base
XnListT< T, TAlloc > Base
Definition: XnQueueT.h:16
XnListT::End
Iterator End()
Definition: XnListT.h:281
XnListT
Definition: XnListT.h:64
XnQueueT::Pop
XnStatus Pop(T &value)
Definition: XnQueueT.h:42
XnListT::Remove
XnStatus Remove(ConstIterator where)
Definition: XnListT.h:426
XnQueueT::XnQueueT
XnQueueT(const XnQueueT &other)
Definition: XnQueueT.h:20
XnQueueT::Top
T const & Top() const
Definition: XnQueueT.h:53
XnStatus
XnUInt32 XnStatus
Definition: XnStatus.h:33
XnQueueT
Definition: XnQueueT.h:13
XnQueueT::XnQueueT
XnQueueT()
Definition: XnQueueT.h:18
XnQueueT::Top
T & Top()
Definition: XnQueueT.h:54
XnListT::operator=
XnListT & operator=(const XnListT &other)
Definition: XnListT.h:242
XnListT::AddLast
XnStatus AddLast(T const &value)
Definition: XnListT.h:383
XnListT::IsEmpty
XnBool IsEmpty() const
Definition: XnListT.h:482
XnQueueT::~XnQueueT
~XnQueueT()
Definition: XnQueueT.h:32
XnQueueT::operator=
XnQueueT & operator=(const XnQueueT &other)
Definition: XnQueueT.h:25
XnListT.h
XnListT::Size
XnUInt32 Size() const
Definition: XnListT.h:490
XnQueueT::Push
XnStatus Push(T const &value)
Definition: XnQueueT.h:37
XnListT::Iterator
Definition: XnListT.h:167
XnListT::Begin
Iterator Begin()
Definition: XnListT.h:265