XRootD
XrdCmsPList.hh
Go to the documentation of this file.
1 #ifndef XRDCMSPLIST__H
2 #define XRDCMSPLIST__H
3 /******************************************************************************/
4 /* */
5 /* X r d C m s P L i s t . h h */
6 /* */
7 /* (c) 2007 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 #include <cstring>
34 #include <strings.h>
35 #include <cstdlib>
36 
37 #include "XrdCms/XrdCmsTypes.hh"
38 #include "XrdSys/XrdSysPthread.hh"
39 
40 /******************************************************************************/
41 /* C l a s s X r d C m s P I n f o */
42 /******************************************************************************/
43 
45 {
46 public:
50 
51 inline int And(const SMask_t mask)
52  {return ((rovec &= mask)|(rwvec &= mask)|(ssvec &= mask)) != 0;}
53 
54 inline void Or(const XrdCmsPInfo *pi)
55  {rovec |= pi->rovec; rwvec |= pi->rwvec; ssvec |= pi->ssvec;}
56 
57 inline void Set(const XrdCmsPInfo *pi)
58  {rovec = pi->rovec; rwvec = pi->rwvec; ssvec = pi->ssvec;}
59 
63  {Set(&rhs); return *this;}
64 };
65 
66 /******************************************************************************/
67 /* C l a s s X r d C m s P L i s t */
68 /******************************************************************************/
69 
71 {
72 public:
73 friend class XrdCmsPList_Anchor;
74 
75 inline XrdCmsPList *Next() {return next;}
76 inline char *Path() {return pathname;}
77 const char *PType();
78 
79  XrdCmsPList(const char *pname="", XrdCmsPInfo *pi=0)
80  : next(0), pathname(strdup(pname)), pathlen(strlen(pname)),
81  pathtype(0) {if (pi) pathmask.Set(pi);}
82 
83  ~XrdCmsPList() {if (pathname) free(pathname);}
84 
85 private:
86 
87 XrdCmsPInfo pathmask;
88 XrdCmsPList *next;
89 char *pathname;
90 int pathlen;
91 char pathtype;
92 char reserved[3];
93 };
94 
96 {
97 public:
98 
99 inline void Lock() {mutex.Lock();}
100 inline void UnLock() {mutex.UnLock();}
101 
102  int Add(const char *pname, XrdCmsPInfo *pinfo);
103 
104 inline void Empty(XrdCmsPList *newlist=0)
105  {Lock();
106  XrdCmsPList *p = next;
107  while(p) {next = p->next; delete p; p = next;}
108  next = newlist;
109  UnLock();
110  }
111 
112  int Find(const char *pname, XrdCmsPInfo &masks);
113 
114 inline XrdCmsPList *First() {return next;}
115 
116  SMask_t Insert(const char *pname, XrdCmsPInfo *pinfo);
117 
118 inline int NotEmpty() {return next != 0;}
119 
120  void Remove(SMask_t mask);
121 
122 const char *Type(const char *pname);
123 
124 inline XrdCmsPList *Zorch(XrdCmsPList *newlist=0)
125  {Lock();
126  XrdCmsPList *p = next;
127  next = newlist;
128  UnLock();
129  return p;
130  }
131 
132  XrdCmsPList_Anchor() {next = 0;}
133 
135 
136 private:
137 
138 XrdSysMutex mutex;
139 XrdCmsPList *next;
140 };
141 #endif
unsigned long long SMask_t
Definition: XrdCmsTypes.hh:33
XrdCmsPInfo & operator=(const XrdCmsPInfo &rhs)
Definition: XrdCmsPList.hh:62
SMask_t ssvec
Definition: XrdCmsPList.hh:49
int And(const SMask_t mask)
Definition: XrdCmsPList.hh:51
SMask_t rovec
Definition: XrdCmsPList.hh:47
SMask_t rwvec
Definition: XrdCmsPList.hh:48
void Set(const XrdCmsPInfo *pi)
Definition: XrdCmsPList.hh:57
void Or(const XrdCmsPInfo *pi)
Definition: XrdCmsPList.hh:54
void Remove(SMask_t mask)
Definition: XrdCmsPList.cc:158
void Empty(XrdCmsPList *newlist=0)
Definition: XrdCmsPList.hh:104
int Find(const char *pname, XrdCmsPInfo &masks)
Definition: XrdCmsPList.cc:77
XrdCmsPList * Zorch(XrdCmsPList *newlist=0)
Definition: XrdCmsPList.hh:124
const char * Type(const char *pname)
Definition: XrdCmsPList.cc:186
int Add(const char *pname, XrdCmsPInfo *pinfo)
Definition: XrdCmsPList.cc:41
SMask_t Insert(const char *pname, XrdCmsPInfo *pinfo)
Definition: XrdCmsPList.cc:102
XrdCmsPList * First()
Definition: XrdCmsPList.hh:114
XrdCmsPList(const char *pname="", XrdCmsPInfo *pi=0)
Definition: XrdCmsPList.hh:79
char * Path()
Definition: XrdCmsPList.hh:76
XrdCmsPList * Next()
Definition: XrdCmsPList.hh:75
const char * PType()
Definition: XrdCmsPList.cc:212