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 <set>
34#include <string>
35#include <utility>
36#include <vector>
37
38class PlugInManagerFixture;
39
40namespace XrdCl
41{
42 //----------------------------------------------------------------------------
44 //----------------------------------------------------------------------------
46 {
47 friend class ::PlugInManagerFixture;
48
49 public:
50 //------------------------------------------------------------------------
52 //------------------------------------------------------------------------
54
55 //------------------------------------------------------------------------
57 //------------------------------------------------------------------------
59
60 //------------------------------------------------------------------------
63 //------------------------------------------------------------------------
64 bool RegisterFactory( const std::string &url,
65 PlugInFactory *factory );
66
67 //------------------------------------------------------------------------
70 //------------------------------------------------------------------------
72
73 //------------------------------------------------------------------------
77 //------------------------------------------------------------------------
78 PlugInFactory *GetFactory( const std::string url );
79
80 //------------------------------------------------------------------------
126 //------------------------------------------------------------------------
128
129 private:
130 typedef void *(*PlugInFunc_t)( const void *arg );
131
132 struct FactoryHelper
133 {
134 FactoryHelper(): plugin(0), factory(0), isEnv(false), counter(0) {}
135 ~FactoryHelper()
136 {
137 delete factory;
138 if(plugin) plugin->Unload();
139 delete plugin;
140 }
141 XrdOucPinLoader *plugin;
142 PlugInFactory *factory;
143 bool isEnv;
144 uint32_t counter;
145 };
146
147 //------------------------------------------------------------------------
149 //------------------------------------------------------------------------
150 void ProcessConfigDir( const std::string &dir );
151
152 //------------------------------------------------------------------------
155 //------------------------------------------------------------------------
156 void ProcessConfigDirs( const std::vector<std::string> &dirs );
157
158 //------------------------------------------------------------------------
161 //------------------------------------------------------------------------
162 void ProcessConfigDir( const std::string &dir,
163 std::set<std::string> &settled );
164
165 //------------------------------------------------------------------------
167 //------------------------------------------------------------------------
168 void ProcessPlugInConfig( const std::string &confFile );
169
170 //------------------------------------------------------------------------
173 //------------------------------------------------------------------------
174 void ProcessPlugInConfig( const std::string &confFile,
175 const std::set<std::string> &settled,
176 std::set<std::string> &decided );
177
178 //------------------------------------------------------------------------
180 //------------------------------------------------------------------------
181 std::pair<XrdOucPinLoader*,PlugInFactory*> LoadFactory(
182 const std::string &lib,
183 const std::map<std::string, std::string> &config );
184
185 //------------------------------------------------------------------------
188 //------------------------------------------------------------------------
189 bool RegisterFactory( const std::string &urlString,
190 const std::string &lib,
191 PlugInFactory *factory,
192 XrdOucPinLoader *plugin );
193
194 //------------------------------------------------------------------------
196 //------------------------------------------------------------------------
197 std::string NormalizeURL( const std::string url );
198
199 std::map<std::string, FactoryHelper*> pFactoryMap;
200 FactoryHelper *pDefaultFactory;
201 XrdSysMutex pMutex;
202 };
203}
204
205#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)