gmerlin
|
00001 /***************************************************************** 00002 * gmerlin - a general purpose multimedia framework and applications 00003 * 00004 * Copyright (c) 2001 - 2011 Members of the Gmerlin project 00005 * gmerlin-general@lists.sourceforge.net 00006 * http://gmerlin.sourceforge.net 00007 * 00008 * This program is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation, either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 * *****************************************************************/ 00021 00022 #ifndef __BG_CFG_REGISTRY_H_ 00023 #define __BG_CFG_REGISTRY_H_ 00024 00025 #include <gmerlin/parameter.h> 00026 00059 typedef struct bg_cfg_section_s bg_cfg_section_t; 00060 00067 typedef struct bg_cfg_registry_s bg_cfg_registry_t; 00068 00076 bg_cfg_registry_t * bg_cfg_registry_create(); 00077 00083 void bg_cfg_registry_destroy(bg_cfg_registry_t * reg); 00084 00085 /* cfg_xml.c */ 00086 00093 void bg_cfg_registry_load(bg_cfg_registry_t * reg, const char * filename); 00094 00101 void bg_cfg_registry_save(bg_cfg_registry_t * reg, const char * filename); 00102 00111 int bg_cfg_registry_has_section(bg_cfg_registry_t * r, const char * name); 00112 00113 00114 /* The name and xml tag of the section must be set before */ 00115 00124 void bg_cfg_section_2_xml(bg_cfg_section_t * section, xmlNodePtr xml_section); 00125 00135 void bg_cfg_xml_2_section(xmlDocPtr xml_doc, xmlNodePtr xml_section, 00136 bg_cfg_section_t * section); 00137 00146 void bg_cfg_section_dump(bg_cfg_section_t * section, const char * filename); 00147 00148 /* 00149 * Path looks like "section:subsection:subsubsection" 00150 */ 00151 00163 bg_cfg_section_t * bg_cfg_registry_find_section(bg_cfg_registry_t * reg, 00164 const char * path); 00165 00175 bg_cfg_section_t * bg_cfg_section_find_subsection(bg_cfg_section_t * section, 00176 const char * name); 00177 00185 bg_cfg_section_t * bg_cfg_section_create_subsection_at_pos(bg_cfg_section_t * section, 00186 int pos); 00187 00195 void bg_cfg_section_move_child(bg_cfg_section_t * section, bg_cfg_section_t * child, 00196 int pos); 00197 00198 00208 bg_cfg_section_t * bg_cfg_section_find_subsection_by_index(bg_cfg_section_t * section, 00209 int index); 00210 00211 00212 /* 00213 * Create/destroy config sections 00214 */ 00215 00222 bg_cfg_section_t * bg_cfg_section_create(const char * name); 00223 00235 bg_cfg_section_t * 00236 bg_cfg_section_create_from_parameters(const char * name, 00237 const bg_parameter_info_t * parameters); 00238 00249 void bg_cfg_section_create_items(bg_cfg_section_t * section, 00250 const bg_parameter_info_t * parameters); 00251 00257 void bg_cfg_section_destroy(bg_cfg_section_t * section); 00258 00265 bg_cfg_section_t * bg_cfg_section_copy(const bg_cfg_section_t * src); 00266 00277 void bg_cfg_section_transfer(bg_cfg_section_t * src, bg_cfg_section_t * dst); 00278 00285 void bg_cfg_section_transfer_children(bg_cfg_section_t * src, bg_cfg_section_t * dst); 00286 00293 void bg_cfg_section_add_ref(bg_cfg_section_t * s, bg_cfg_section_t * ref); 00294 00295 /* 00296 * Get/Set section names 00297 */ 00298 00305 const char * bg_cfg_section_get_name(bg_cfg_section_t * section); 00306 00315 char * bg_cfg_section_get_name_translated(bg_cfg_section_t * section); 00316 00325 void bg_cfg_section_set_name(bg_cfg_section_t * section, const char * name, 00326 const char * gettext_domain, 00327 const char * gettext_directory); 00328 00329 /* 00330 * Get/Set values 00331 */ 00332 00343 void bg_cfg_section_set_parameter(bg_cfg_section_t * section, 00344 const bg_parameter_info_t * info, 00345 const bg_parameter_value_t * value); 00346 00359 int bg_cfg_section_set_parameters_from_string(bg_cfg_section_t * section, 00360 const bg_parameter_info_t * info, 00361 const char * str); 00362 00373 void bg_cfg_section_get_parameter(bg_cfg_section_t * section, 00374 const bg_parameter_info_t * info, 00375 bg_parameter_value_t * value); 00376 00385 void bg_cfg_section_delete_subsection(bg_cfg_section_t * section, 00386 bg_cfg_section_t * subsection); 00387 00388 00389 /* 00390 * Type specific get/set functions, which don't require 00391 * an info structure 00392 */ 00393 00401 void bg_cfg_section_set_parameter_int(bg_cfg_section_t * section, 00402 const char * name, int value); 00403 00411 void bg_cfg_section_set_parameter_float(bg_cfg_section_t * section, 00412 const char * name, float value); 00413 00421 void bg_cfg_section_set_parameter_string(bg_cfg_section_t * section, 00422 const char * name, const char * value); 00423 00431 void bg_cfg_section_set_parameter_time(bg_cfg_section_t * section, 00432 const char * name, gavl_time_t value); 00433 00434 /* Get parameter values, return 0 if no such entry */ 00435 00444 int bg_cfg_section_get_parameter_int(bg_cfg_section_t * section, 00445 const char * name, int * value); 00446 00455 int bg_cfg_section_get_parameter_float(bg_cfg_section_t * section, 00456 const char * name, float * value); 00457 00466 int bg_cfg_section_get_parameter_string(bg_cfg_section_t * section, 00467 const char * name, const char ** value); 00468 00477 int bg_cfg_section_get_parameter_time(bg_cfg_section_t * section, 00478 const char * name, gavl_time_t * value); 00479 00480 00481 /* Apply all values found in the parameter info */ 00482 00495 void bg_cfg_section_apply(bg_cfg_section_t * section, 00496 const bg_parameter_info_t * parameters, 00497 bg_set_parameter_func_t func, 00498 void * callback_data); 00499 00511 void bg_cfg_section_apply_noterminate(bg_cfg_section_t * section, 00512 const bg_parameter_info_t * infos, 00513 bg_set_parameter_func_t func, 00514 void * callback_data); 00515 00529 void bg_cfg_section_get(bg_cfg_section_t * section, 00530 const bg_parameter_info_t * parameters, 00531 bg_get_parameter_func_t func, 00532 void * callback_data); 00533 00541 int bg_cfg_section_has_subsection(bg_cfg_section_t * section, 00542 const char * name); 00543 00550 void bg_cfg_section_restore_defaults(bg_cfg_section_t * s, 00551 const bg_parameter_info_t * info); 00552 00553 00554 #endif /* __BG_CFG_REGISTRY_H_ */