tizen 2.4 release
[framework/context/place-context-provider.git] / src / geofence / myplace_handle.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_PLACE_MYPLACE_HANDLE_H__
18 #define __CONTEXT_PLACE_MYPLACE_HANDLE_H__
19
20 #include <set>
21 #include <string>
22 #include <map>
23 #include <geofence_manager.h>
24
25 namespace ctx {
26
27         class myplace_handle {
28
29                 typedef std::map<int, geofence_state_e> geo_state_map_t;
30                 typedef std::set<std::string> string_set_t;
31
32                 public:
33                         myplace_handle();
34                         ~myplace_handle();
35
36                         bool start_monitor(int place_id);
37                         int get_place_id();
38
39                 private:
40                         int _place_id;
41                         geofence_state_e prev_state;
42                         geofence_manager_h geo_handle;
43                         geo_state_map_t geo_state_map;
44
45                         void emit_state_change();
46                         void stop_monitor();
47                         bool start_fence(int fence_id);
48                         void remove_fence(int fence_id);
49                         void update_fence(int fence_id, geofence_manage_e manage);
50                         void update_state(int fence_id, geofence_state_e state);
51
52                         static bool fence_list_cb(int geofence_id, geofence_h fence, int fence_index, int fence_cnt, void* user_data);
53                         static void fence_event_cb(int place_id, int geofence_id, geofence_manager_error_e error, geofence_manage_e manage, void* user_data);
54                         static void fence_state_cb(int geofence_id, geofence_state_e state, void* user_data);
55         };
56
57 }       /* namespace ctx */
58
59 #endif /* __CONTEXT_PLACE_MYPLACE_HANDLE_H__ */