mirror of https://github.com/Icinga/icinga2.git
23 lines
501 B
C++
23 lines
501 B
C++
|
#include "i2-icinga.h"
|
||
|
|
||
|
using namespace icinga;
|
||
|
|
||
|
map<string, CheckTask::Factory> CheckTask::m_Types;
|
||
|
|
||
|
void CheckTask::RegisterType(string type, Factory factory)
|
||
|
{
|
||
|
m_Types[type] = factory;
|
||
|
}
|
||
|
|
||
|
CheckTask::Ptr CheckTask::CreateTask(const Service& service)
|
||
|
{
|
||
|
map<string, CheckTask::Factory>::iterator it;
|
||
|
|
||
|
it = m_Types.find(service.GetCheckType());
|
||
|
|
||
|
if (it == m_Types.end())
|
||
|
throw runtime_error("Invalid check type specified for service '" + service.GetName() + "'");
|
||
|
|
||
|
return it->second(service);
|
||
|
}
|