XrdCmsPList.hh

Go to the documentation of this file.
00001 #ifndef XRDCMSPLIST__H
00002 #define XRDCMSPLIST__H
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                        X r d C m s P L i s t . h h                         */
00006 /*                                                                            */
00007 /* (c) 2007 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-AC02-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012 
00013 //         $Id: XrdCmsPList.hh 35287 2010-09-14 21:19:35Z ganis $
00014 
00015 #include <string.h>
00016 #include <strings.h>
00017 #include <stdlib.h>
00018 
00019 #include "XrdCms/XrdCmsTypes.hh"
00020 #include "XrdSys/XrdSysPthread.hh"
00021   
00022 /******************************************************************************/
00023 /*                     C l a s s   X r d C m s P I n f o                      */
00024 /******************************************************************************/
00025   
00026 class XrdCmsPInfo
00027 {
00028 public:
00029    SMask_t rovec;
00030    SMask_t rwvec;
00031    SMask_t ssvec;
00032 
00033 inline int  And(const SMask_t mask)
00034                {return ((rovec &= mask)|(rwvec &= mask)|(ssvec &= mask)) != 0;}
00035 
00036 inline void Or(const XrdCmsPInfo *pi)
00037                {rovec |=  pi->rovec; rwvec |=  pi->rwvec; ssvec |=  pi->ssvec;}
00038 
00039 inline void Set(const XrdCmsPInfo *pi)
00040                {rovec  =  pi->rovec; rwvec  =  pi->rwvec; ssvec  =  pi->ssvec;}
00041 
00042            XrdCmsPInfo() {rovec = rwvec = ssvec = 0;}
00043           ~XrdCmsPInfo() {}
00044            XrdCmsPInfo   &operator =(const XrdCmsPInfo &rhs)
00045                         {Set(&rhs); return *this;}
00046 };
00047  
00048 /******************************************************************************/
00049 /*                     C l a s s   X r d C m s P L i s t                      */
00050 /******************************************************************************/
00051   
00052 class XrdCmsPList
00053 {
00054 public:
00055 friend class XrdCmsPList_Anchor;
00056 
00057 inline XrdCmsPList   *Next() {return next;}
00058 inline char          *Path() {return pathname;}
00059 const  char          *PType();
00060 
00061        XrdCmsPList(const char *pname="", XrdCmsPInfo *pi=0)
00062                   : next(0), pathname(strdup(pname)), pathlen(strlen(pname)),
00063                     pathtype(0) {if (pi) pathmask.Set(pi);}
00064 
00065       ~XrdCmsPList() {if (pathname) free(pathname);}
00066 
00067 private:
00068 
00069 XrdCmsPInfo     pathmask;
00070 XrdCmsPList    *next;
00071 char           *pathname;
00072 int             pathlen;
00073 char            pathtype;
00074 char            reserved[3];
00075 };
00076 
00077 class XrdCmsPList_Anchor
00078 {
00079 public:
00080 
00081 inline void         Lock() {mutex.Lock();}
00082 inline void       UnLock() {mutex.UnLock();}
00083 
00084        int          Add(const char *pname, XrdCmsPInfo *pinfo);
00085 
00086 inline void         Empty(XrdCmsPList *newlist=0)
00087                     {Lock();
00088                      XrdCmsPList *p = next;
00089                      while(p) {next = p->next; delete p; p = next;}
00090                      next = newlist;
00091                      UnLock();
00092                     }
00093 
00094        int          Find(const char *pname, XrdCmsPInfo &masks);
00095 
00096 inline XrdCmsPList *First() {return next;}
00097 
00098        SMask_t      Insert(const char *pname, XrdCmsPInfo *pinfo);
00099 
00100 inline int          NotEmpty() {return next != 0;}
00101 
00102        void         Remove(SMask_t mask);
00103 
00104 const  char        *Type(const char *pname);
00105 
00106 inline XrdCmsPList *Zorch(XrdCmsPList *newlist=0)
00107                    {Lock();
00108                     XrdCmsPList *p = next;
00109                     next = newlist;
00110                     UnLock();
00111                     return p;
00112                    }
00113 
00114        XrdCmsPList_Anchor() {next = 0;}
00115 
00116       ~XrdCmsPList_Anchor() {Empty();}
00117 
00118 private:
00119 
00120 XrdSysMutex   mutex;
00121 XrdCmsPList  *next;
00122 };
00123 #endif

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