diff --git a/lib/config/applyrule-targeted.cpp b/lib/config/applyrule-targeted.cpp index 8a4b2fd45..210c67764 100644 --- a/lib/config/applyrule-targeted.cpp +++ b/lib/config/applyrule-targeted.cpp @@ -11,7 +11,7 @@ using namespace icinga; /** * @returns All ApplyRules targeting only specific parent objects including the given host. (See AddTargetedRule().) */ -const std::vector& ApplyRule::GetTargetedHostRules(const Type::Ptr& sourceType, const String& host) +const std::set& ApplyRule::GetTargetedHostRules(const Type::Ptr& sourceType, const String& host) { auto perSourceType (m_Rules.find(sourceType.get())); @@ -23,14 +23,14 @@ const std::vector& ApplyRule::GetTargetedHostRules(const Type::P } } - static const std::vector noRules; + static const std::set noRules; return noRules; } /** * @returns All ApplyRules targeting only specific parent objects including the given service. (See AddTargetedRule().) */ -const std::vector& ApplyRule::GetTargetedServiceRules(const Type::Ptr& sourceType, const String& host, const String& service) +const std::set& ApplyRule::GetTargetedServiceRules(const Type::Ptr& sourceType, const String& host, const String& service) { auto perSourceType (m_Rules.find(sourceType.get())); @@ -46,7 +46,7 @@ const std::vector& ApplyRule::GetTargetedServiceRules(const Type } } - static const std::vector noRules; + static const std::set noRules; return noRules; } @@ -67,7 +67,7 @@ bool ApplyRule::AddTargetedRule(const ApplyRule::Ptr& rule, const String& target if (GetTargetHosts(rule->m_Filter.get(), hosts)) { for (auto host : hosts) { - rules.Targeted[*host].ForHost.emplace_back(rule); + rules.Targeted[*host].ForHost.emplace(rule); } return true; @@ -77,7 +77,7 @@ bool ApplyRule::AddTargetedRule(const ApplyRule::Ptr& rule, const String& target if (GetTargetServices(rule->m_Filter.get(), services)) { for (auto service : services) { - rules.Targeted[*service.first].ForServices[*service.second].emplace_back(rule); + rules.Targeted[*service.first].ForServices[*service.second].emplace(rule); } return true; diff --git a/lib/config/applyrule.hpp b/lib/config/applyrule.hpp index 3756ede52..6b6fca8f8 100644 --- a/lib/config/applyrule.hpp +++ b/lib/config/applyrule.hpp @@ -23,8 +23,8 @@ public: struct PerHost { - std::vector ForHost; - std::unordered_map> ForServices; + std::set ForHost; + std::unordered_map> ForServices; }; struct PerSourceType @@ -36,13 +36,13 @@ public: /* * m_Rules[T::TypeInstance.get()].Targeted["H"].ForHost * contains all apply rules like apply T "x" to Host { ... } - * which target only specific hosts incl. "H", e. g. via + * which target only specific hosts incl. "H", e.g. via * assign where host.name == "H" || host.name == "h". * * m_Rules[T::TypeInstance.get()].Targeted["H"].ForServices["S"] * contains all apply rules like apply T "x" to Service { ... } - * which target only specific services on specific hosts incl. "H!S", - * e. g. via assign where host.name == "H" && service.name == "S". + * which target only specific services on specific hosts, + * e.g. via assign where host.name == "H" && service.name == "S". * * m_Rules[T::TypeInstance.get()].Regular[C::TypeInstance.get()] * contains all other apply rules like apply T "x" to C { ... }. @@ -70,8 +70,8 @@ public: const Expression::Ptr& filter, const String& package, const String& fkvar, const String& fvvar, const Expression::Ptr& fterm, bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope); static const std::vector& GetRules(const Type::Ptr& sourceType, const Type::Ptr& targetType); - static const std::vector& GetTargetedHostRules(const Type::Ptr& sourceType, const String& host); - static const std::vector& GetTargetedServiceRules(const Type::Ptr& sourceType, const String& host, const String& service); + static const std::set& GetTargetedHostRules(const Type::Ptr& sourceType, const String& host); + static const std::set& GetTargetedServiceRules(const Type::Ptr& sourceType, const String& host, const String& service); static void RegisterType(const String& sourceType, const std::vector& targetTypes); static bool IsValidSourceType(const String& sourceType);