Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:27:54

0001 #ifndef __OUC_CHAIN__
0002 #define __OUC_CHAIN__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                        X r d O u c C h a i n . h h                         */
0006 /*                                                                            */
0007 /* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*                            All Rights Reserved                             */
0009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0011 /*                                                                            */
0012 /* This file is part of the XRootD software suite.                            */
0013 /*                                                                            */
0014 /* XRootD is free software: you can redistribute it and/or modify it under    */
0015 /* the terms of the GNU Lesser General Public License as published by the     */
0016 /* Free Software Foundation, either version 3 of the License, or (at your     */
0017 /* option) any later version.                                                 */
0018 /*                                                                            */
0019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0022 /* License for more details.                                                  */
0023 /*                                                                            */
0024 /* You should have received a copy of the GNU Lesser General Public License   */
0025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0027 /*                                                                            */
0028 /* The copyright holder's institutional names and contributor's names may not */
0029 /* be used to endorse or promote products derived from this software without  */
0030 /* specific prior written permission of the institution or contributor.       */
0031 /******************************************************************************/
0032 
0033 template<class T>
0034 class XrdOucQSItem
0035 {
0036 public:
0037 XrdOucQSItem<T>  *nextelem;
0038 T                *dataitem;
0039                   XrdOucQSItem(T *item) {dataitem = item; nextelem = 0;}
0040                  ~XrdOucQSItem()        {}
0041 };
0042   
0043 template<class T>
0044 class XrdOucStack
0045 {
0046 public:
0047 
0048 int    isEmpty() {return anchor == 0;}
0049 
0050 T     *Pop() {XrdOucQSItem<T> *cp;
0051               if (!(cp = anchor)) return (T *)0;
0052               anchor = anchor->nextelem;
0053               cp->nextelem = 0;
0054               return cp->dataitem;
0055              }
0056 
0057 void   Push(XrdOucQSItem<T> *item) {item->nextelem = anchor; anchor = item;}
0058 
0059        XrdOucStack() {anchor = 0;}
0060       ~XrdOucStack() {}
0061 
0062 private:
0063 XrdOucQSItem<T>    *anchor;
0064 };
0065 
0066 template<class T>
0067 class XrdOucQueue
0068 {
0069 public:
0070 
0071 void   Add(XrdOucQSItem<T> *item) 
0072              {item->nextelem = 0;
0073               if (lastelem) {lastelem->nextelem = item;
0074                              lastelem = item;
0075                             }
0076                  else        anchor = lastelem  = item;
0077              }
0078 
0079 int    isEmpty() {return anchor == 0;}
0080 
0081 T     *Remove() {XrdOucQSItem<T> *qp;
0082                  if (!(qp = anchor)) return (T *)0;
0083                  if (!(anchor = anchor->nextelem)) lastelem = 0;
0084                  return qp->dataitem;
0085                 }
0086 
0087        XrdOucQueue() {anchor = lastelem = 0;}
0088       ~XrdOucQueue() {}
0089 
0090 private:
0091 XrdOucQSItem<T> *anchor;
0092 XrdOucQSItem<T> *lastelem;
0093 };
0094 #endif