• Main Page
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

XnStack.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 *                                                                            *
00003 *  OpenNI 1.0 Alpha                                                          *
00004 *  Copyright (C) 2010 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 
00023 
00024 
00025 
00026 #ifndef _XN_STACK_H
00027 #define _XN_STACK_H
00028 
00029 //---------------------------------------------------------------------------
00030 // Includes
00031 //---------------------------------------------------------------------------
00032 #include "XnList.h"
00033 
00034 //---------------------------------------------------------------------------
00035 // Types
00036 //---------------------------------------------------------------------------
00040 class XnStack
00041 {
00042 public:
00046     XnStack() {}
00050     ~XnStack() {}
00051 
00059     XnStatus Push(XnValue const& value)
00060     {
00061         return m_List.AddFirst(value);
00062     }
00063 
00071     XnStatus Pop(XnValue& value)
00072     {
00073         if (IsEmpty())
00074         {
00075             return XN_STATUS_IS_EMPTY;
00076         }
00077 
00078         value = *(m_List.begin());
00079         return m_List.Remove(m_List.begin());
00080     }
00081 
00087     XnValue const& Top() const
00088     {
00089         return *(m_List.begin());
00090     }
00091 
00097     XnValue& Top()
00098     {
00099         return *(m_List.begin());
00100     }
00101 
00105     XnBool IsEmpty() const
00106     {
00107         return m_List.IsEmpty();
00108     }
00109 
00113     XnUInt32 Size() const
00114     {
00115         return m_List.Size();
00116     }
00117 
00118 private:
00120     XnList m_List;
00121 };
00122 
00127 #define XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(decl, Type, ClassName, Translator)        \
00128     /* Note: we use queue declaration, as this is the same interface. */                \
00129     XN_DECLARE_QUEUE_WITH_TRANSLATOR_DECL(decl, Type, ClassName, Translator, XnStack)
00130 
00135 #define XN_DECLARE_STACK_WITH_TRANSLATOR(Type, ClassName, Translator)   \
00136     XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(, ClassName, Translator)
00137 
00142 #define XN_DECLARE_STACK_DECL(decl, Type, ClassName)                                                    \
00143     XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(decl, Type, XN_DEFAULT_TRANSLATOR_NAME(ClassName))         \
00144     XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(decl, Type, ClassName, XN_DEFAULT_TRANSLATOR_NAME(ClassName))
00145 
00149 #define XN_DECLARE_STACK(Type, ClassName)           \
00150     XN_DECLARE_STACK_DECL(, Type, ClassName)
00151 
00152 
00153 #endif // _XN_STACK_H

Generated on Thu Feb 10 2011 for OpenNI 1.0.0 by  doxygen 1.7.1