284fb48d06b80695629f2d05c834017e8e45e114
[platform/core/connectivity/stc-manager.git] / src / database / include / table-statistics.h
1 /*
2  * Copyright (c) 2016 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 __TABLE_STATISTICS_H__
18 #define __TABLE_STATISTICS_H__
19
20 typedef struct {
21         char *app_id;
22         char *ifname;
23         char *subscriber_id;
24         stc_iface_type_e iftype;
25         stc_db_tm_interval_s *interval;
26         stc_data_counter_s cnt;
27         stc_roaming_type_e roaming;
28         stc_hw_net_protocol_type_e hw_net_protocol_type;
29         stc_app_state_e ground;
30 } table_statistics_info;
31
32 typedef struct {
33         char *app_id;
34         char *subscriber_id;
35         stc_iface_type_e iftype;
36         stc_db_tm_interval_s *interval;
37 } table_statistics_reset_rule;
38
39 typedef struct {
40         time_t from;
41         time_t to;
42         stc_iface_type_e iftype;
43         int granularity;
44 } table_statistics_select_rule;
45
46 typedef stc_cb_ret_e
47 (*table_statistics_info_cb)(const table_statistics_info *info, void *user_data);
48
49 stc_error_e table_statistics_reset_first_n_entries(int num);
50
51 stc_error_e table_statistics_reset(const table_statistics_reset_rule *rule);
52
53 stc_error_e table_statistics_foreach_app(const table_statistics_select_rule *rule,
54                                          table_statistics_info_cb info_cb,
55                                          void *user_data);
56
57 stc_error_e table_statistics_per_app(const char *app_id,
58                                      table_statistics_select_rule *rule,
59                                      table_statistics_info_cb info_cb,
60                                      void *user_data);
61
62 stc_error_e table_statistics_insert(stc_db_classid_iftype_key *stat_key,
63                                     stc_db_app_stats *stat,
64                                     time_t last_touch_time);
65
66 stc_error_e table_statistics_prepare(sqlite3 *db);
67
68 void table_statistics_finalize(void);
69
70 #endif /*__TABLE_STATISTICS_H__ */