OpenNI 1.5.7
XnStack.h
Go to the documentation of this file.
1/*****************************************************************************
2* *
3* OpenNI 1.x Alpha *
4* Copyright (C) 2012 PrimeSense Ltd. *
5* *
6* This file is part of OpenNI. *
7* *
8* Licensed under the Apache License, Version 2.0 (the "License"); *
9* you may not use this file except in compliance with the License. *
10* You may obtain a copy of the License at *
11* *
12* http://www.apache.org/licenses/LICENSE-2.0 *
13* *
14* Unless required by applicable law or agreed to in writing, software *
15* distributed under the License is distributed on an "AS IS" BASIS, *
16* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
17* See the License for the specific language governing permissions and *
18* limitations under the License. *
19* *
20*****************************************************************************/
21#ifndef _XN_STACK_H
22#define _XN_STACK_H
23
24//---------------------------------------------------------------------------
25// Includes
26//---------------------------------------------------------------------------
27#include "XnList.h"
28
29//---------------------------------------------------------------------------
30// Types
31//---------------------------------------------------------------------------
36{
37public:
46
54 XnStatus Push(XnValue const& value)
55 {
56 return m_List.AddFirst(value);
57 }
58
67 {
68 if (IsEmpty())
69 {
70 return XN_STATUS_IS_EMPTY;
71 }
72
73 value = *(m_List.begin());
74 return m_List.Remove(m_List.begin());
75 }
76
82 XnValue const& Top() const
83 {
84 return *(m_List.begin());
85 }
86
93 {
94 return *(m_List.begin());
95 }
96
100 XnBool IsEmpty() const
101 {
102 return m_List.IsEmpty();
103 }
104
108 XnUInt32 Size() const
109 {
110 return m_List.Size();
111 }
112
113private:
114 XN_DISABLE_COPY_AND_ASSIGN(XnStack);
115
117 XnList m_List;
118};
119
124#define XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(decl, Type, ClassName, Translator) \
125 /* Note: we use queue declaration, as this is the same interface. */ \
126 XN_DECLARE_QUEUE_WITH_TRANSLATOR_DECL(decl, Type, ClassName, Translator, XnStack)
127
132#define XN_DECLARE_STACK_WITH_TRANSLATOR(Type, ClassName, Translator) \
133 XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(, ClassName, Translator)
134
139#define XN_DECLARE_STACK_DECL(decl, Type, ClassName) \
140 XN_DECLARE_DEFAULT_VALUE_TRANSLATOR_DECL(decl, Type, XN_DEFAULT_TRANSLATOR_NAME(ClassName)) \
141 XN_DECLARE_STACK_WITH_TRANSLATOR_DECL(decl, Type, ClassName, XN_DEFAULT_TRANSLATOR_NAME(ClassName))
142
146#define XN_DECLARE_STACK(Type, ClassName) \
147 XN_DECLARE_STACK_DECL(, Type, ClassName)
148
149
150#endif // _XN_STACK_H
void * XnValue
Definition: XnDataTypes.h:35
XnUInt32 XnStatus
Definition: XnStatus.h:33
Definition: XnList.h:41
XnUInt32 Size() const
Definition: XnList.h:420
XnStatus Remove(ConstIterator where, XnValue &value)
Definition: XnList.h:360
XnStatus AddFirst(const XnValue &value)
Definition: XnList.h:249
Iterator begin()
Definition: XnList.h:432
XnBool IsEmpty() const
Definition: XnList.h:412
Definition: XnStack.h:36
XnStatus Pop(XnValue &value)
Definition: XnStack.h:66
XnStack()
Definition: XnStack.h:41
XnUInt32 Size() const
Definition: XnStack.h:108
XnValue const & Top() const
Definition: XnStack.h:82
XnStatus Push(XnValue const &value)
Definition: XnStack.h:54
~XnStack()
Definition: XnStack.h:45
XnBool IsEmpty() const
Definition: XnStack.h:100
XnValue & Top()
Definition: XnStack.h:92