OpenNI 1.5.7
XnQueueT.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_QUEUE_T_H_
22#define _XN_QUEUE_T_H_
23
24//---------------------------------------------------------------------------
25// Includes
26//---------------------------------------------------------------------------
27#include <XnListT.h>
28
29//---------------------------------------------------------------------------
30// Code
31//---------------------------------------------------------------------------
32template<class T, class TAlloc = XnLinkedNodeDefaultAllocatorT<T> >
33class XnQueueT : protected XnListT<T, TAlloc>
34{
35public:
37
38 XnQueueT() : Base() {}
39
40 XnQueueT(const XnQueueT& other) : Base()
41 {
42 *this = other;
43 }
44
46 {
47 Base::operator=(other);
48 // no other members
49 return *this;
50 }
51
53
54 using Base::ConstIterator;
55 using Base::IsEmpty;
56
57 XnStatus Push(T const& value)
58 {
59 return Base::AddLast(value);
60 }
61
62 XnStatus Pop(T& value)
63 {
64 Iterator it = Begin();
65 if (it == End())
66 {
67 return XN_STATUS_IS_EMPTY;
68 }
69 value = *it;
70 return Base::Remove(it);
71 }
72
73 T const& Top() const { return *Begin(); }
74 T& Top() { return *Begin(); }
75
76 using Base::Begin;
77 using Base::End;
78 using Base::Size;
79};
80
81
82
83#endif // _XN_QUEUE_T_H_
XnUInt32 XnStatus
Definition XnStatus.h:33
Definition XnListT.h:188
Definition XnListT.h:85
XnUInt32 Size() const
Definition XnListT.h:510
XnStatus AddLast(T const &value)
Definition XnListT.h:403
XnListT & operator=(const XnListT &other)
Definition XnListT.h:262
Iterator End()
Definition XnListT.h:301
Iterator Begin()
Definition XnListT.h:285
XnStatus Remove(ConstIterator where)
Definition XnListT.h:446
XnBool IsEmpty() const
Definition XnListT.h:502
Definition XnQueueT.h:34
XnStatus Push(T const &value)
Definition XnQueueT.h:57
XnListT< T, TAlloc > Base
Definition XnQueueT.h:36
XnStatus Pop(T &value)
Definition XnQueueT.h:62
XnQueueT & operator=(const XnQueueT &other)
Definition XnQueueT.h:45
XnQueueT(const XnQueueT &other)
Definition XnQueueT.h:40
Iterator End()
Definition XnListT.h:301
Iterator Begin()
Definition XnListT.h:285
~XnQueueT()
Definition XnQueueT.h:52
T const & Top() const
Definition XnQueueT.h:73
T & Top()
Definition XnQueueT.h:74
XnQueueT()
Definition XnQueueT.h:38