diff options
author | Miikka Heikkinen <miikka.heikkinen@theqtcompany.com> | 2015-10-22 13:11:21 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@theqtcompany.com> | 2015-10-22 13:16:16 +0300 |
commit | c6090dc08fbb6c88cc3a35482660839664eb46e7 (patch) | |
tree | 316138cb73c49877f5a80a8496c2f1b737122fb5 /tests/manual/kinectsurface/QtKinectWrapper/OpenNI/Include/XnStackT.h | |
parent | b235e3dbeddc7ee7f4d47509c799bbc990585832 (diff) | |
parent | 31f9c57bc50ae053cfaf039a1dfdb128e2494458 (diff) |
Merge branch 'develop'
Change-Id: Id4ff4c5196d35401f647e70a8c2a127d1c77629f
Diffstat (limited to 'tests/manual/kinectsurface/QtKinectWrapper/OpenNI/Include/XnStackT.h')
-rw-r--r-- | tests/manual/kinectsurface/QtKinectWrapper/OpenNI/Include/XnStackT.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/manual/kinectsurface/QtKinectWrapper/OpenNI/Include/XnStackT.h b/tests/manual/kinectsurface/QtKinectWrapper/OpenNI/Include/XnStackT.h new file mode 100644 index 00000000..2963a5f8 --- /dev/null +++ b/tests/manual/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 |