![]() |
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_QUEUE_T_H_ 00022 #define _XN_QUEUE_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 XnQueueT : protected XnListT<T, TAlloc> 00034 { 00035 public: 00036 typedef XnListT<T, TAlloc> Base; 00037 00038 XnQueueT() : Base() {} 00039 00040 XnQueueT(const XnQueueT& other) : Base() 00041 { 00042 *this = other; 00043 } 00044 00045 XnQueueT& operator=(const XnQueueT& other) 00046 { 00047 Base::operator=(other); 00048 // no other members 00049 return *this; 00050 } 00051 00052 ~XnQueueT() {} 00053 00054 using Base::ConstIterator; 00055 using Base::IsEmpty; 00056 00057 XnStatus Push(T const& value) 00058 { 00059 return Base::AddLast(value); 00060 } 00061 00062 XnStatus Pop(T& value) 00063 { 00064 Iterator it = Begin(); 00065 if (it == End()) 00066 { 00067 return XN_STATUS_IS_EMPTY; 00068 } 00069 value = *it; 00070 return Base::Remove(it); 00071 } 00072 00073 T const& Top() const { return *Begin(); } 00074 T& Top() { return *Begin(); } 00075 00076 using Base::Begin; 00077 using Base::End; 00078 using Base::Size; 00079 }; 00080 00081 00082 00083 #endif // _XN_QUEUE_T_H_