MCPcopy Create free account
hub / github.com/Icinga/icinga2 / AddRule

Method AddRule

lib/config/applyrule.cpp:61–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61void ApplyRule::AddRule(const String& sourceType, const String& targetType, const String& name,
62 const Expression::Ptr& expression, const Expression::Ptr& filter, const String& package, const String& fkvar,
63 const String& fvvar, const Expression::Ptr& fterm, bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope)
64{
65 auto actualTargetType (&targetType);
66
67 if (*actualTargetType == "") {
68 auto& targetTypes (GetTargetTypes(sourceType));
69
70 if (targetTypes.size() == 1u) {
71 actualTargetType = &targetTypes[0];
72 }
73 }
74
75 ApplyRule::Ptr rule = new ApplyRule(name, expression, filter, package, fkvar, fvvar, fterm, ignoreOnError, di, scope);
76 auto& rules (m_Rules[Type::GetByName(sourceType).get()]);
77
78 if (!AddTargetedRule(rule, *actualTargetType, rules)) {
79 rules.Regular[Type::GetByName(*actualTargetType).get()].emplace_back(std::move(rule));
80 }
81}
82
83bool ApplyRule::EvaluateFilter(ScriptFrame& frame) const
84{

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected