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 //---------------------------------------------------------------------------
35 class XnStack
36 {
37 public:
41  XnStack() {}
45  ~XnStack() {}
46 
54  XnStatus Push(XnValue const& value)
55  {
56  return m_List.AddFirst(value);
57  }
58 
66  XnStatus Pop(XnValue& value)
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 
92  XnValue& Top()
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 
113 private:
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
XnList::Remove
XnStatus Remove(ConstIterator where, XnValue &value)
Definition: XnList.h:377
XnStack::Pop
XnStatus Pop(XnValue &value)
Definition: XnStack.h:83
XnStack
Definition: XnStack.h:34
XnList.h
XnStatus
XnUInt32 XnStatus
Definition: XnStatus.h:32
XnStack::Size
XnUInt32 Size() const
Definition: XnStack.h:125
XnList::begin
Iterator begin()
Definition: XnList.h:449
XnList::IsEmpty
XnBool IsEmpty() const
Definition: XnList.h:429
XnStack::IsEmpty
XnBool IsEmpty() const
Definition: XnStack.h:117
XnStack::~XnStack
~XnStack()
Definition: XnStack.h:62
XnList::AddFirst
XnStatus AddFirst(const XnValue &value)
Definition: XnList.h:266
XnStack::XnStack
XnStack()
Definition: XnStack.h:58
XnStack::Push
XnStatus Push(XnValue const &value)
Definition: XnStack.h:71
XnList
Definition: XnList.h:39
XnList::Size
XnUInt32 Size() const
Definition: XnList.h:437
XnStack::Top
XnValue const & Top() const
Definition: XnStack.h:99
XnValue
void * XnValue
Definition: XnDataTypes.h:35