xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdCms
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 <string.h>
34
#include <strings.h>
35
#include <stdlib.h>
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
44
class
XrdCmsPInfo
45
{
46
public
:
47
SMask_t
rovec
;
48
SMask_t
rwvec
;
49
SMask_t
ssvec
;
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
60
XrdCmsPInfo
() {
rovec
=
rwvec
=
ssvec
= 0;}
61
~XrdCmsPInfo
() {}
62
XrdCmsPInfo
&
operator =
(
const
XrdCmsPInfo
&rhs)
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
70
class
XrdCmsPList
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
95
class
XrdCmsPList_Anchor
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
134
~XrdCmsPList_Anchor
() {
Empty
();}
135
136
private
:
137
138
XrdSysMutex
mutex
;
139
XrdCmsPList
*
next
;
140
};
141
#endif
Generated by
1.8.3.1