xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdOuc
XrdOucChain.hh
Go to the documentation of this file.
1
#ifndef __OUC_CHAIN__
2
#define __OUC_CHAIN__
3
/******************************************************************************/
4
/* */
5
/* X r d O u c C h a i n . h h */
6
/* */
7
/* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University */
8
/* All Rights Reserved */
9
/* Produced by Andrew Hanushevsky for Stanford University under contract */
10
/* DE-AC02-76-SFO0515 with the Department of Energy */
11
/* */
12
/* This file is part of the XRootD software suite. */
13
/* */
14
/* XRootD is free software: you can redistribute it and/or modify it under */
15
/* the terms of the GNU Lesser General Public License as published by the */
16
/* Free Software Foundation, either version 3 of the License, or (at your */
17
/* option) any later version. */
18
/* */
19
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22
/* License for more details. */
23
/* */
24
/* You should have received a copy of the GNU Lesser General Public License */
25
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27
/* */
28
/* The copyright holder's institutional names and contributor's names may not */
29
/* be used to endorse or promote products derived from this software without */
30
/* specific prior written permission of the institution or contributor. */
31
/******************************************************************************/
32
33
template
<
class
T>
34
class
XrdOucQSItem
35
{
36
public
:
37
XrdOucQSItem<T>
*
nextelem
;
38
T *
dataitem
;
39
XrdOucQSItem
(T *item) {
dataitem
= item;
nextelem
= 0;}
40
~XrdOucQSItem
() {}
41
};
42
43
template
<
class
T>
44
class
XrdOucStack
45
{
46
public
:
47
48
int
isEmpty
() {
return
anchor
== 0;}
49
50
T *
Pop
() {
XrdOucQSItem<T>
*cp;
51
if
(!(cp =
anchor
))
return
(T *)0;
52
anchor
=
anchor
->nextelem;
53
cp->
nextelem
= 0;
54
return
cp->
dataitem
;
55
}
56
57
void
Push
(
XrdOucQSItem<T>
*item) {item->
nextelem
=
anchor
;
anchor
= item;}
58
59
XrdOucStack
() {
anchor
= 0;}
60
~XrdOucStack
() {}
61
62
private
:
63
XrdOucQSItem<T>
*
anchor
;
64
};
65
66
template
<
class
T>
67
class
XrdOucQueue
68
{
69
public
:
70
71
void
Add
(
XrdOucQSItem<T>
*item)
72
{item->
nextelem
= 0;
73
if
(
lastelem
) {
lastelem
->nextelem = item;
74
lastelem
= item;
75
}
76
else
anchor
=
lastelem
= item;
77
}
78
79
int
isEmpty
() {
return
anchor
== 0;}
80
81
T *
Remove
() {
XrdOucQSItem<T>
*qp;
82
if
(!(qp =
anchor
))
return
(T *)0;
83
if
(!(
anchor
=
anchor
->nextelem))
lastelem
= 0;
84
return
qp->
dataitem
;
85
}
86
87
XrdOucQueue
() {
anchor
=
lastelem
= 0;}
88
~XrdOucQueue
() {}
89
90
private
:
91
XrdOucQSItem<T>
*
anchor
;
92
XrdOucQSItem<T>
*
lastelem
;
93
};
94
#endif
Generated by
1.8.3.1