OpenNI 1.5.7
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
Include
XnStackT.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_T_H_
22
#define _XN_STACK_T_H_
23
24
//---------------------------------------------------------------------------
25
// Includes
26
//---------------------------------------------------------------------------
27
#include "
XnListT.h
"
28
29
//---------------------------------------------------------------------------
30
// Code
31
//---------------------------------------------------------------------------
32
template
<
class
T,
class
TAlloc = XnLinkedNodeDefaultAllocatorT<T> >
33
class
XnStackT
:
protected
XnListT
<T, TAlloc>
34
{
35
public
:
36
typedef
XnListT<T, TAlloc>
Base
;
37
38
typedef
typename
Base::ConstIterator
ConstIterator
;
39
40
XnStackT
() :
Base
() {}
41
42
XnStackT
(
const
XnStackT
& other) :
Base
()
43
{
44
*
this
= other;
45
}
46
47
XnStackT
&
operator=
(
const
XnStackT
& other)
48
{
49
Base::operator=
(other);
50
// no other members
51
return
*
this
;
52
}
53
54
~XnStackT
() {}
55
56
XnBool
IsEmpty
()
const
{
return
Base::IsEmpty
(); }
57
58
XnStatus
Push
(T
const
& value) {
return
Base::AddFirst
(value); }
59
60
XnStatus
Pop
(T& value)
61
{
62
ConstIterator
it =
Begin
();
63
if
(it ==
End
())
64
{
65
return
XN_STATUS_IS_EMPTY;
66
}
67
value = *it;
68
return
Base::Remove
(it);
69
}
70
71
T
const
&
Top
()
const
{
return
*
Begin
(); }
72
T&
Top
() {
return
*
Begin
(); }
73
74
ConstIterator
Begin
()
const
{
return
Base::Begin
(); }
75
ConstIterator
End
()
const
{
return
Base::End
(); }
76
};
77
78
#endif // _XN_STACK_T_H_
Generated on Tue Nov 12 2013 13:40:20 for OpenNI 1.5.7 by
1.8.3.1