XRootD
Loading...
Searching...
No Matches
XrdClPlugInManager.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// Copyright (c) 2014 by European Organization for Nuclear Research (CERN)
3// Author: Lukasz Janyst <ljanyst@cern.ch>
4//------------------------------------------------------------------------------
5// This file is part of the XRootD software suite.
6//
7// XRootD is free software: you can redistribute it and/or modify
8// it under the terms of the GNU Lesser General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// XRootD is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU Lesser General Public License
18// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19//
20// In applying this licence, CERN does not waive the privileges and immunities
21// granted to it by virtue of its status as an Intergovernmental Organization
22// or submit itself to any jurisdiction.
23//------------------------------------------------------------------------------
24
25#ifndef __XRD_CL_PLUGIN_MANAGER__
26#define __XRD_CL_PLUGIN_MANAGER__
27
31
32#include <map>
33#include <string>
34#include <utility>
35
36namespace XrdCl
37{
38 //----------------------------------------------------------------------------
40 //----------------------------------------------------------------------------
42 {
43 public:
44 //------------------------------------------------------------------------
46 //------------------------------------------------------------------------
48
49 //------------------------------------------------------------------------
51 //------------------------------------------------------------------------
53
54 //------------------------------------------------------------------------
57 //------------------------------------------------------------------------
58 bool RegisterFactory( const std::string &url,
59 PlugInFactory *factory );
60
61 //------------------------------------------------------------------------
64 //------------------------------------------------------------------------
66
67 //------------------------------------------------------------------------
71 //------------------------------------------------------------------------
72 PlugInFactory *GetFactory( const std::string url );
73
74 //------------------------------------------------------------------------
116 //------------------------------------------------------------------------
118
119 private:
120 typedef void *(*PlugInFunc_t)( const void *arg );
121
122 struct FactoryHelper
123 {
124 FactoryHelper(): plugin(0), factory(0), isEnv(false), counter(0) {}
125 ~FactoryHelper()
126 {
127 delete factory;
128 if(plugin) plugin->Unload();
129 delete plugin;
130 }
131 XrdOucPinLoader *plugin;
132 PlugInFactory *factory;
133 bool isEnv;
134 uint32_t counter;
135 };
136
137 //------------------------------------------------------------------------
139 //------------------------------------------------------------------------
140 void ProcessConfigDir( const std::string &dir );
141
142 //------------------------------------------------------------------------
144 //------------------------------------------------------------------------
145 void ProcessPlugInConfig( const std::string &confFile );
146
147 //------------------------------------------------------------------------
149 //------------------------------------------------------------------------
150 std::pair<XrdOucPinLoader*,PlugInFactory*> LoadFactory(
151 const std::string &lib,
152 const std::map<std::string, std::string> &config );
153
154 //------------------------------------------------------------------------
157 //------------------------------------------------------------------------
158 bool RegisterFactory( const std::string &urlString,
159 const std::string &lib,
160 PlugInFactory *factory,
161 XrdOucPinLoader *plugin );
162
163 //------------------------------------------------------------------------
165 //------------------------------------------------------------------------
166 std::string NormalizeURL( const std::string url );
167
168 std::map<std::string, FactoryHelper*> pFactoryMap;
169 FactoryHelper *pDefaultFactory;
170 XrdSysMutex pMutex;
171 };
172}
173
174#endif // __XRD_CL_PLUGIN_MANAGER__
bool RegisterFactory(const std::string &url, PlugInFactory *factory)
bool RegisterDefaultFactory(PlugInFactory *factory)
Register a plug-in factory applying to all URLs.
PlugInFactory * GetFactory(const std::string url)
void Unload(bool dodel=false)