mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 21:55:03 +02:00
Checkable: Extract parents directly from dependency groups
This commit is contained in:
parent
806fff950c
commit
8640a3f84e
@ -250,12 +250,8 @@ bool Checkable::AffectsChildren() const
|
||||
std::set<Checkable::Ptr> Checkable::GetParents() const
|
||||
{
|
||||
std::set<Checkable::Ptr> parents;
|
||||
|
||||
for (const Dependency::Ptr& dep : GetDependencies()) {
|
||||
Checkable::Ptr parent = dep->GetParent();
|
||||
|
||||
if (parent && parent.get() != this)
|
||||
parents.insert(parent);
|
||||
for (auto& dependencyGroup : GetDependencyGroups()) {
|
||||
dependencyGroup->LoadParents(parents);
|
||||
}
|
||||
|
||||
return parents;
|
||||
|
@ -133,6 +133,20 @@ std::vector<Dependency::Ptr> DependencyGroup::GetDependenciesForChild(const Chec
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all parent Checkables of the current dependency group.
|
||||
*
|
||||
* @param parents The set to load the parent Checkables into.
|
||||
*/
|
||||
void DependencyGroup::LoadParents(std::set<Checkable::Ptr>& parents) const
|
||||
{
|
||||
std::lock_guard lock(m_Mutex);
|
||||
for (auto& [compositeKey, children] : m_Members) {
|
||||
ASSERT(!children.empty()); // We should never have an empty map for any given key at any given time.
|
||||
parents.insert(std::get<0>(compositeKey));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the number of dependency objects in the current dependency group.
|
||||
*
|
||||
|
@ -155,6 +155,7 @@ public:
|
||||
void AddDependency(const Dependency::Ptr& dependency);
|
||||
void RemoveDependency(const Dependency::Ptr& dependency);
|
||||
std::vector<Dependency::Ptr> GetDependenciesForChild(const Checkable* child) const;
|
||||
void LoadParents(std::set<Checkable::Ptr>& parents) const;
|
||||
size_t GetDependenciesCount() const;
|
||||
|
||||
void SetIcingaDBIdentifier(const String& identifier);
|
||||
|
Loading…
x
Reference in New Issue
Block a user