icinga2/icinga/icingaapplication.cpp

55 lines
1.4 KiB
C++
Raw Normal View History

2012-03-31 16:29:53 +02:00
#include <cstdio>
#include <iostream>
#include "i2-icinga.h"
using namespace icinga;
using std::cout;
using std::endl;
IcingaApplication::IcingaApplication(void)
{
m_ConnectionManager = new_object<ConnectionManager>();
}
int IcingaApplication::Main(const vector<string>& args)
{
GetConfigHive()->OnObjectCreated.bind(bind_weak(&IcingaApplication::ConfigObjectCreatedHandler, shared_from_this()));
GetConfigHive()->OnObjectRemoved.bind(bind_weak(&IcingaApplication::ConfigObjectRemovedHandler, shared_from_this()));
2012-03-31 16:29:53 +02:00
ConfigObject::RefType fileComponentConfig = new_object<ConfigObject>();
fileComponentConfig->SetName("configfilecomponent");
fileComponentConfig->SetType("component");
fileComponentConfig->SetProperty("filename", "icinga.conf");
GetConfigHive()->AddObject(fileComponentConfig);
RunEventLoop();
return 0;
}
ConnectionManager::RefType IcingaApplication::GetConnectionManager(void)
{
return m_ConnectionManager;
}
int IcingaApplication::ConfigObjectCreatedHandler(ConfigHiveEventArgs::RefType ea)
{
if (ea->ConfigObject->GetType() == "component") {
LoadComponent(ea->ConfigObject->GetName());
}
return 0;
}
int IcingaApplication::ConfigObjectRemovedHandler(ConfigHiveEventArgs::RefType ea)
{
if (ea->ConfigObject->GetType() == "component") {
UnloadComponent(ea->ConfigObject->GetName());
}
return 0;
}
2012-03-31 16:29:53 +02:00
SET_START_CLASS(icinga::IcingaApplication);