Create a poller object, try in order of preference, if none of the poller types is known then return 0
45 {
47
48
49
50
51 typedef std::map<std::string, Poller *(*)()> PollerMap;
52 PollerMap pollerMap;
53 pollerMap["built-in"] = createBuiltIn;
54
55
56
57
58 PollerMap::iterator it;
59 std::string available;
60 for( it = pollerMap.begin(); it != pollerMap.end(); ++it )
61 {
62 available += it->first; available += ", ";
63 }
64 if( !available.empty() )
65 available.erase( available.length()-2, 2 );
66 log->Debug(
PollerMsg,
"Available pollers: %s", available.c_str() );
67
68
69
70
71 if( preference.empty() )
72 {
73 log->Error(
PollerMsg,
"Poller preference list is empty" );
74 return 0;
75 }
76 log->Debug(
PollerMsg,
"Attempting to create a poller according to "
77 "preference: %s", preference.c_str() );
78
79 std::vector<std::string> prefs;
80 std::vector<std::string>::iterator itP;
82 for( itP = prefs.begin(); itP != prefs.end(); ++itP )
83 {
84 it = pollerMap.find( *itP );
85 if( it == pollerMap.end() )
86 {
87 log->Debug(
PollerMsg,
"Unable to create poller: %s",
88 itP->c_str() );
89 continue;
90 }
91 log->Debug(
PollerMsg,
"Creating poller: %s", itP->c_str() );
92 return (*it->second)();
93 }
94
95 return 0;
96 }
static Log * GetLog()
Get default log.
static void splitString(Container &result, const std::string &input, const std::string &delimiter)
Split a string.