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 GetFilter(void) const;
43 DebugInfo GetDebugInfo(void) const;
44 Object::Ptr GetScope(void) const;
46 bool EvaluateFilter(const Object::Ptr& scope) const;
48 static void AddRule(const String& sourceType, const String& name,
49 const Expression::Ptr& filter, const DebugInfo& di, const Object::Ptr& scope);
50 static void EvaluateRules(bool clear);
52 static void RegisterType(const String& sourceType, const ObjectRule::Callback& callback);
53 static bool IsValidSourceType(const String& sourceType);
57 Expression::Ptr m_Filter;
58 DebugInfo m_DebugInfo;
61 static CallbackMap m_Callbacks;
62 static RuleMap m_Rules;
64 ObjectRule(const String& name, const Expression::Ptr& filter,
65 const DebugInfo& di, const Object::Ptr& scope);
70 #endif /* OBJECTRULE_H */