xrootd
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>
35 {
36 public:
39  XrdOucQSItem(T *item) {dataitem = item; nextelem = 0;}
41 };
42 
43 template<class T>
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 
61 
62 private:
64 };
65 
66 template<class T>
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 
82  if (!(qp = anchor)) return (T *)0;
83  if (!(anchor = anchor->nextelem)) lastelem = 0;
84  return qp->dataitem;
85  }
86 
89 
90 private:
93 };
94 #endif
~XrdOucStack()
Definition: XrdOucChain.hh:60
XrdOucQSItem< T > * nextelem
Definition: XrdOucChain.hh:37
void Add(XrdOucQSItem< T > *item)
Definition: XrdOucChain.hh:71
XrdOucQSItem< T > * anchor
Definition: XrdOucChain.hh:63
XrdOucStack()
Definition: XrdOucChain.hh:59
T * Pop()
Definition: XrdOucChain.hh:50
T * Remove()
Definition: XrdOucChain.hh:81
XrdOucQueue()
Definition: XrdOucChain.hh:87
int isEmpty()
Definition: XrdOucChain.hh:79
Definition: XrdOucChain.hh:34
T * dataitem
Definition: XrdOucChain.hh:38
int isEmpty()
Definition: XrdOucChain.hh:48
Definition: XrdOucChain.hh:44
Definition: XrdOucChain.hh:67
void Push(XrdOucQSItem< T > *item)
Definition: XrdOucChain.hh:57
~XrdOucQSItem()
Definition: XrdOucChain.hh:40
XrdOucQSItem< T > * lastelem
Definition: XrdOucChain.hh:92
XrdOucQSItem< T > * anchor
Definition: XrdOucChain.hh:91
~XrdOucQueue()
Definition: XrdOucChain.hh:88
XrdOucQSItem(T *item)
Definition: XrdOucChain.hh:39