xrootd
Loading...
Searching...
No Matches
XrdOucNList.hh
Go to the documentation of this file.
1#ifndef __OOUC_NLIST__
2#define __OOUC_NLIST__
3/******************************************************************************/
4/* */
5/* X r d O u c N L i s t . h h */
6/* */
7/* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* Produced by Andrew Hanushevsky for Stanford University under contract */
9/* DE-AC02-76-SFO0515 with the Department of Energy */
10/* */
11/* This file is part of the XRootD software suite. */
12/* */
13/* XRootD is free software: you can redistribute it and/or modify it under */
14/* the terms of the GNU Lesser General Public License as published by the */
15/* Free Software Foundation, either version 3 of the License, or (at your */
16/* option) any later version. */
17/* */
18/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21/* License for more details. */
22/* */
23/* You should have received a copy of the GNU Lesser General Public License */
24/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26/* */
27/* The copyright holder's institutional names and contributor's names may not */
28/* be used to endorse or promote products derived from this software without */
29/* specific prior written permission of the institution or contributor. */
30/******************************************************************************/
31
32#ifndef WIN32
33#include <strings.h>
34#else
35#include "XrdSys/XrdWin32.hh"
36#endif
37#include <cstdlib>
39
41{
42public:
43
44inline int Flag() {return flags;}
45inline XrdOucNList *Next() {return next;}
46
47 int NameKO(const char *pd, const int pl);
48inline int NameKO(const char *pd)
49 {return NameKO(pd, strlen(pd));}
50
51 int NameOK(const char *pd, const int pl);
52inline int NameOK(const char *pd)
53 {return NameOK(pd, strlen(pd));}
54
55inline void Set(int fval) {flags = fval;}
56
57 XrdOucNList(const char *name="", int nvals=0);
58
60 {if (nameL) free(nameL);}
61
62friend class XrdOucNList_Anchor;
63
64private:
65
68char *nameL;
70char *nameR;
72};
73
75{
76public:
77
78inline void Lock() {mutex.Lock();}
79inline void UnLock() {mutex.UnLock();}
80
81inline void Empty(XrdOucNList *newlist=0)
82 {Lock();
83 XrdOucNList *p = next;
84 while(p) {next = p->next; delete p; p = next;}
85 next = newlist;
86 UnLock();
87 }
88
89inline XrdOucNList *Find(const char *name)
90 {int nlen = strlen(name);
91 Lock();
92 XrdOucNList *p = next;
93 while(p) {if (p->NameOK(name, nlen)) break;
94 p=p->next;
95 }
96 UnLock();
97 return p;
98 }
99
100inline XrdOucNList *First() {return next;}
101
102inline void Insert(XrdOucNList *newitem)
103 {Lock();
104 newitem->next = next; next = newitem;
105 UnLock();
106 }
107
108inline int NotEmpty() {return next != 0;}
109
111 {XrdOucNList *np;
112 Lock();
113 if ((np = next)) next = np->next;
114 UnLock();
115 return np;
116 }
117
118 void Replace(const char *name, int nval);
119
120 void Replace(XrdOucNList *item);
121
122 // Warning: You must manually lock the object before swap
123inline void Swap(XrdOucNList_Anchor &other)
124 {XrdOucNList *savenext = next;
125 next = other.First();
126 other.Zorch(savenext);
127 }
128
129inline void Zorch(XrdOucNList *newnext=0) {next = newnext;}
130
131private:
132
134};
135#endif
Definition XrdOucNList.hh:75
int NotEmpty()
Definition XrdOucNList.hh:108
XrdOucNList * First()
Definition XrdOucNList.hh:100
void Empty(XrdOucNList *newlist=0)
Definition XrdOucNList.hh:81
XrdSysMutex mutex
Definition XrdOucNList.hh:133
void Zorch(XrdOucNList *newnext=0)
Definition XrdOucNList.hh:129
void Swap(XrdOucNList_Anchor &other)
Definition XrdOucNList.hh:123
XrdOucNList * Pop()
Definition XrdOucNList.hh:110
void Replace(XrdOucNList *item)
void Insert(XrdOucNList *newitem)
Definition XrdOucNList.hh:102
void UnLock()
Definition XrdOucNList.hh:79
void Lock()
Definition XrdOucNList.hh:78
void Replace(const char *name, int nval)
XrdOucNList * Find(const char *name)
Definition XrdOucNList.hh:89
Definition XrdOucNList.hh:41
char * nameR
Definition XrdOucNList.hh:70
int NameKO(const char *pd, const int pl)
int namelenL
Definition XrdOucNList.hh:67
XrdOucNList * Next()
Definition XrdOucNList.hh:45
int flags
Definition XrdOucNList.hh:71
int namelenR
Definition XrdOucNList.hh:69
XrdOucNList * next
Definition XrdOucNList.hh:66
int NameOK(const char *pd, const int pl)
XrdOucNList(const char *name="", int nvals=0)
int NameKO(const char *pd)
Definition XrdOucNList.hh:48
char * nameL
Definition XrdOucNList.hh:68
int Flag()
Definition XrdOucNList.hh:44
void Set(int fval)
Definition XrdOucNList.hh:55
~XrdOucNList()
Definition XrdOucNList.hh:59
int NameOK(const char *pd)
Definition XrdOucNList.hh:52
Definition XrdSysPthread.hh:165
void Lock()
Definition XrdSysPthread.hh:222
void UnLock()
Definition XrdSysPthread.hh:224