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
37#include "XrdSys/XrdSysError.hh"
38
39//------------------------------------------------------------------------------
43//------------------------------------------------------------------------------
44
45class XrdOucEnv;
46struct XrdVersionInfo;
47
48template<class T>
50{
51public:
52
53//------------------------------------------------------------------------------
60//------------------------------------------------------------------------------
61
62void 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
77T *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
105
106private:
107
108const char *Drctv;
111XrdVersionInfo *vInfo;
112
114{
115std::string path;
116std::string parm;
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
125std::vector<pinInfo> pinVec;
126};
127
128
129template<class T>
130T *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
Definition XrdOucEnv.hh:42
Definition XrdOucPinKing.hh:50
std::vector< pinInfo > pinVec
Definition XrdOucPinKing.hh:125
XrdOucEnv & eInfo
Definition XrdOucPinKing.hh:109
const char * Drctv
Definition XrdOucPinKing.hh:108
void Add(const char *path, const char *parms, bool push=false)
Definition XrdOucPinKing.hh:62
T * Load(const char *Symbol)
Definition XrdOucPinKing.hh:130
~XrdOucPinKing()
Definition XrdOucPinKing.hh:104
XrdVersionInfo * vInfo
Definition XrdOucPinKing.hh:111
XrdSysError & eMsg
Definition XrdOucPinKing.hh:110
XrdOucPinKing(const char *drctv, XrdOucEnv &envR, XrdSysError &errR, XrdVersionInfo *vinfo=0)
Definition XrdOucPinKing.hh:91
Definition XrdOucPinLoader.hh:50
Definition XrdOucPinObject.hh:43
virtual T * getInstance(const char *parms, XrdOucEnv &envR, XrdSysLogger &logR, T *prevP)=0
Definition XrdSysError.hh:90
Definition XrdOucPinKing.hh:114
XrdOucPinLoader * pinP
Definition XrdOucPinKing.hh:117
std::string path
Definition XrdOucPinKing.hh:115
std::string parm
Definition XrdOucPinKing.hh:116
~pinInfo()
Definition XrdOucPinKing.hh:122
pinInfo(const char *pth, const char *prm)
Definition XrdOucPinKing.hh:119