![]() |
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_H 00022 #define _XN_STACK_H 00023 00024 //--------------------------------------------------------------------------- 00025 // Includes 00026 //--------------------------------------------------------------------------- 00027 #include "XnList.h" 00028 00029 //--------------------------------------------------------------------------- 00030 // Types 00031 //--------------------------------------------------------------------------- 00035 class XnStack 00036 { 00037 public: 00041 XnStack() {} 00045 ~XnStack() {} 00046 00054 XnStatus Push(XnValue const& value) 00055 { 00056 return m_List.AddFirst(value); 00057 } 00058 00066 XnStatus Pop(XnValue& value) 00067 { 00068 if (IsEmpty()) 00069 { 00070 return XN_STATUS_IS_EMPTY; 00071 } 00072 00073 value = *(m_List.begin()); 00074 return m_List.Remove(m_List.begin()); 00075 } 00076 00082 XnValue const& Top() const 00083 { 00084 return *(m_List.begin()); 00085 } 00086 00092 XnValue& Top() 00093 { 00094 return *(m_List.begin()); 00095 } 00096 00100 XnBool IsEmpty() const 00101 { 00102 return m_List.IsEmpty(); 00103 } 00104 00108 XnUInt32 Size() const 00109 { 00110 return m_List.Size(); 00111 } 00112 00113 private: 00114 XN_DISABLE_COPY_AND_ASSIGN(XnStack); 00115 00117 XnList m_List; 00118 }; 00119 00124 #define XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(decl, Type, ClassName, Translator) \ 00125 /* Note: we use queue declaration, as this is the same interface. */ \ 00126 XN_DECLARE_QUEUE_WITH_TRANSLATOR_DECL(decl, Type, ClassName, Translator, XnStack) 00127 00132 #define XN_DECLARE_STACK_WITH_TRANSLATOR(Type, ClassName, Translator) \ 00133 XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(, ClassName, Translator) 00134 00139 #define XN_DECLARE_STACK_DECL(decl, Type, ClassName) \ 00140 XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(decl, Type, XN_DEFAULT_TRANSLATOR_NAME(ClassName)) \ 00141 XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(decl, Type, ClassName, XN_DEFAULT_TRANSLATOR_NAME(ClassName)) 00142 00146 #define XN_DECLARE_STACK(Type, ClassName) \ 00147 XN_DECLARE_STACK_DECL(, Type, ClassName) 00148 00149 00150 #endif // _XN_STACK_H