5faff83f802f84198baaf9eb880d8f68e4b17a43
[platform/core/connectivity/stc-manager.git] / src / database / include / table-counters.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_COUNTERS_H__
18 #define __TABLE_COUNTERS_H__
19
20 typedef struct {
21         uint64_t restriction_id;
22         int64_t data_counter;
23         int64_t warn_counter;
24         int64_t monthly_counter;
25         int64_t weekly_counter;
26         int64_t daily_counter;
27         int32_t month_start_date;
28         int64_t month_start_ts;
29         int64_t week_start_ts;
30         int64_t day_start_ts;
31 } table_counters_info;
32
33 typedef stc_cb_ret_e(*table_counters_info_cb)(const table_counters_info *info,
34                                               void *user_data);
35
36 stc_error_e table_counters_get(uint64_t restriction_id,
37                                table_counters_info *info);
38
39 stc_error_e table_counters_update_counters(const table_counters_info *info);
40
41 stc_error_e table_counters_get_timestamps(uint64_t restriction_id,
42                                         table_counters_info *info);
43
44 stc_error_e table_counters_update_timestamps(const table_counters_info *info);
45
46 stc_error_e table_counters_delete(uint64_t restriction_id);
47
48 stc_error_e table_counters_prepare(sqlite3 *db);
49
50 void table_counters_finalize(void);
51
52 #endif /*__TABLE_COUNTERS_H__ */