[refactoring] revise interface
[platform/core/api/system-settings.git] / src / sst_interface.h
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
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 #pragma once
17
18 #include "system_settings.h"
19
20 typedef enum {
21         SYSTEM_SETTING_DATA_TYPE_STRING,        /**< string */
22         SYSTEM_SETTING_DATA_TYPE_INT,           /**< integer */
23         SYSTEM_SETTING_DATA_TYPE_BOOL,          /**< boolean */
24         //SYSTEM_SETTING_DATA_TYPE_FLOAT,
25         //SYSTEM_SETTING_DATA_TYPE_DOULBE,
26 } sst_interface_data_type;
27
28 typedef struct sst_interface_s sst_interface;
29
30 typedef int (*sst_check_feature_fn)(void *value);
31
32 typedef int (*sst_get_int_fn)(sst_interface *iface, int *value);
33 typedef int (*sst_get_bool_fn)(sst_interface *iface, bool *value);
34 typedef int (*sst_get_str_fn)(sst_interface *iface, char **value);
35
36 typedef int (*sst_set_int_fn)(sst_interface *iface, int value);
37 typedef int (*sst_set_bool_fn)(sst_interface *iface, bool value);
38 typedef int (*sst_set_str_fn)(sst_interface *iface, const char *value);
39
40
41 struct sst_interface_s {
42         system_settings_key_e key;
43         const char* const vconf_key;
44         sst_interface_data_type data_type;
45         sst_check_feature_fn feature_checker;
46         union {
47                 sst_get_int_fn i;
48                 sst_get_bool_fn b;
49                 sst_get_str_fn s;
50         } getter;
51         union {
52                 sst_set_int_fn i;
53                 sst_set_bool_fn b;
54                 sst_set_str_fn s;
55         } setter;
56 };
57
58 int sst_get_interface(system_settings_key_e key, sst_interface **iface);