Tizen 2.0 Release
[framework/system/sync-agent.git] / include / engine-controller / param_spec.h
1 /*
2  * sync-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #ifndef PARAM_SPEC_H_
19 #define PARAM_SPEC_H_
20
21 #include "fundamental_type.h"
22 #include "define.h"
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif                          /* __cplusplus */
27
28 /**
29  * @file param_spec.h
30  * @brief Provides parameter spec creation for various data type
31  */
32
33 /** @addtogroup engine_controller
34  *      @{
35  */
36
37 /**
38  * @brief Callback function which copies parameter data in structure type
39  * @param[in] pStruct Parameter data in structure type to copy from
40  * @return Pointer of newly copied structure�
41  */
42         typedef sync_agent_ec_pointer(*sync_agent_copy_struct_cb) (sync_agent_ec_pointer pStruct);
43
44 /**
45  * @brief Callback function which frees parameter data in structure type
46  * @param[in] pStruct Parameter data in structure type to free
47  */
48         typedef void (*sync_agent_free_struct_cb) (sync_agent_ec_pointer pStruct);
49
50 /**
51  * @brief Callback function which validates parameter data in structure type
52  * @param[in] pStruct Parameter data in structure type to validate
53  * @return 1 on validation success case, otherwise 0
54  */
55         typedef sync_agent_ec_boolean(*sync_agent_validate_struct_cb) (sync_agent_ec_pointer pStruct, sync_agent_ec_pointer usr_data);
56
57 /**
58  * @brief Enumerations of flag which indicates sort of parameter
59  */
60         typedef enum {
61                 SYNC_AGENT_EC_PARAM_FLAG_DEFAULT = 0,                           /**< Default type */
62                 SYNC_AGENT_EC_PARAM_FLAG_INPUT = 1,                                     /**< Input type */
63                 SYNC_AGENT_EC_PARAM_FLAG_OUTPUT = 2,                            /**< Output type */
64                 SYNC_AGENT_EC_PARAM_FLAG_INPUT_VALIDATE_ON = 4, /**< Input-validate type */
65                 SYNC_AGENT_EC_PARAM_FLAG_OUTPUT_VALIDATE_ON = 8,        /**< Output-validate type */
66                 SYNC_AGENT_EC_PARAM_FLAG_INPUT_DEFAULT_VALUE_ON = 16
67                                                                 /**< Intput-default-value type */
68         } sync_agent_ec_param_flags_e;
69
70 /**
71  * @brief Structure of parameter spec which contains function parameter spec
72  */
73         typedef struct sync_agent_ec_param_param_spec sync_agent_ec_param_spec_s;
74
75 /**
76  * @brief Decreases reference count of parameter spec
77  * @par Usage:
78  * @code
79  sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("accountId", true, false, false, 0, 0, false, 0, false, 0, 0);
80  sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("syncMode", _string_copy_struct, free, true, false, false, NULL, false, NULL, false, NULL);
81  sync_agent_ec_param_spec_s *param_spec_array[2] = {pParam_spec1, pParam_spec2};
82  
83  sync_agent_ec_task_spec_s *pTask_spec = sync_agent_alloc_simple_task_spec("synchronize", synchronize_task_process, NULL, NULL, 2, param_spec_array);
84  
85  sync_agent_unref_param_spec(pParam_spec1);
86  sync_agent_unref_param_spec(pParam_spec2);
87  * @endcode
88  * @param[in] param_spec Pointer of parameter spec to decrease ref count
89  */
90         void sync_agent_unref_param_spec(sync_agent_ec_param_spec_s * param_spec);
91
92 /**
93  * @brief Allocs and returns int type of parameter spec
94  * @par Usage:
95  * @code
96  sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("accountId", true, false, false, 0, 0, false, 0, false, 0, 0);
97  * @endcode
98  * @param[in] name Name of parameter which user defined
99  * @param[in] is_input On if this parameter to be used as input
100  * @param[in] is_output On if this parameter to be used as output
101  * @param[in] input_validate_on On if want to perform input parameter value validation
102  * @param[in] input_minimum Minimum value of valid input parameter value range
103  * @param[in] input_maximum Maximum value of valid input parameter value range
104  * @param[in] input_default_on On if this parameter to contain default value
105  * @param[in] input_default_value Default value for this parameter to contain
106  * @param[in] output_validate_on On if want to perform output parameter value validation
107  * @param[in] output_minimum Minimum value of valid output parameter value range
108  * @param[in] output_maximum Maximum value of valid output parameter value range
109  * @return Pointer of parameter spec which defined as ordered type
110  */
111         sync_agent_ec_param_spec_s *sync_agent_alloc_param_spec_int(const sync_agent_ec_char * name, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output, sync_agent_ec_boolean input_validate_on, sync_agent_ec_int input_minimum,
112                                                                     sync_agent_ec_int input_maximum, sync_agent_ec_boolean input_default_on, sync_agent_ec_int input_default_value, sync_agent_ec_boolean output_validate_on, sync_agent_ec_int output_minimum,
113                                                                     sync_agent_ec_int output_maximum);
114
115 /**
116  * @brief Allocs and returns structure(Pointer) type of parameter spec
117  * @par Usage:
118  * @code
119  sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_structure("syncMode", _string_copy_struct, free, true, false, false, NULL, false, NULL, false, NULL);
120  * @endcode
121  * @param[in] name Name of parameter which user defined
122  * @param[in] copy_func Function which can make copy of this structure type of parameter
123  * @param[in] free_func Function which can free this structure type of parameter
124  * @param[in] is_input On if this parameter to be used as input
125  * @param[in] is_output On if this parameter to be used as output
126  * @param[in] input_validate_on On if want to perform input parameter value validation
127  * @param[in] in_val_func Function which can validate this structure type of input parameter
128  * @param[in] input_default_on On if this parameter to contain default value
129  * @param[in] default_struct Default value of this structure type of parameter
130  * @param[in] output_validate_on On if want to perform output parameter value validation
131  * @param[in] out_val_func which can validate this structure type of output parameter
132  * @return Pointer of parameter spec which defined as ordered type
133  */
134         sync_agent_ec_param_spec_s *sync_agent_alloc_param_spec_structure(const sync_agent_ec_char * name, sync_agent_copy_struct_cb copy_func, sync_agent_free_struct_cb free_func, sync_agent_ec_boolean is_input, sync_agent_ec_boolean is_output,
135                                                                           sync_agent_ec_boolean input_validate_on, sync_agent_validate_struct_cb in_val_func, sync_agent_ec_boolean input_default_on, sync_agent_ec_pointer default_struct,
136                                                                           sync_agent_ec_boolean output_validate_on, sync_agent_validate_struct_cb out_val_func);
137
138 /**
139  *      @}
140  */
141
142 #ifdef __cplusplus
143 }
144 #endif                          /* __cplusplus */
145 #endif                          /* PARAM_SPEC_H_ */