OpenNI 1.5.4: XnStack.h Source File

OpenNI

OpenNI 1.5.4
XnStack.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 *                                                                           *
00003 *  OpenNI 1.x Alpha                                                         *
00004 *  Copyright (C) 2011 PrimeSense Ltd.                                       *
00005 *                                                                           *
00006 *  This file is part of OpenNI.                                             *
00007 *                                                                           *
00008 *  OpenNI is free software: you can redistribute it and/or modify           *
00009 *  it under the terms of the GNU Lesser General Public License as published *
00010 *  by the Free Software Foundation, either version 3 of the License, or     *
00011 *  (at your option) any later version.                                      *
00012 *                                                                           *
00013 *  OpenNI is distributed in the hope that it will be useful,                *
00014 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00015 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the             *
00016 *  GNU Lesser General Public License for more details.                      *
00017 *                                                                           *
00018 *  You should have received a copy of the GNU Lesser General Public License *
00019 *  along with OpenNI. If not, see <http://www.gnu.org/licenses/>.           *
00020 *                                                                           *
00021 ****************************************************************************/
00022 #ifndef _XN_STACK_H
00023 #define _XN_STACK_H
00024 
00025 //---------------------------------------------------------------------------
00026 // Includes
00027 //---------------------------------------------------------------------------
00028 #include "XnList.h"
00029 
00030 //---------------------------------------------------------------------------
00031 // Types
00032 //---------------------------------------------------------------------------
00036 class XnStack
00037 {
00038 public:
00042     XnStack() {}
00046     ~XnStack() {}
00047 
00055     XnStatus Push(XnValue const& value)
00056     {
00057         return m_List.AddFirst(value);
00058     }
00059 
00067     XnStatus Pop(XnValue& value)
00068     {
00069         if (IsEmpty())
00070         {
00071             return XN_STATUS_IS_EMPTY;
00072         }
00073 
00074         value = *(m_List.begin());
00075         return m_List.Remove(m_List.begin());
00076     }
00077 
00083     XnValue const& Top() const
00084     {
00085         return *(m_List.begin());
00086     }
00087 
00093     XnValue& Top()
00094     {
00095         return *(m_List.begin());
00096     }
00097 
00101     XnBool IsEmpty() const
00102     {
00103         return m_List.IsEmpty();
00104     }
00105 
00109     XnUInt32 Size() const
00110     {
00111         return m_List.Size();
00112     }
00113 
00114 private:
00115     XN_DISABLE_COPY_AND_ASSIGN(XnStack);
00116 
00118     XnList m_List;
00119 };
00120 
00125 #define XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(decl, Type, ClassName, Translator)        \
00126     /* Note: we use queue declaration, as this is the same interface. */                \
00127     XN_DECLARE_QUEUE_WITH_TRANSLATOR_DECL(decl, Type, ClassName, Translator, XnStack)
00128 
00133 #define XN_DECLARE_STACK_WITH_TRANSLATOR(Type, ClassName, Translator)   \
00134     XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(, ClassName, Translator)
00135 
00140 #define XN_DECLARE_STACK_DECL(decl, Type, ClassName)                                                    \
00141     XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(decl, Type, XN_DEFAULT_TRANSLATOR_NAME(ClassName))         \
00142     XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(decl, Type, ClassName, XN_DEFAULT_TRANSLATOR_NAME(ClassName))
00143 
00147 #define XN_DECLARE_STACK(Type, ClassName)           \
00148     XN_DECLARE_STACK_DECL(, Type, ClassName)
00149 
00150 
00151 #endif // _XN_STACK_H
Generated on Wed May 16 2012 10:16:05 for OpenNI 1.5.4 by   doxygen 1.7.5.1