using namespace icinga;
-map<String, vector<String> > Host::m_ServicesCache;
+map<String, vector<Service::WeakPtr> > Host::m_ServicesCache;
bool Host::m_ServicesCacheValid = true;
static AttributeDescription hostAttributes[] = {
ValidateServicesCache();
- BOOST_FOREACH(const String& svc, m_ServicesCache[GetName()]) {
- if (!Service::Exists(svc))
+ BOOST_FOREACH(const Service::WeakPtr& svc, m_ServicesCache[GetName()]) {
+ Service::Ptr service = svc.lock();
+
+ if (!service)
continue;
- Service::Ptr service = Service::GetByName(svc);
services.insert(service);
}
BOOST_FOREACH(tie(tuples::ignore, object), DynamicType::GetByName("Service")->GetObjects()) {
const Service::Ptr& service = static_pointer_cast<Service>(object);
- m_ServicesCache[service->GetHost()->GetName()].push_back(service->GetName());
+ m_ServicesCache[service->GetHost()->GetName()].push_back(service);
}
m_ServicesCacheValid = true;
private:
static bool m_InitializerDone;
- static map<String, vector<String> > m_ServicesCache;
+ static map<String, vector<weak_ptr<Service> > > m_ServicesCache;
static bool m_ServicesCacheValid;
static void ObjectCommittedHandler(const ConfigItem::Ptr& item);
using namespace icinga;
-map<String, vector<String> > HostGroup::m_MembersCache;
+map<String, vector<Host::WeakPtr> > HostGroup::m_MembersCache;
bool HostGroup::m_MembersCacheValid = true;
static AttributeDescription hostGroupAttributes[] = {
ValidateMembersCache();
- BOOST_FOREACH(const String& hst, m_MembersCache[GetName()]) {
- if (!Host::Exists(hst))
+ BOOST_FOREACH(const Host::WeakPtr& hst, m_MembersCache[GetName()]) {
+ Host::Ptr host = hst.lock();
+
+ if (!host)
continue;
- Host::Ptr host = Host::GetByName(hst);
hosts.insert(host);
}
if (!HostGroup::Exists(hostgroup))
Logger::Write(LogWarning, "icinga", "Host group '" + static_cast<String>(hostgroup) + "' used but not defined.");
- m_MembersCache[hostgroup].push_back(host->GetName());
+ m_MembersCache[hostgroup].push_back(host);
}
}
}
static void InvalidateMembersCache(void);
private:
- static map<String, vector<String> > m_MembersCache;
+ static map<String, vector<weak_ptr<Host> > > m_MembersCache;
static bool m_MembersCacheValid;
static void ValidateMembersCache(void);
using namespace icinga;
-map<String, vector<String> > ServiceGroup::m_MembersCache;
+map<String, vector<Service::WeakPtr> > ServiceGroup::m_MembersCache;
bool ServiceGroup::m_MembersCacheValid;
static AttributeDescription serviceGroupAttributes[] = {
ValidateMembersCache();
- BOOST_FOREACH(const String& svc, m_MembersCache[GetName()]) {
- if (!Service::Exists(svc))
+ BOOST_FOREACH(const Service::WeakPtr& svc, m_MembersCache[GetName()]) {
+ Service::Ptr service = svc.lock();
+
+ if (!service)
continue;
- Service::Ptr service = Service::GetByName(svc);
services.insert(service);
}
if (!ServiceGroup::Exists(servicegroup))
Logger::Write(LogWarning, "icinga", "Service group '" + static_cast<String>(servicegroup) + "' used but not defined.");
- m_MembersCache[servicegroup].push_back(service->GetName());
+ m_MembersCache[servicegroup].push_back(service);
}
}
}
static void InvalidateMembersCache(void);
private:
- static map<String, vector<String> > m_MembersCache;
+ static map<String, vector<weak_ptr<Service> > > m_MembersCache;
static bool m_MembersCacheValid;
static void ValidateMembersCache(void);