Store the dbus connection while launching the service
[platform/core/context/context-service.git] / src / agent / legacy / trigger / TemplateManager.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef _CONTEXT_TRIGGER_TEMPLATE_MANAGER_H_
18 #define _CONTEXT_TRIGGER_TEMPLATE_MANAGER_H_
19
20 #include <CtxJson1.h>
21 #include <DatabaseManager.h>
22
23 namespace ctx {
24
25         class ContextManager;
26
27 namespace trigger {
28
29         class RuleManager;
30
31         class TemplateManager {
32         public:
33                 static TemplateManager* getInstance();
34                 static void setManager(ContextManager* ctxMgr, RuleManager* ruleMgr);
35                 static void destroy();
36
37                 bool init();
38                 void applyTemplates();
39                 int getTemplate(std::string &subject, CtxJson1* tmpl);
40                 void registerTemplate(std::string subject, int operation, CtxJson1 attributes, CtxJson1 options, std::string owner);
41                 void unregisterTemplate(std::string subject);
42
43         private:
44                 TemplateManager();
45                 TemplateManager(const TemplateManager& other);
46                 ~TemplateManager();
47
48                 static TemplateManager *__instance;
49                 static ContextManager *__contextMgr;
50                 static RuleManager *__ruleMgr;
51
52                 DatabaseManager __dbManager;
53
54                 std::string __addTemplate(std::string &subject, int &operation, CtxJson1 &attributes, CtxJson1 &options, std::string &owner);
55                 std::string __removeTemplate(std::string &subject);
56
57         };      /* class TemplateManager */
58
59 }       /* namespace trigger */
60 }       /* namespace ctx */
61
62 #endif  /* End of _CONTEXT_TRIGGER_TEMPLATE_MANAGER_H_ */