]> granicus.if.org Git - icinga2/blob - lib/config/objectrule.hpp
Remove unused fields from the ObjectRule class
[icinga2] / lib / config / objectrule.hpp
1 /******************************************************************************
2  * Icinga 2                                                                   *
3  * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org)    *
4  *                                                                            *
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.                     *
9  *                                                                            *
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.                               *
14  *                                                                            *
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  ******************************************************************************/
19
20 #ifndef OBJECTRULE_H
21 #define OBJECTRULE_H
22
23 #include "config/i2-config.hpp"
24 #include "config/expression.hpp"
25 #include "base/debuginfo.hpp"
26 #include "base/dynamictype.hpp"
27
28 namespace icinga
29 {
30
31 /**
32  * @ingroup config
33  */
34 class I2_CONFIG_API ObjectRule
35 {
36 public:
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;
40
41         String GetName(void) const;
42         Expression::Ptr GetFilter(void) const;
43         DebugInfo GetDebugInfo(void) const;
44         Object::Ptr GetScope(void) const;
45
46         bool EvaluateFilter(const Object::Ptr& scope) const;
47
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);
51
52         static void RegisterType(const String& sourceType, const ObjectRule::Callback& callback);
53         static bool IsValidSourceType(const String& sourceType);
54
55 private:
56         String m_Name;
57         Expression::Ptr m_Filter;
58         DebugInfo m_DebugInfo;
59         Object::Ptr m_Scope;
60
61         static CallbackMap m_Callbacks;
62         static RuleMap m_Rules;
63
64         ObjectRule(const String& name, const Expression::Ptr& filter,
65             const DebugInfo& di, const Object::Ptr& scope);
66 };
67
68 }
69
70 #endif /* OBJECTRULE_H */