xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
30 #include "XrdSys/XrdSysPthread.hh"
31 
32 #include <map>
33 #include <string>
34 #include <utility>
35 
36 namespace XrdCl
37 {
38  //----------------------------------------------------------------------------
40  //----------------------------------------------------------------------------
42  {
43  public:
44  //------------------------------------------------------------------------
46  //------------------------------------------------------------------------
47  PlugInManager();
48 
49  //------------------------------------------------------------------------
51  //------------------------------------------------------------------------
53 
54  //------------------------------------------------------------------------
57  //------------------------------------------------------------------------
58  bool RegisterFactory( const std::string &url,
59  PlugInFactory *factory );
60 
61  //------------------------------------------------------------------------
64  //------------------------------------------------------------------------
65  bool RegisterDefaultFactory( PlugInFactory *factory );
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 
123  {
124  FactoryHelper(): plugin(0), factory(0), isEnv(false), counter(0) {}
126  {
127  delete factory;
128  if(plugin) plugin->Unload();
129  delete plugin;
130  }
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;
171  };
172 }
173 
174 #endif // __XRD_CL_PLUGIN_MANAGER__
void ProcessConfigDir(const std::string &dir)
Process the configuration directory and load plug in definitions.
bool isEnv
Definition: XrdClPlugInManager.hh:133
bool RegisterDefaultFactory(PlugInFactory *factory)
PlugInFactory * GetFactory(const std::string url)
void Unload(bool dodel=false)
~PlugInManager()
Destructor.
std::string NormalizeURL(const std::string url)
Normalize a URL.
Definition: XrdClPlugInManager.hh:122
Definition: XrdOucPinLoader.hh:49
XrdOucPinLoader * plugin
Definition: XrdClPlugInManager.hh:131
std::map< std::string, FactoryHelper * > pFactoryMap
Definition: XrdClPlugInManager.hh:168
Manage client-side plug-ins and match them agains URLs.
Definition: XrdClPlugInManager.hh:41
Definition: XrdSysPthread.hh:164
XrdSysMutex pMutex
Definition: XrdClPlugInManager.hh:170
void ProcessEnvironmentSettings()
std::pair< XrdOucPinLoader *, PlugInFactory * > LoadFactory(const std::string &lib, const std::map< std::string, std::string > &config)
Load the plug-in and create the factory.
FactoryHelper * pDefaultFactory
Definition: XrdClPlugInManager.hh:169
void ProcessPlugInConfig(const std::string &confFile)
Process a plug-in config file and load the plug-in if possible.
Plugin factory.
Definition: XrdClPlugInInterface.hh:548
PlugInFactory * factory
Definition: XrdClPlugInManager.hh:132
~FactoryHelper()
Definition: XrdClPlugInManager.hh:125
uint32_t counter
Definition: XrdClPlugInManager.hh:134
PlugInManager()
Constructor.
FactoryHelper()
Definition: XrdClPlugInManager.hh:124
bool RegisterFactory(const std::string &url, PlugInFactory *factory)