1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
6 #include "config/i2-config.hpp"
7 #include "config/expression.hpp"
8 #include "base/debuginfo.hpp"
19 typedef std::map<String, std::vector<String> > TypeMap;
20 typedef std::map<String, std::vector<ApplyRule> > RuleMap;
22 String GetTargetType() const;
23 String GetName() const;
24 std::shared_ptr<Expression> GetExpression() const;
25 std::shared_ptr<Expression> GetFilter() const;
26 String GetPackage() const;
27 String GetFKVar() const;
28 String GetFVVar() const;
29 std::shared_ptr<Expression> GetFTerm() const;
30 bool GetIgnoreOnError() const;
31 DebugInfo GetDebugInfo() const;
32 Dictionary::Ptr GetScope() const;
34 bool HasMatches() const;
36 bool EvaluateFilter(ScriptFrame& frame) const;
38 static void AddRule(const String& sourceType, const String& targetType, const String& name, const std::shared_ptr<Expression>& expression,
39 const std::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr<Expression>& fterm,
40 bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope);
41 static std::vector<ApplyRule>& GetRules(const String& type);
43 static void RegisterType(const String& sourceType, const std::vector<String>& targetTypes);
44 static bool IsValidSourceType(const String& sourceType);
45 static bool IsValidTargetType(const String& sourceType, const String& targetType);
46 static std::vector<String> GetTargetTypes(const String& sourceType);
48 static void CheckMatches(bool silent);
53 std::shared_ptr<Expression> m_Expression;
54 std::shared_ptr<Expression> m_Filter;
58 std::shared_ptr<Expression> m_FTerm;
60 DebugInfo m_DebugInfo;
61 Dictionary::Ptr m_Scope;
64 static TypeMap m_Types;
65 static RuleMap m_Rules;
67 ApplyRule(String targetType, String name, std::shared_ptr<Expression> expression,
68 std::shared_ptr<Expression> filter, String package, String fkvar, String fvvar, std::shared_ptr<Expression> fterm,
69 bool ignoreOnError, DebugInfo di, Dictionary::Ptr scope);
74 #endif /* APPLYRULE_H */