OpenNI 1.5.4
XnStackT.h
Go to the documentation of this file.
1 #ifndef _XN_STACK_T_H_
2 #define _XN_STACK_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 XnStackT : protected XnListT<T, TAlloc>
14 {
15 public:
17 
19 
20  XnStackT() : Base() {}
21 
22  XnStackT(const XnStackT& other) : Base()
23  {
24  *this = other;
25  }
26 
27  XnStackT& operator=(const XnStackT& other)
28  {
29  Base::operator=(other);
30  // no other members
31  return *this;
32  }
33 
34  ~XnStackT() {}
35 
36  XnBool IsEmpty() const { return Base::IsEmpty(); }
37 
38  XnStatus Push(T const& value) { return Base::AddFirst(value); }
39 
40  XnStatus Pop(T& value)
41  {
42  ConstIterator it = Begin();
43  if (it == End())
44  {
45  return XN_STATUS_IS_EMPTY;
46  }
47  value = *it;
48  return Base::Remove(it);
49  }
50 
51  T const& Top() const { return *Begin(); }
52  T& Top() { return *Begin(); }
53 
54  ConstIterator Begin() const { return Base::Begin(); }
55  ConstIterator End() const { return Base::End(); }
56 };
57 
58 #endif // _XN_STACK_T_H_
XnStackT::~XnStackT
~XnStackT()
Definition: XnStackT.h:34
XnStackT
Definition: XnStackT.h:13
XnListT::End
Iterator End()
Definition: XnListT.h:281
XnListT
Definition: XnListT.h:64
XnListT::Remove
XnStatus Remove(ConstIterator where)
Definition: XnListT.h:426
XnStackT::ConstIterator
Base::ConstIterator ConstIterator
Definition: XnStackT.h:18
XnStackT::operator=
XnStackT & operator=(const XnStackT &other)
Definition: XnStackT.h:27
XnStatus
XnUInt32 XnStatus
Definition: XnStatus.h:33
XnStackT::Begin
ConstIterator Begin() const
Definition: XnStackT.h:54
XnStackT::IsEmpty
XnBool IsEmpty() const
Definition: XnStackT.h:36
XnListT::operator=
XnListT & operator=(const XnListT &other)
Definition: XnListT.h:242
XnStackT::XnStackT
XnStackT()
Definition: XnStackT.h:20
XnListT::ConstIterator
Definition: XnListT.h:74
XnListT::IsEmpty
XnBool IsEmpty() const
Definition: XnListT.h:482
XnStackT::Top
T & Top()
Definition: XnStackT.h:52
XnStackT::Push
XnStatus Push(T const &value)
Definition: XnStackT.h:38
XnListT.h
XnStackT::XnStackT
XnStackT(const XnStackT &other)
Definition: XnStackT.h:22
XnStackT::Top
T const & Top() const
Definition: XnStackT.h:51
XnStackT::Base
XnListT< T, TAlloc > Base
Definition: XnStackT.h:16
XnStackT::Pop
XnStatus Pop(T &value)
Definition: XnStackT.h:40
XnListT::Begin
Iterator Begin()
Definition: XnListT.h:265
XnStackT::End
ConstIterator End() const
Definition: XnStackT.h:55
XnListT::AddFirst
XnStatus AddFirst(T const &value)
Definition: XnListT.h:371