4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jonghyuk Choi <jhchoi.choi@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef MMF_ATTRS_PRIVATE_H_
23 #define MMF_ATTRS_PRIVATE_H_
33 #define MMF_IS_VALUE_TYPE(t) ((t) == MMF_VALUE_TYPE_INT || \
34 (t) == MMF_VALUE_TYPE_DOUBLE || \
35 (t) == MMF_VALUE_TYPE_STRING || \
36 (t) == MMF_VALUE_TYPE_DATA)
38 #define MMF_IS_VALUE_SPEC_TYPE(t) ((t) == MMF_VALUE_SPEC_NONE || \
39 (t) == MMF_VALUE_SPEC_INT_ARRAY || \
40 (t) == MMF_VALUE_SPEC_INT_RANGE) || \
41 (t) == MMF_VALUE_SPEC_DOUBLE_ARRAY || \
42 (t) == MMF_VALUE_SPEC_DOUBLE_RANGE)
45 MMF_VALUE_TYPE_INT = MM_ATTRS_TYPE_INT,
46 MMF_VALUE_TYPE_DOUBLE=MM_ATTRS_TYPE_DOUBLE,
47 MMF_VALUE_TYPE_STRING = MM_ATTRS_TYPE_STRING,
48 MMF_VALUE_TYPE_DATA = MM_ATTRS_TYPE_DATA,
51 enum mmf_value_spec_type {
52 MMF_VALUE_SPEC_NONE = MM_ATTRS_VALID_TYPE_NONE,
53 MMF_VALUE_SPEC_INT_ARRAY = MM_ATTRS_VALID_TYPE_INT_ARRAY,
54 MMF_VALUE_SPEC_INT_RANGE = MM_ATTRS_VALID_TYPE_INT_RANGE,
55 MMF_VALUE_SPEC_DOUBLE_ARRAY = MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY,
56 MMF_VALUE_SPEC_DOUBLE_RANGE = MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
59 typedef struct mmf_value mmf_value_t;
60 typedef struct mmf_value_spec mmf_value_spec_t;
61 typedef struct mmf_attribute mmf_attribute_t;
62 typedef struct mmf_attrs mmf_attrs_t;
63 typedef struct mmf_attrs_list mmf_attrs_list_t;
64 typedef struct mmf_attribute_construct_info mmf_attrs_construct_info_t;
66 typedef bool (*mmf_attrs_commit_func_t)(int attr_idx,
67 const char* attr_name,
68 const mmf_value_t *value,
82 struct mmf_value_spec {
111 struct mmf_attribute {
116 mmf_value_spec_t value_spec;
122 mmf_attribute_t *items;
123 mmf_attrs_commit_func_t commit_func;
127 struct mmf_attrs_list {
129 mmf_attrs_list_t *next;
132 struct mmf_attribute_construct_info {
139 int mmf_value_init(mmf_value_t *value, int type);
141 int mmf_value_copy(mmf_value_t *dest, const mmf_value_t *src);
143 int mmf_value_set_int(mmf_value_t *v, int ival);
145 int mmf_value_get_int(const mmf_value_t *v);
147 int mmf_value_set_double(mmf_value_t *v, double dval);
149 double mmf_value_get_double(mmf_value_t *v);
151 int mmf_value_set_string(mmf_value_t *v, const char *sval, int size);
153 const char* mmf_value_get_string(const mmf_value_t *v, int *size);
155 int mmf_value_set_data(mmf_value_t *v, void *data, int size);
157 void* mmf_value_get_data(const mmf_value_t *v, int *size);
159 void mmf_value_dump(const mmf_value_t *value);
161 int mmf_value_clear(mmf_value_t *value);
163 int mmf_value_spec_init(mmf_value_spec_t *vs, int vs_type);
165 int mmf_value_spec_set_int_range(mmf_value_spec_t *vs, int min, int max);
167 int mmf_value_spec_get_int_range(mmf_value_spec_t *vs, int *min, int *max);
169 int mmf_value_spec_set_int_array(mmf_value_spec_t *vs, const int *array, int count);
171 int mmf_value_spec_get_int_array(mmf_value_spec_t *vs, int **array, int *count);
173 int mmf_value_spec_set_double_range(mmf_value_spec_t *vs, double min, double max);
175 int mmf_value_spec_get_double_range(mmf_value_spec_t *vs, double *min, double *max);
177 int mmf_value_spec_set_double_array(mmf_value_spec_t *vs, const double *array, int count);
179 int mmf_value_spec_get_double_array(mmf_value_spec_t *vs, double **array, int *count);
181 int mmf_value_spec_clear(mmf_value_spec_t *vs);
183 int mmf_attribute_init(mmf_attribute_t *item, const char *name, int value_type, int flags);
185 bool mmf_attribute_check_flags(mmf_attribute_t *item, int flags);
187 bool mmf_attribute_validate_int(mmf_attribute_t *item, int val);
189 bool mmf_attribute_validate_double(mmf_attribute_t *item, double val);
191 void mmf_attribute_clear(mmf_attribute_t *item);
193 bool mmf_attribute_is_modified(mmf_attribute_t *item);
195 void mmf_attribute_set_modified(mmf_attribute_t *item);
197 void mmf_attribute_set_readonly(mmf_attribute_t *item);
199 void mmf_attribute_set_disabled(mmf_attribute_t *item);
201 void mmf_attribute_commit(mmf_attribute_t *item);
203 int mmf_attribute_set_int(mmf_attribute_t *item, int val);
205 int mmf_attribute_set_double(mmf_attribute_t *item, double val);
207 int mmf_attribute_set_string(mmf_attribute_t *item, const char *string, int size);
209 int mmf_attribute_set_data(mmf_attribute_t *item, void *data, int size);
211 /* --- Create, Destroy and Initialize MmfAttrs --- */
213 MMHandleType mmf_attrs_new(int count);
215 MMHandleType mmf_attrs_new_from_data(const char *name,
216 mmf_attrs_construct_info_t *info,
218 mmf_attrs_commit_func_t commit_func,
221 void mmf_attrs_free(MMHandleType attrs);
223 int mmf_attrs_init(MMHandleType h, mmf_attrs_construct_info_t *info, int count);
225 int mmf_attrs_commit(MMHandleType h);
227 int mmf_attrs_commit_err(MMHandleType h, char **err_attr_name);
229 int mmf_attrs_set_valid_type(MMHandleType h, int idx, int v_type);
231 int mmf_attrs_set_valid_range(MMHandleType h, int idx, int min, int max);
233 int mmf_attrs_set_valid_array(MMHandleType h, int idx, const int *array, int count);
235 int mmf_attrs_set_valid_double_range(MMHandleType h, int idx, double min, double max);
237 int mmf_attrs_set_valid_double_array(MMHandleType h, int idx, const double *array, int count);
244 #endif /*MMF_ATTRS_PRIVATE_H_*/