XRootD
XrdClTransportManager.cc
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2012 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // XRootD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // XRootD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17 //------------------------------------------------------------------------------
18 
21 
22 namespace XrdCl
23 {
24  //----------------------------------------------------------------------------
25  // Constructor
26  //----------------------------------------------------------------------------
28  {
29  pHandlers["root"] = new XRootDTransport();
30  pHandlers["xroot"] = new XRootDTransport();
31  pHandlers["roots"] = new XRootDTransport();
32  pHandlers["xroots"] = new XRootDTransport();
33  }
34 
35  //----------------------------------------------------------------------------
36  // Destructor
37  //----------------------------------------------------------------------------
39  {
40  HandlerMap::iterator it;
41  for( it = pHandlers.begin(); it != pHandlers.end(); ++it )
42  delete it->second;
43  }
44 
45  //----------------------------------------------------------------------------
46  // Register a transport factory function for a given protocol
47  //----------------------------------------------------------------------------
48  bool TransportManager::RegisterFactory( const std::string &protocol,
49  TransportFactory factory )
50  {
51  FactoryMap::iterator it = pFactories.find( protocol );
52  if( it == pFactories.end() )
53  return false;
54  pFactories[protocol] = factory;
55  return true;
56  }
57 
58  //----------------------------------------------------------------------------
59  // Get a transport handler object for a given protocol
60  //----------------------------------------------------------------------------
61  TransportHandler *TransportManager::GetHandler( const std::string &protocol )
62  {
63  HandlerMap::iterator itH = pHandlers.find( protocol );
64  if( itH != pHandlers.end() )
65  return itH->second;
66 
67  FactoryMap::iterator itF = pFactories.find( protocol );
68  if( itF == pFactories.end() )
69  return 0;
70 
71  TransportHandler *handler = (*itF->second)();
72  pHandlers[protocol] = handler;
73  return handler;
74  }
75 }
Perform the handshake and the authentication for each physical stream.
bool RegisterFactory(const std::string &protocol, TransportFactory factory)
Register a transport factory function for a given protocol.
TransportHandler * GetHandler(const std::string &protocol)
Get a transport handler object for a given protocol.
XRootD transport handler.