OpenNI 1.5.4
XnStack.h
Go to the documentation of this file.
1/****************************************************************************
2* *
3* OpenNI 1.x Alpha *
4* Copyright (C) 2011 PrimeSense Ltd. *
5* *
6* This file is part of OpenNI. *
7* *
8* OpenNI is free software: you can redistribute it and/or modify *
9* it under the terms of the GNU Lesser General Public License as published *
10* by the Free Software Foundation, either version 3 of the License, or *
11* (at your option) any later version. *
12* *
13* OpenNI is distributed in the hope that it will be useful, *
14* but WITHOUT ANY WARRANTY; without even the implied warranty of *
15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16* GNU Lesser General Public License for more details. *
17* *
18* You should have received a copy of the GNU Lesser General Public License *
19* along with OpenNI. If not, see <http://www.gnu.org/licenses/>. *
20* *
21****************************************************************************/
22#ifndef _XN_STACK_H
23#define _XN_STACK_H
24
25//---------------------------------------------------------------------------
26// Includes
27//---------------------------------------------------------------------------
28#include "XnList.h"
29
30//---------------------------------------------------------------------------
31// Types
32//---------------------------------------------------------------------------
37{
38public:
47
55 XnStatus Push(XnValue const& value)
56 {
57 return m_List.AddFirst(value);
58 }
59
68 {
69 if (IsEmpty())
70 {
71 return XN_STATUS_IS_EMPTY;
72 }
73
74 value = *(m_List.begin());
75 return m_List.Remove(m_List.begin());
76 }
77
83 XnValue const& Top() const
84 {
85 return *(m_List.begin());
86 }
87
94 {
95 return *(m_List.begin());
96 }
97
101 XnBool IsEmpty() const
102 {
103 return m_List.IsEmpty();
104 }
105
109 XnUInt32 Size() const
110 {
111 return m_List.Size();
112 }
113
114private:
115 XN_DISABLE_COPY_AND_ASSIGN(XnStack);
116
118 XnList m_List;
119};
120
125#define XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(decl, Type, ClassName, Translator) \
126 /* Note: we use queue declaration, as this is the same interface. */ \
127 XN_DECLARE_QUEUE_WITH_TRANSLATOR_DECL(decl, Type, ClassName, Translator, XnStack)
128
133#define XN_DECLARE_STACK_WITH_TRANSLATOR(Type, ClassName, Translator) \
134 XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(, ClassName, Translator)
135
140#define XN_DECLARE_STACK_DECL(decl, Type, ClassName) \
141 XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(decl, Type, XN_DEFAULT_TRANSLATOR_NAME(ClassName)) \
142 XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(decl, Type, ClassName, XN_DEFAULT_TRANSLATOR_NAME(ClassName))
143
147#define XN_DECLARE_STACK(Type, ClassName) \
148 XN_DECLARE_STACK_DECL(, Type, ClassName)
149
150
151#endif // _XN_STACK_H
void * XnValue
Definition: XnDataTypes.h:36
XnUInt32 XnStatus
Definition: XnStatus.h:34
Definition: XnList.h:42
XnUInt32 Size() const
Definition: XnList.h:421
XnStatus Remove(ConstIterator where, XnValue &value)
Definition: XnList.h:361
XnStatus AddFirst(const XnValue &value)
Definition: XnList.h:250
Iterator begin()
Definition: XnList.h:433
XnBool IsEmpty() const
Definition: XnList.h:413
Definition: XnStack.h:37
XnStatus Pop(XnValue &value)
Definition: XnStack.h:67
XnStack()
Definition: XnStack.h:42
XnUInt32 Size() const
Definition: XnStack.h:109
XnValue const & Top() const
Definition: XnStack.h:83
XnStatus Push(XnValue const &value)
Definition: XnStack.h:55
~XnStack()
Definition: XnStack.h:46
XnBool IsEmpty() const
Definition: XnStack.h:101
XnValue & Top()
Definition: XnStack.h:93