Loading...
Searching...
No Matches
XrdCl::PollerFactory Class Reference

Helper for creating poller objects. More...

`#include <XrdClPollerFactory.hh>`

Collaboration diagram for XrdCl::PollerFactory:

## Static Public Member Functions

static Poller * | CreatePoller (const std::string &preference)

## Detailed Description

Helper for creating poller objects.

Definition at line 30 of file XrdClPollerFactory.hh.

## Member Function Documentation

## CreatePoller()

Poller * XrdCl::PollerFactory::CreatePoller | ( | const std::string & | preference | ) |

static

Create a poller object, try in order of preference, if none of the poller types is known then return 0

Parameters

  preference | comma separated list of poller types in order of preference

Returns
  poller object or 0 if non of the poller types is known

Definition at line 44 of file XrdClPollerFactory.cc.

{
Log *log = DefaultEnv::GetLog();
//--------------------------------------------------------------------------
// Create a list of known pollers
//--------------------------------------------------------------------------
typedef std::map<std::string, Poller *(*)()> PollerMap;
PollerMap pollerMap;
pollerMap["built-in"] = createBuiltIn;
//--------------------------------------------------------------------------
// Print the list of available pollers
//--------------------------------------------------------------------------
PollerMap::iterator it;
std::string available;
for( it = pollerMap.begin(); it != pollerMap.end(); ++it )
{
available += it->first; available += ", ";
}
if( !available.empty() )
available.erase( available.length()-2, 2 );
log->Debug( PollerMsg, "Available pollers: %s", available.c_str() );
//--------------------------------------------------------------------------
// Try to create a poller
//--------------------------------------------------------------------------
if( preference.empty() )
{
log->Error( PollerMsg, "Poller preference list is empty" );
return 0;
}
log->Debug( PollerMsg, "Attempting to create a poller according to "
"preference: %s", preference.c_str() );
std::vector<std::string> prefs;
std::vector<std::string>::iterator itP;
Utils::splitString( prefs, preference, "," );
for( itP = prefs.begin(); itP != prefs.end(); ++itP )
{
it = pollerMap.find( *itP );
if( it == pollerMap.end() )
{
log->Debug( PollerMsg, "Unable to create poller: %s",
itP->c_str() );
continue;
}
log->Debug( PollerMsg, "Creating poller: %s", itP->c_str() );
return (*it->second)();
}
return 0;
}
XrdCl::DefaultEnv::GetLog
static Log * GetLog()
Get default log.
Definition XrdClDefaultEnv.cc:493
XrdCl::Utils::splitString
static void splitString(Container &result, const std::string &input, const std::string &delimiter)
Split a string.
Definition XrdClUtils.hh:56
XrdCl::PollerMsg
const uint64_t PollerMsg
Definition XrdClConstants.hh:35
XrdGlobal::Log
XrdSysError Log
Definition XrdConfig.cc:113

References XrdCl::Log::Debug(), XrdCl::Log::Error(), XrdCl::DefaultEnv::GetLog(), XrdCl::PollerMsg, and XrdCl::Utils::splitString().

Referenced by XrdCl::PostMaster::Initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files:

- XrdClPollerFactory.hh
- XrdClPollerFactory.cc