1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2 
3 #ifndef DBQUERY_H
4 #define DBQUERY_H
5 
6 #include "db_ido/i2-db_ido.hpp"
7 #include "db_ido/dbvalue.hpp"
8 #include "icinga/customvarobject.hpp"
9 #include "base/dictionary.hpp"
10 #include "base/configobject.hpp"
11 
12 namespace icinga
13 {
14 
15 enum DbQueryType
16 {
17 	DbQueryInsert = 1,
18 	DbQueryUpdate = 2,
19 	DbQueryDelete = 4,
20 	DbQueryNewTransaction = 8
21 };
22 
23 enum DbQueryCategory
24 {
25 	DbCatInvalid = 0, //-1 is required for DbCatEverything
26 	DbCatEverything = ~0,
27 
28 	DbCatConfig = 1,
29 	DbCatState = 2,
30 	DbCatAcknowledgement = 4,
31 	DbCatComment = 8,
32 	DbCatDowntime = 16,
33 	DbCatEventHandler = 32,
34 	DbCatExternalCommand = 64,
35 	DbCatFlapping = 128,
36 	DbCatCheck = 256,
37 	DbCatLog = 512,
38 	DbCatNotification = 1024,
39 	DbCatProgramStatus = 2048,
40 	DbCatRetention = 4096,
41 	DbCatStateHistory = 8192
42 };
43 
44 class DbObject;
45 
46 struct DbQuery
47 {
48 	int Type{0};
49 	DbQueryCategory Category{DbCatInvalid};
50 	String Table;
51 	String IdColumn;
52 	Dictionary::Ptr Fields;
53 	Dictionary::Ptr WhereCriteria;
54 	intrusive_ptr<DbObject> Object;
55 	DbValue::Ptr NotificationInsertID;
56 	bool ConfigUpdate{false};
57 	bool StatusUpdate{false};
58 	WorkQueuePriority Priority{PriorityNormal};
59 
60 	static void StaticInitialize();
61 
62 	static const std::map<String, int>& GetCategoryFilterMap();
63 
64 private:
65 	static std::map<String, int> m_CategoryFilterMap;
66 };
67 
68 }
69 
70 #endif /* DBQUERY_H */
71 
72 #include "db_ido/dbobject.hpp"
73