* If the given ApplyRule targets only specific parent objects, add it to the respective "index". * * - The above means for apply T "N" to Host: assign where host.name == "H" [ || host.name == "h" ... ] * - For apply T "N" to Service it means: assign where host.name == "H" && service.name == "S" [ || host.name == "h" && service.name == "s" ... ] * * The order of operands of || && == doesn't ma
| 62 | * @returns Whether the rule has been added to the "index". |
| 63 | */ |
| 64 | bool ApplyRule::AddTargetedRule(const ApplyRule::Ptr& rule, const String& targetType, ApplyRule::PerSourceType& rules) |
| 65 | { |
| 66 | if (targetType == "Host") { |
| 67 | std::vector<const String *> hosts; |
| 68 | |
| 69 | if (GetTargetHosts(rule->m_Filter.get(), hosts)) { |
| 70 | for (auto host : hosts) { |
| 71 | rules.Targeted[*host].ForHost.emplace(rule); |
| 72 | } |
| 73 | |
| 74 | return true; |
| 75 | } |
| 76 | } else if (targetType == "Service") { |
| 77 | std::vector<std::pair<const String *, const String *>> services; |
| 78 | |
| 79 | if (GetTargetServices(rule->m_Filter.get(), services)) { |
| 80 | for (auto service : services) { |
| 81 | rules.Targeted[*service.first].ForServices[*service.second].emplace(rule); |
| 82 | } |
| 83 | |
| 84 | return true; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | return false; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * If the given assign filter is like the following, extract the host names ("H", "h", ...) into the vector: |