Loading...
Searching...
No Matches
XrdClPlugInManager.hh
Go to the documentation of this file.
//------------------------------------------------------------------------------
// Copyright (c) 2014 by European Organization for Nuclear Research (CERN)
// Author: Lukasz Janyst <ljanyst@cern.ch>
//------------------------------------------------------------------------------
// This file is part of the XRootD software suite.
//
// XRootD is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// XRootD is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
//
// In applying this licence, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
//------------------------------------------------------------------------------
#ifndef __XRD_CL_PLUGIN_MANAGER__
#define __XRD_CL_PLUGIN_MANAGER__
#include "XrdCl/XrdClPlugInInterface.hh"
#include "XrdOuc/XrdOucPinLoader.hh"
#include "XrdSys/XrdSysPthread.hh"
#include <map>
#include <string>
#include <utility>
namespace XrdCl
{
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
class PlugInManager
{
public:
//------------------------------------------------------------------------
//------------------------------------------------------------------------
PlugInManager();
//------------------------------------------------------------------------
//------------------------------------------------------------------------
~PlugInManager();
//------------------------------------------------------------------------
//------------------------------------------------------------------------
bool RegisterFactory( const std::string &url,
PlugInFactory *factory );
//------------------------------------------------------------------------
//------------------------------------------------------------------------
bool RegisterDefaultFactory( PlugInFactory *factory );
//------------------------------------------------------------------------
//------------------------------------------------------------------------
PlugInFactory *GetFactory( const std::string url );
//------------------------------------------------------------------------
//------------------------------------------------------------------------
void ProcessEnvironmentSettings();
private:
typedef void *(*PlugInFunc_t)( const void *arg );
struct FactoryHelper
{
FactoryHelper(): plugin(0), factory(0), isEnv(false), counter(0) {}
~FactoryHelper()
{
delete factory;
if(plugin) plugin->Unload();
delete plugin;
}
XrdOucPinLoader *plugin;
PlugInFactory *factory;
bool isEnv;
uint32_t counter;
};
//------------------------------------------------------------------------
//------------------------------------------------------------------------
void ProcessConfigDir( const std::string &dir );
//------------------------------------------------------------------------
//------------------------------------------------------------------------
void ProcessPlugInConfig( const std::string &confFile );
//------------------------------------------------------------------------
//------------------------------------------------------------------------
std::pair<XrdOucPinLoader*,PlugInFactory*> LoadFactory(
const std::string &lib,
const std::map<std::string, std::string> &config );
//------------------------------------------------------------------------
//------------------------------------------------------------------------
bool RegisterFactory( const std::string &urlString,
const std::string &lib,
PlugInFactory *factory,
XrdOucPinLoader *plugin );
//------------------------------------------------------------------------
//------------------------------------------------------------------------
std::string NormalizeURL( const std::string url );
std::map<std::string, FactoryHelper*> pFactoryMap;
FactoryHelper *pDefaultFactory;
XrdSysMutex pMutex;
};
}
#endif // __XRD_CL_PLUGIN_MANAGER__
XrdClPlugInInterface.hh
XrdOucPinLoader.hh
XrdSysPthread.hh
XrdCl::PlugInFactory
Plugin factory.
Definition XrdClPlugInInterface.hh:549
XrdCl::PlugInManager::ProcessEnvironmentSettings
void ProcessEnvironmentSettings()
Definition XrdClPlugInManager.cc:186
XrdCl::PlugInManager::RegisterFactory
bool RegisterFactory(const std::string &url, PlugInFactory *factory)
Definition XrdClPlugInManager.cc:75
XrdCl::PlugInManager::PlugInManager
PlugInManager()
Constructor.
Definition XrdClPlugInManager.cc:51
XrdCl::PlugInManager::RegisterDefaultFactory
bool RegisterDefaultFactory(PlugInFactory *factory)
Register a plug-in factory applying to all URLs.
Definition XrdClPlugInManager.cc:119
XrdCl::PlugInManager::~PlugInManager
~PlugInManager()
Destructor.
Definition XrdClPlugInManager.cc:59
XrdCl::PlugInManager::GetFactory
PlugInFactory * GetFactory(const std::string url)
Definition XrdClPlugInManager.cc:145
XrdOucPinLoader
Definition XrdOucPinLoader.hh:50
XrdOucPinLoader::Unload
void Unload(bool dodel=false)
Definition XrdOucPinLoader.cc:305
XrdSysMutex
Definition XrdSysPthread.hh:165
XrdCl
Definition XrdClAction.hh:34