XrdOucPList.hh

Go to the documentation of this file.
00001 #ifndef __OUC_PLIST__
00002 #define __OUC_PLIST__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                        X r d O u c P L i s t . h h                         */
00006 /*                                                                            */
00007 /* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*                            All Rights Reserved                             */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC03-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012 
00013 //         $Id: XrdOucPList.hh 32231 2010-02-05 18:24:46Z ganis $
00014 
00015 #include <strings.h>
00016 #include <stdlib.h>
00017   
00018 class XrdOucPList
00019 {
00020 public:
00021 
00022 inline unsigned long long  Flag() {return flags;}
00023 inline XrdOucPList        *Next() {return next;}
00024 inline char               *Path() {return path;}
00025 inline int                 Plen() {return pathlen;}
00026 
00027 inline int          PathOK(const char *pd, const int pl)
00028                           {return pl >= pathlen && !strncmp(pd, path, pathlen);}
00029 
00030 inline void         Set(unsigned long long fval) {flags = fval;}
00031 
00032              XrdOucPList(const char *pd="", unsigned long long fv=0)
00033                         : flags(fv), next(0),  path(strdup(pd)),
00034                           pathlen(strlen(pd)), reserved(0) {}
00035             ~XrdOucPList()
00036                   {if (path) free(path);}
00037 
00038 friend class XrdOucPListAnchor;
00039 
00040 private:
00041 
00042 unsigned long long flags;
00043 XrdOucPList       *next;
00044 char              *path;
00045 int                pathlen;
00046 int                reserved;
00047 };
00048 
00049 class XrdOucPListAnchor : public XrdOucPList
00050 {
00051 public:
00052 
00053 inline void        Default(unsigned long long x) {dflts = x;}
00054 
00055 inline void        Empty(XrdOucPList *newlist=0)
00056                    {XrdOucPList *p = next;
00057                     while(p) {next = p->next; delete p; p = next;}
00058                     next = newlist;
00059                    }
00060 
00061 inline unsigned long long  Find(const char *pathname)
00062                    {int plen = strlen(pathname); 
00063                     XrdOucPList *p = next;
00064                     while(p) {if (p->PathOK(pathname, plen)) break;
00065                               p=p->next;
00066                              }
00067                     return (p ? p->flags : dflts);
00068                    }
00069 
00070 inline XrdOucPList *Match(const char *pathname)
00071                    {int plen = strlen(pathname); 
00072                     XrdOucPList *p = next;
00073                     while(p) {if (p->pathlen == plen 
00074                               &&  !strcmp(p->path, pathname)) break;
00075                               p=p->next;
00076                              }
00077                     return p;
00078                    }
00079 
00080 inline XrdOucPList *First() {return next;}
00081 
00082 inline void        Insert(XrdOucPList *newitem)
00083                    {XrdOucPList *pp = 0, *cp = next;
00084                     while(cp && newitem->pathlen < cp->pathlen) {pp=cp;cp=cp->next;}
00085                     if (pp) {newitem->next = pp->next; pp->next = newitem;}
00086                        else {newitem->next = next;         next = newitem;}
00087                    }
00088 
00089 inline int         NotEmpty() {return next != 0;}
00090 
00091                    XrdOucPListAnchor(unsigned long long dfx=0) {dflts = dfx;}
00092                   ~XrdOucPListAnchor() {}
00093 
00094 private:
00095 
00096 unsigned long long dflts;
00097 };
00098 #endif

Generated on Tue Jul 5 14:46:50 2011 for ROOT_528-00b_version by  doxygen 1.5.1