1 /******************************************************************************
3 * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
23 #include "config/i2-config.hpp"
24 #include "config/expression.hpp"
25 #include "base/debuginfo.hpp"
26 #include "base/dynamictype.hpp"
34 class I2_CONFIG_API ObjectRule
37 typedef boost::function<void (const std::vector<ObjectRule>& rules)> Callback;
38 typedef std::map<String, Callback> CallbackMap;
39 typedef std::map<String, std::vector<ObjectRule> > RuleMap;
41 String GetName(void) const;
42 Expression::Ptr GetExpression(void) const;
43 Expression::Ptr GetFilter(void) const;
44 DebugInfo GetDebugInfo(void) const;
45 Object::Ptr GetScope(void) const;
47 bool EvaluateFilter(const Object::Ptr& scope) const;
49 static void AddRule(const String& sourceType, const String& name, const Expression::Ptr& expression,
50 const Expression::Ptr& filter, const DebugInfo& di, const Object::Ptr& scope);
51 static void EvaluateRules(bool clear);
53 static void RegisterType(const String& sourceType, const ObjectRule::Callback& callback);
54 static bool IsValidSourceType(const String& sourceType);
58 Expression::Ptr m_Expression;
59 Expression::Ptr m_Filter;
60 DebugInfo m_DebugInfo;
63 static CallbackMap m_Callbacks;
64 static RuleMap m_Rules;
66 ObjectRule(const String& name, const Expression::Ptr& expression,
67 const Expression::Ptr& filter, const DebugInfo& di, const Object::Ptr& scope);
72 #endif /* OBJECTRULE_H */