mirror of
https://github.com/Icinga/icinga2.git
synced 2025-09-25 02:37:44 +02:00
parent
a65f2d6b41
commit
74618c6598
@ -11,9 +11,9 @@ ApplyRule::RuleMap ApplyRule::m_Rules;
|
||||
ApplyRule::TypeMap ApplyRule::m_Types;
|
||||
|
||||
ApplyRule::ApplyRule(String name, Expression::Ptr expression,
|
||||
Expression::Ptr filter, String package, String fkvar, String fvvar, Expression::Ptr fterm,
|
||||
Expression::Ptr filter, String zone, String package, String fkvar, String fvvar, Expression::Ptr fterm,
|
||||
bool ignoreOnError, DebugInfo di, Dictionary::Ptr scope)
|
||||
: m_Name(std::move(name)), m_Expression(std::move(expression)), m_Filter(std::move(filter)), m_Package(std::move(package)), m_FKVar(std::move(fkvar)),
|
||||
: m_Name(std::move(name)), m_Expression(std::move(expression)), m_Filter(std::move(filter)), m_Zone(std::move(zone)), m_Package(std::move(package)), m_FKVar(std::move(fkvar)),
|
||||
m_FVVar(std::move(fvvar)), m_FTerm(std::move(fterm)), m_IgnoreOnError(ignoreOnError), m_DebugInfo(std::move(di)), m_Scope(std::move(scope)), m_HasMatches(false)
|
||||
{ }
|
||||
|
||||
@ -32,6 +32,11 @@ Expression::Ptr ApplyRule::GetFilter() const
|
||||
return m_Filter;
|
||||
}
|
||||
|
||||
String ApplyRule::GetZone() const
|
||||
{
|
||||
return m_Zone;
|
||||
}
|
||||
|
||||
String ApplyRule::GetPackage() const
|
||||
{
|
||||
return m_Package;
|
||||
@ -58,7 +63,7 @@ Dictionary::Ptr ApplyRule::GetScope() const
|
||||
}
|
||||
|
||||
void ApplyRule::AddRule(const String& sourceType, const String& targetType, const String& name,
|
||||
const Expression::Ptr& expression, const Expression::Ptr& filter, const String& package, const String& fkvar,
|
||||
const Expression::Ptr& expression, const Expression::Ptr& filter, const String& zone, const String& package, const String& fkvar,
|
||||
const String& fvvar, const Expression::Ptr& fterm, bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope)
|
||||
{
|
||||
auto actualTargetType (&targetType);
|
||||
@ -71,7 +76,7 @@ void ApplyRule::AddRule(const String& sourceType, const String& targetType, cons
|
||||
}
|
||||
}
|
||||
|
||||
ApplyRule::Ptr rule = new ApplyRule(name, expression, filter, package, fkvar, fvvar, fterm, ignoreOnError, di, scope);
|
||||
ApplyRule::Ptr rule = new ApplyRule(name, expression, filter, zone, package, fkvar, fvvar, fterm, ignoreOnError, di, scope);
|
||||
auto& rules (m_Rules[Type::GetByName(sourceType).get()]);
|
||||
|
||||
if (!AddTargetedRule(rule, *actualTargetType, rules)) {
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
String GetName() const;
|
||||
Expression::Ptr GetExpression() const;
|
||||
Expression::Ptr GetFilter() const;
|
||||
String GetZone() const;
|
||||
String GetPackage() const;
|
||||
|
||||
inline const String& GetFKVar() const noexcept
|
||||
@ -77,7 +78,7 @@ public:
|
||||
bool EvaluateFilter(ScriptFrame& frame) const;
|
||||
|
||||
static void AddRule(const String& sourceType, const String& targetType, const String& name, const Expression::Ptr& expression,
|
||||
const Expression::Ptr& filter, const String& package, const String& fkvar, const String& fvvar, const Expression::Ptr& fterm,
|
||||
const Expression::Ptr& filter, const String& zone, 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<ApplyRule::Ptr>& GetRules(const Type::Ptr& sourceType, const Type::Ptr& targetType);
|
||||
static const std::set<ApplyRule::Ptr>& GetTargetedHostRules(const Type::Ptr& sourceType, const String& host);
|
||||
@ -97,6 +98,7 @@ private:
|
||||
String m_Name;
|
||||
Expression::Ptr m_Expression;
|
||||
Expression::Ptr m_Filter;
|
||||
String m_Zone;
|
||||
String m_Package;
|
||||
String m_FKVar;
|
||||
String m_FVVar;
|
||||
@ -117,7 +119,7 @@ private:
|
||||
static const Value * GetConst(Expression* exp, const Dictionary::Ptr& constants);
|
||||
|
||||
ApplyRule(String name, Expression::Ptr expression,
|
||||
Expression::Ptr filter, String package, String fkvar, String fvvar, Expression::Ptr fterm,
|
||||
Expression::Ptr filter, String zone, String package, String fkvar, String fvvar, Expression::Ptr fterm,
|
||||
bool ignoreOnError, DebugInfo di, Dictionary::Ptr scope);
|
||||
};
|
||||
|
||||
|
@ -1221,7 +1221,7 @@ apply:
|
||||
std::unique_ptr<Expression> fterm{context->m_FTerm.top()};
|
||||
context->m_FTerm.pop();
|
||||
|
||||
$$ = new ApplyExpression(std::move(type), std::move(target), std::unique_ptr<Expression>($4), std::move(filter), context->GetPackage(), std::move(fkvar), std::move(fvvar), std::move(fterm), std::move(*$7), $8, std::unique_ptr<Expression>($10), DebugInfoRange(@2, @8));
|
||||
$$ = new ApplyExpression(std::move(type), std::move(target), std::unique_ptr<Expression>($4), std::move(filter), context->GetZone(), context->GetPackage(), std::move(fkvar), std::move(fvvar), std::move(fterm), std::move(*$7), $8, std::unique_ptr<Expression>($10), DebugInfoRange(@2, @8));
|
||||
delete $7;
|
||||
}
|
||||
;
|
||||
|
@ -915,7 +915,7 @@ ExpressionResult ApplyExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhin
|
||||
ExpressionResult nameres = m_Name->Evaluate(frame);
|
||||
CHECK_RESULT(nameres);
|
||||
|
||||
return VMOps::NewApply(frame, m_Type, m_Target, nameres.GetValue(), m_Filter,
|
||||
return VMOps::NewApply(frame, m_Type, m_Target, nameres.GetValue(), m_Filter, m_Zone,
|
||||
m_Package, m_FKVar, m_FVVar, m_FTerm, m_ClosedVars, m_IgnoreOnError, m_Expression, m_DebugInfo);
|
||||
}
|
||||
|
||||
|
@ -830,11 +830,11 @@ class ApplyExpression final : public DebuggableExpression
|
||||
{
|
||||
public:
|
||||
ApplyExpression(String type, String target, std::unique_ptr<Expression> name,
|
||||
std::unique_ptr<Expression> filter, String package, String fkvar, String fvvar,
|
||||
std::unique_ptr<Expression> filter, String zone, String package, String fkvar, String fvvar,
|
||||
std::unique_ptr<Expression> fterm, std::map<String, std::unique_ptr<Expression> >&& closedVars, bool ignoreOnError,
|
||||
std::unique_ptr<Expression> expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
: DebuggableExpression(debugInfo), m_Type(std::move(type)), m_Target(std::move(target)),
|
||||
m_Name(std::move(name)), m_Filter(filter.release()), m_Package(std::move(package)), m_FKVar(std::move(fkvar)), m_FVVar(std::move(fvvar)),
|
||||
m_Name(std::move(name)), m_Filter(filter.release()), m_Zone(std::move(zone)), m_Package(std::move(package)), m_FKVar(std::move(fkvar)), m_FVVar(std::move(fvvar)),
|
||||
m_FTerm(fterm.release()), m_IgnoreOnError(ignoreOnError), m_ClosedVars(std::move(closedVars)),
|
||||
m_Expression(expression.release())
|
||||
{ }
|
||||
@ -847,6 +847,7 @@ private:
|
||||
String m_Target;
|
||||
std::unique_ptr<Expression> m_Name;
|
||||
Expression::Ptr m_Filter;
|
||||
String m_Zone;
|
||||
String m_Package;
|
||||
String m_FKVar;
|
||||
String m_FVVar;
|
||||
|
@ -115,11 +115,11 @@ public:
|
||||
return new Function(name, wrapper, argNames);
|
||||
}
|
||||
|
||||
static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const Expression::Ptr& filter,
|
||||
static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const Expression::Ptr& filter, const String& zone,
|
||||
const String& package, const String& fkvar, const String& fvvar, const Expression::Ptr& fterm, const std::map<String, std::unique_ptr<Expression> >& closedVars,
|
||||
bool ignoreOnError, const Expression::Ptr& expression, const DebugInfo& debugInfo = DebugInfo())
|
||||
{
|
||||
ApplyRule::AddRule(type, target, name, expression, filter, package, fkvar,
|
||||
ApplyRule::AddRule(type, target, name, expression, filter, zone, package, fkvar,
|
||||
fvvar, fterm, ignoreOnError, debugInfo, EvaluateClosedVars(frame, closedVars));
|
||||
|
||||
return Empty;
|
||||
|
Loading…
x
Reference in New Issue
Block a user