diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-10-14 08:12:34 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-10-14 08:12:34 +0300 |
commit | 18a5a1510b90a16007569f436392b52553f150fa (patch) | |
tree | 190f35b2da9ad298a4bc1636d0a9d993f41ea288 /tests/kinectsurface/QtKinectWrapper/OpenNI/Include/XnStackT.h | |
parent | a64c67d75badaa7662b8a05b8bc7ed78ec8e651e (diff) | |
parent | 34c345b024be424873bbb8b3c83414eea2bc7523 (diff) |
Merge remote-tracking branch 'origin/develop'
Change-Id: I3b63e58db8a5555ada270f81f88fa3b04cecada9
Diffstat (limited to 'tests/kinectsurface/QtKinectWrapper/OpenNI/Include/XnStackT.h')
-rw-r--r-- | tests/kinectsurface/QtKinectWrapper/OpenNI/Include/XnStackT.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/kinectsurface/QtKinectWrapper/OpenNI/Include/XnStackT.h b/tests/kinectsurface/QtKinectWrapper/OpenNI/Include/XnStackT.h new file mode 100644 index 00000000..2963a5f8 --- /dev/null +++ b/tests/kinectsurface/QtKinectWrapper/OpenNI/Include/XnStackT.h @@ -0,0 +1,58 @@ +#ifndef _XN_STACK_T_H_ +#define _XN_STACK_T_H_ + +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include "XnListT.h" + +//--------------------------------------------------------------------------- +// Code +//--------------------------------------------------------------------------- +template<class T, class TAlloc = XnLinkedNodeDefaultAllocatorT<T> > +class XnStackT : protected XnListT<T, TAlloc> +{ +public: + typedef XnListT<T, TAlloc> Base; + + typedef typename Base::ConstIterator ConstIterator; + + XnStackT() : Base() {} + + XnStackT(const XnStackT& other) : Base() + { + *this = other; + } + + XnStackT& operator=(const XnStackT& other) + { + Base::operator=(other); + // no other members + return *this; + } + + ~XnStackT() {} + + XnBool IsEmpty() const { return Base::IsEmpty(); } + + XnStatus Push(T const& value) { return Base::AddFirst(value); } + + XnStatus Pop(T& value) + { + ConstIterator it = Begin(); + if (it == End()) + { + return XN_STATUS_IS_EMPTY; + } + value = *it; + return Base::Remove(it); + } + + T const& Top() const { return *Begin(); } + T& Top() { return *Begin(); } + + ConstIterator Begin() const { return Base::Begin(); } + ConstIterator End() const { return Base::End(); } +}; + +#endif // _XN_STACK_T_H_
\ No newline at end of file |