Migrate from 2.4 code repo
[platform/core/context/context-service.git] / src / context_trigger / context_monitor.h
1 /*
2 * context-service
3 *
4 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20 #ifndef __CONTEXT_MONITOR_H__
21 #define __CONTEXT_MONITOR_H__
22
23 #include <map>
24 #include "timer.h"
25
26 namespace ctx {
27
28         class json;
29         class fact_reader;
30         class context_fact;
31
32         class context_monitor {
33            public:
34                         context_monitor();
35                         ~context_monitor();
36                         bool init(ctx::fact_reader* fr, ctx::context_trigger* tr);
37
38                         int subscribe(int rule_id, std::string subject, ctx::json event, const char* zone);
39                         int unsubscribe(int rule_id, std::string subject, ctx::json option, const char* zone);
40                         int read(std::string subject, json option, const char* zone, ctx::json* result);
41                         bool is_supported(std::string subject, const char* zone);
42
43                 private:
44                         std::map<std::string, ctx::trigger_timer>::iterator get_zone_timer(std::string zone);
45                         int subscribe_timer(ctx::json option, const char* zone);
46                         int unsubscribe_timer(ctx::json option, const char* zone);
47                         int read_day_of_month(ctx::json* result, const char* zone);
48                         int read_day_of_week(ctx::json* result, const char* zone);
49                         int read_time(ctx::json* result, const char* zone);
50                         std::map<int, int> request_map; // <rule_id, fact_read_req_id>
51                         std::map<int, int> read_req_cnt_map;    // <fact_read_req_id, count>
52                         ctx::context_trigger* trigger;
53
54    };   /* class context_monitor */
55
56 }       /* namespace ctx */
57
58 #endif  /* End of __CONTEXT_MONITOR_H__ */