add GetChildHosts() to host object

This commit is contained in:
Michael Friedrich 2013-07-19 16:11:17 +02:00
parent 669e3764bd
commit f0f3412f2c
2 changed files with 24 additions and 0 deletions

View File

@ -461,6 +461,29 @@ std::set<Host::Ptr> Host::GetParentHosts(void) const
return parents;
}
std::set<Host::Ptr> Host::GetChildHosts(void) const
{
std::set<Host::Ptr> childs;
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("Host")) {
const Host::Ptr& host = static_pointer_cast<Host>(object);
Array::Ptr dependencies = host->GetHostDependencies();
if (dependencies) {
ObjectLock olock(dependencies);
BOOST_FOREACH(const Value& value, dependencies) {
if (value == GetName())
childs.insert(host);
}
}
}
return childs;
}
Service::Ptr Host::GetHostCheckService(void) const
{
String host_check = GetHostCheck();

View File

@ -94,6 +94,7 @@ public:
shared_ptr<Service> GetHostCheckService(void) const;
std::set<Host::Ptr> GetParentHosts(void) const;
std::set<Host::Ptr> GetChildHosts(void) const;
std::set<shared_ptr<Service> > GetParentServices(void) const;
bool IsReachable() const;