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

XnStack.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 *                                                                           *
00003 *  OpenNI 1.1 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:
00116     XnList m_List;
00117 };
00118 
00123 #define XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(decl, Type, ClassName, Translator)        \
00124     /* Note: we use queue declaration, as this is the same interface. */                \
00125     XN_DECLARE_QUEUE_WITH_TRANSLATOR_DECL(decl, Type, ClassName, Translator, XnStack)
00126 
00131 #define XN_DECLARE_STACK_WITH_TRANSLATOR(Type, ClassName, Translator)   \
00132     XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(, ClassName, Translator)
00133 
00138 #define XN_DECLARE_STACK_DECL(decl, Type, ClassName)                                                    \
00139     XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(decl, Type, XN_DEFAULT_TRANSLATOR_NAME(ClassName))         \
00140     XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(decl, Type, ClassName, XN_DEFAULT_TRANSLATOR_NAME(ClassName))
00141 
00145 #define XN_DECLARE_STACK(Type, ClassName)           \
00146     XN_DECLARE_STACK_DECL(, Type, ClassName)
00147 
00148 
00149 #endif // _XN_STACK_H

Generated on Sat Nov 10 2012 07:13:53 for OpenNI 1.3.2 by  doxygen 1.7.1