XnStack.h
Go to the documentation of this file.
/****************************************************************************
* *
* OpenNI 1.x Alpha *
* Copyright (C) 2011 PrimeSense Ltd. *
* *
* This file is part of OpenNI. *
* *
* OpenNI is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* OpenNI is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with OpenNI. If not, see <http://www.gnu.org/licenses/>. *
* *
****************************************************************************/
#ifndef _XN_STACK_H
#define _XN_STACK_H
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include "XnList.h"
//---------------------------------------------------------------------------
// Types
//---------------------------------------------------------------------------
class XnStack
{
public:
XnStack() {}
~XnStack() {}
XnStatus Push(XnValue const& value)
{
return m_List.AddFirst(value);
}
XnStatus Pop(XnValue& value)
{
if (IsEmpty())
{
return XN_STATUS_IS_EMPTY;
}
value = *(m_List.begin());
return m_List.Remove(m_List.begin());
}
XnValue const& Top() const
{
return *(m_List.begin());
}
XnValue& Top()
{
return *(m_List.begin());
}
XnBool IsEmpty() const
{
return m_List.IsEmpty();
}
XnUInt32 Size() const
{
return m_List.Size();
}
private:
XN_DISABLE_COPY_AND_ASSIGN(XnStack);
XnList m_List;
};
#define XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(decl, Type, ClassName, Translator) \
/* Note: we use queue declaration, as this is the same interface. */ \
XN_DECLARE_QUEUE_WITH_TRANSLATOR_DECL(decl, Type, ClassName, Translator, XnStack)
#define XN_DECLARE_STACK_WITH_TRANSLATOR(Type, ClassName, Translator) \
XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(, ClassName, Translator)
#define XN_DECLARE_STACK_DECL(decl, Type, ClassName) \
XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(decl, Type, XN_DEFAULT_TRANSLATOR_NAME(ClassName)) \
XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(decl, Type, ClassName, XN_DEFAULT_TRANSLATOR_NAME(ClassName))
#define XN_DECLARE_STACK(Type, ClassName) \
XN_DECLARE_STACK_DECL(, Type, ClassName)
#endif // _XN_STACK_H
XnValue
void * XnValue
Definition XnDataTypes.h:36
XnList.h
XN_DISABLE_COPY_AND_ASSIGN
#define XN_DISABLE_COPY_AND_ASSIGN(TypeName)
Definition XnMacros.h:119
XnStatus
XnUInt32 XnStatus
Definition XnStatus.h:34
XnList
Definition XnList.h:42
XnStack
Definition XnStack.h:37
XnStack::Pop
XnStatus Pop(XnValue &value)
Definition XnStack.h:67
XnStack::XnStack
XnStack()
Definition XnStack.h:42
XnStack::Size
XnUInt32 Size() const
Definition XnStack.h:109
XnStack::Top
XnValue const & Top() const
Definition XnStack.h:83
XnStack::Push
XnStatus Push(XnValue const &value)
Definition XnStack.h:55
XnStack::~XnStack
~XnStack()
Definition XnStack.h:46
XnStack::IsEmpty
XnBool IsEmpty() const
Definition XnStack.h:101
XnStack::Top
XnValue & Top()
Definition XnStack.h:93