![]() |
OpenNI 1.5.7
|
00001 /***************************************************************************** 00002 * * 00003 * OpenNI 1.x Alpha * 00004 * Copyright (C) 2012 PrimeSense Ltd. * 00005 * * 00006 * This file is part of OpenNI. * 00007 * * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); * 00009 * you may not use this file except in compliance with the License. * 00010 * You may obtain a copy of the License at * 00011 * * 00012 * http://www.apache.org/licenses/LICENSE-2.0 * 00013 * * 00014 * Unless required by applicable law or agreed to in writing, software * 00015 * distributed under the License is distributed on an "AS IS" BASIS, * 00016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 00017 * See the License for the specific language governing permissions and * 00018 * limitations under the License. * 00019 * * 00020 *****************************************************************************/ 00021 #ifndef _XN_STACK_T_H_ 00022 #define _XN_STACK_T_H_ 00023 00024 //--------------------------------------------------------------------------- 00025 // Includes 00026 //--------------------------------------------------------------------------- 00027 #include "XnListT.h" 00028 00029 //--------------------------------------------------------------------------- 00030 // Code 00031 //--------------------------------------------------------------------------- 00032 template<class T, class TAlloc = XnLinkedNodeDefaultAllocatorT<T> > 00033 class XnStackT : protected XnListT<T, TAlloc> 00034 { 00035 public: 00036 typedef XnListT<T, TAlloc> Base; 00037 00038 typedef typename Base::ConstIterator ConstIterator; 00039 00040 XnStackT() : Base() {} 00041 00042 XnStackT(const XnStackT& other) : Base() 00043 { 00044 *this = other; 00045 } 00046 00047 XnStackT& operator=(const XnStackT& other) 00048 { 00049 Base::operator=(other); 00050 // no other members 00051 return *this; 00052 } 00053 00054 ~XnStackT() {} 00055 00056 XnBool IsEmpty() const { return Base::IsEmpty(); } 00057 00058 XnStatus Push(T const& value) { return Base::AddFirst(value); } 00059 00060 XnStatus Pop(T& value) 00061 { 00062 ConstIterator it = Begin(); 00063 if (it == End()) 00064 { 00065 return XN_STATUS_IS_EMPTY; 00066 } 00067 value = *it; 00068 return Base::Remove(it); 00069 } 00070 00071 T const& Top() const { return *Begin(); } 00072 T& Top() { return *Begin(); } 00073 00074 ConstIterator Begin() const { return Base::Begin(); } 00075 ConstIterator End() const { return Base::End(); } 00076 }; 00077 00078 #endif // _XN_STACK_T_H_