00001 #ifndef __SUT_BUCKLIST_H__ 00002 #define __SUT_BUCKLIST_H__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d S u t B u c k L i s t . h h */ 00006 /* */ 00007 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* Produced by Gerri Ganis for CERN */ 00009 /* */ 00010 /* This file is part of the XRootD software suite. */ 00011 /* */ 00012 /* XRootD is free software: you can redistribute it and/or modify it under */ 00013 /* the terms of the GNU Lesser General Public License as published by the */ 00014 /* Free Software Foundation, either version 3 of the License, or (at your */ 00015 /* option) any later version. */ 00016 /* */ 00017 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00018 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00019 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00020 /* License for more details. */ 00021 /* */ 00022 /* You should have received a copy of the GNU Lesser General Public License */ 00023 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00024 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00025 /* */ 00026 /* The copyright holder's institutional names and contributor's names may not */ 00027 /* be used to endorse or promote products derived from this software without */ 00028 /* specific prior written permission of the institution or contributor. */ 00029 /******************************************************************************/ 00030 00031 #ifndef __SUT_BUCKET_H__ 00032 #include "XrdSut/XrdSutBucket.hh" 00033 #endif 00034 00035 /******************************************************************************/ 00036 /* */ 00037 /* Light single-linked list for managing buckets inside the exchanged */ 00038 /* buffer */ 00039 /* */ 00040 /******************************************************************************/ 00041 00042 // 00043 // Node definition 00044 // 00045 class XrdSutBuckListNode { 00046 private: 00047 XrdSutBucket *buck; 00048 XrdSutBuckListNode *next; 00049 public: 00050 XrdSutBuckListNode(XrdSutBucket *b = 0, XrdSutBuckListNode *n = 0) 00051 { buck = b; next = n;} 00052 virtual ~XrdSutBuckListNode() { } 00053 00054 XrdSutBucket *Buck() const { return buck; } 00055 00056 XrdSutBuckListNode *Next() const { return next; } 00057 00058 void SetNext(XrdSutBuckListNode *n) { next = n; } 00059 }; 00060 00061 class XrdSutBuckList { 00062 00063 private: 00064 XrdSutBuckListNode *begin; 00065 XrdSutBuckListNode *current; 00066 XrdSutBuckListNode *end; 00067 XrdSutBuckListNode *previous; 00068 int size; 00069 00070 XrdSutBuckListNode *Find(XrdSutBucket *b); 00071 00072 public: 00073 XrdSutBuckList(XrdSutBucket *b = 0); 00074 virtual ~XrdSutBuckList(); 00075 00076 // Access information 00077 int Size() const { return size; } 00078 XrdSutBucket *End() const { return end->Buck(); } 00079 00080 // Modifiers 00081 void PutInFront(XrdSutBucket *b); 00082 void PushBack(XrdSutBucket *b); 00083 void Remove(XrdSutBucket *b); 00084 00085 // Pseudo - iterator functionality 00086 XrdSutBucket *Begin(); 00087 XrdSutBucket *Next(); 00088 }; 00089 00090 #endif 00091