XRootD
Loading...
Searching...
No Matches
XrdOucPinKing.hh
Go to the documentation of this file.
1
#ifndef __XRDOUCPINKING_HH__
2
#define __XRDOUCPINKING_HH__
3
/******************************************************************************/
4
/* */
5
/* X r d O u c P i n K i n g . h h */
6
/* */
7
/* (c) 2020 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
#include <string>
33
#include <vector>
34
35
#include "
XrdOuc/XrdOucPinLoader.hh
"
36
#include "
XrdOuc/XrdOucPinObject.hh
"
37
#include "
XrdSys/XrdSysError.hh
"
38
39
//------------------------------------------------------------------------------
43
//------------------------------------------------------------------------------
44
45
class
XrdOucEnv
;
46
struct
XrdVersionInfo;
47
48
template
<
class
T>
49
class
XrdOucPinKing
50
{
51
public
:
52
53
//------------------------------------------------------------------------------
60
//------------------------------------------------------------------------------
61
62
void
Add
(
const
char
*path,
63
const
char
*parms,
64
bool
push=
false
)
65
{
if
(push) pinVec.push_back(pinInfo(path, parms));
66
else
pinVec[0] = pinInfo(path, parms);
67
}
68
69
//------------------------------------------------------------------------------
75
//------------------------------------------------------------------------------
76
77
T *
Load
(
const
char
*Symbol);
78
79
//------------------------------------------------------------------------------
89
//------------------------------------------------------------------------------
90
91
XrdOucPinKing
(
const
char
*drctv,
92
XrdOucEnv
&envR,
93
XrdSysError
&errR,
94
XrdVersionInfo *vinfo=0)
95
: Drctv(drctv), eInfo(envR), eMsg(errR), vInfo(vinfo)
96
{pinVec.push_back(pinInfo(0,0));}
97
98
//------------------------------------------------------------------------------
102
//------------------------------------------------------------------------------
103
104
~XrdOucPinKing
() {}
105
106
private
:
107
108
const
char
*Drctv;
109
XrdOucEnv
&eInfo;
110
XrdSysError
&
eMsg
;
111
XrdVersionInfo *vInfo;
112
113
struct
pinInfo
114
{
115
std::string path;
116
std::string parm;
117
XrdOucPinLoader
*pinP;
118
119
pinInfo(
const
char
*pth,
const
char
*prm)
120
: path(pth ? pth :
""
), parm(prm ? prm :
""
), pinP(0) {}
121
122
~pinInfo() {
delete
pinP;}
123
};
124
125
std::vector<pinInfo> pinVec;
126
};
127
128
129
template
<
class
T>
130
T *
XrdOucPinKing<T>::Load
(
const
char
*Symbol)
131
{
132
XrdOucPinObject<T>
*objPIN;
133
T *lastPIN = 0;
134
typename
std::vector<pinInfo>::iterator it;
135
136
for
(it = pinVec.begin(); it != pinVec.end(); it++)
137
{
if
(it->path.size() == 0)
continue
;
138
it->pinP =
new
XrdOucPinLoader
(&eMsg, vInfo, Drctv, it->path.c_str());
139
objPIN = (
XrdOucPinObject<T>
*)(it->pinP->Resolve(Symbol));
140
if
(!objPIN
141
|| !(lastPIN = objPIN->
getInstance
(it->parm.c_str(), eInfo,
142
*(eMsg.logger()), lastPIN)))
143
return
0;
144
}
145
return
lastPIN;
146
}
147
#endif
XrdOucPinLoader.hh
XrdOucPinObject.hh
eMsg
#define eMsg(x)
Definition
XrdSecsssAdmin.cc:53
XrdSysError.hh
XrdOucEnv
Definition
XrdOucEnv.hh:42
XrdOucPinKing::Add
void Add(const char *path, const char *parms, bool push=false)
Definition
XrdOucPinKing.hh:62
XrdOucPinKing::Load
T * Load(const char *Symbol)
Definition
XrdOucPinKing.hh:130
XrdOucPinKing::~XrdOucPinKing
~XrdOucPinKing()
Definition
XrdOucPinKing.hh:104
XrdOucPinKing::XrdOucPinKing
XrdOucPinKing(const char *drctv, XrdOucEnv &envR, XrdSysError &errR, XrdVersionInfo *vinfo=0)
Definition
XrdOucPinKing.hh:91
XrdOucPinLoader
Definition
XrdOucPinLoader.hh:50
XrdOucPinObject
Definition
XrdOucPinObject.hh:43
XrdOucPinObject::getInstance
virtual T * getInstance(const char *parms, XrdOucEnv &envR, XrdSysLogger &logR, T *prevP)=0
XrdSysError
Definition
XrdSysError.hh:90
XrdOuc
XrdOucPinKing.hh
Generated by
1.13.1