gmerlin
parameter.h
1/*****************************************************************
2 * gmerlin - a general purpose multimedia framework and applications
3 *
4 * Copyright (c) 2001 - 2012 Members of the Gmerlin project
5 * gmerlin-general@lists.sourceforge.net
6 * http://gmerlin.sourceforge.net
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * *****************************************************************/
21
22#ifndef __BG_PARAMETER_H_
23#define __BG_PARAMETER_H_
24
25#include <libxml/tree.h>
26#include <libxml/parser.h>
27
28#include <gavl/gavl.h>
29
44/* Universal Parameter setting mechanism */
45
77
82typedef union
83 {
84 double val_f;
85 int val_i;
86 char * val_str;
87 float val_color[4];
89 double val_pos[2];
91
92/* Flags */
93
97#define BG_PARAMETER_SYNC (1<<0)
98
102#define BG_PARAMETER_HIDE_DIALOG (1<<1)
103
107#define BG_PARAMETER_NO_SORT (1<<2)
108
112#define BG_PARAMETER_PLUGIN (1<<3)
113
117#define BG_PARAMETER_OWN_SECTION (1<<4)
118
123#define BG_PARAMETER_GLOBAL_PRESET (1<<5)
124
125
127
135 {
136 char * name;
137 char * long_name;
138 char * opt;
139
142
144
145 int flags;
146
150
151 /* Names which can be passed to set_parameter (NULL terminated) */
152
153 char const * const * multi_names;
154
155 /* Long names are optional, if they are NULL,
156 the short names are used */
157
158 char const * const * multi_labels;
159 char const * const * multi_descriptions;
160
161 /*
162 * These are parameters for each codec.
163 * The name members of these MUST be unique with respect to the rest
164 * of the parameters passed to the same set_parameter func
165 */
166
167 struct bg_parameter_info_s const * const * multi_parameters;
168
170
171 char * help_string;
172
173 char * preset_path;
174
176
178
180
182
183 };
184
185/* Prototype for setting/getting parameters */
186
187/*
188 * NOTE: All applications MUST call a bg_set_parameter_func with
189 * a NULL name argument to signal, that all parameters are set now
190 */
191
205typedef void (*bg_set_parameter_func_t)(void * data, const char * name,
206 const bg_parameter_value_t * v);
207
221typedef int (*bg_get_parameter_func_t)(void * data, const char * name,
223
231 const bg_parameter_info_t * src);
232
244
253void
255
262
274 const bg_parameter_value_t * src,
275 const bg_parameter_info_t * info);
276
285
286
296
308 const char * val);
309
310
324 const char * name);
325
326
338 xmlNodePtr xml_parameters);
339
349void
350bg_parameters_2_xml(const bg_parameter_info_t * info, xmlNodePtr xml_parameters);
351
360void
361bg_parameters_dump(const bg_parameter_info_t * info, const char * filename);
362
363
364#endif /* __BG_PARAMETER_H_ */
365
void bg_parameter_value_copy(bg_parameter_value_t *dst, const bg_parameter_value_t *src, const bg_parameter_info_t *info)
Copy a parameter value.
void bg_parameter_value_free(bg_parameter_value_t *val, bg_parameter_type_t type)
Free a parameter value.
const bg_parameter_info_t * bg_parameter_find(const bg_parameter_info_t *info, const char *name)
Find a parameter info.
int bg_parameter_get_selected(const bg_parameter_info_t *info, const char *val)
Get the index for a multi-options parameter.
void bg_parameter_info_destroy_array(bg_parameter_info_t *info)
Free a NULL terminated parameter array.
bg_parameter_type_t
Parameter type.
Definition parameter.h:54
void bg_parameter_info_set_const_ptrs(bg_parameter_info_t *info)
Set the const pointers of a dynamically allocated parameter info.
void(* bg_set_parameter_func_t)(void *data, const char *name, const bg_parameter_value_t *v)
Generic prototype for setting parameters in a module.
Definition parameter.h:205
void bg_parameter_info_copy(bg_parameter_info_t *dst, const bg_parameter_info_t *src)
Copy a single parameter info.
void bg_parameters_2_xml(const bg_parameter_info_t *info, xmlNodePtr xml_parameters)
Convert a parameter array into a libxml2 node.
bg_parameter_info_t * bg_xml_2_parameters(xmlDocPtr xml_doc, xmlNodePtr xml_parameters)
Convert a libxml2 node into a parameter array.
void bg_parameters_dump(const bg_parameter_info_t *info, const char *filename)
Dump a parameter array into a xml file.
bg_parameter_info_t * bg_parameter_info_copy_array(const bg_parameter_info_t *src)
Copy a NULL terminated parameter array.
bg_parameter_info_t * bg_parameter_info_concat_arrays(bg_parameter_info_t const **srcs)
Concatenate multiple arrays into one.
int(* bg_get_parameter_func_t)(void *data, const char *name, bg_parameter_value_t *v)
Generic prototype for getting parameters from a module.
Definition parameter.h:221
@ BG_PARAMETER_SECTION
Dummy type. It contains no data but acts as a separator in notebook style configuration windows.
Definition parameter.h:55
@ BG_PARAMETER_COLOR_RGBA
RGBA Color.
Definition parameter.h:65
@ BG_PARAMETER_BUTTON
Pressing the button causes set_parameter to be called with NULL value.
Definition parameter.h:75
@ BG_PARAMETER_INT
Integer spinbutton.
Definition parameter.h:57
@ BG_PARAMETER_COLOR_RGB
RGB Color.
Definition parameter.h:64
@ BG_PARAMETER_SLIDER_FLOAT
Float slider.
Definition parameter.h:60
@ BG_PARAMETER_FILE
File.
Definition parameter.h:68
@ BG_PARAMETER_TIME
Time.
Definition parameter.h:73
@ BG_PARAMETER_STRINGLIST
Popdown menu with string values.
Definition parameter.h:63
@ BG_PARAMETER_FLOAT
Float spinbutton.
Definition parameter.h:58
@ BG_PARAMETER_STRING_HIDDEN
Encrypted string (displays as ***)
Definition parameter.h:62
@ BG_PARAMETER_MULTI_MENU
Menu with config- and infobutton.
Definition parameter.h:70
@ BG_PARAMETER_DEVICE
Device.
Definition parameter.h:67
@ BG_PARAMETER_MULTI_LIST
List with config- and infobutton.
Definition parameter.h:71
@ BG_PARAMETER_STRING
String (one line only)
Definition parameter.h:61
@ BG_PARAMETER_FONT
Font (contains fontconfig compatible fontname)
Definition parameter.h:66
@ BG_PARAMETER_MULTI_CHAIN
Several subitems (including suboptions) can be arranged in a chain.
Definition parameter.h:72
@ BG_PARAMETER_DIRECTORY
Directory.
Definition parameter.h:69
@ BG_PARAMETER_CHECKBUTTON
Bool.
Definition parameter.h:56
@ BG_PARAMETER_SLIDER_INT
Integer slider.
Definition parameter.h:59
@ BG_PARAMETER_POSITION
Position (x/y coordinates, scaled 0..1)
Definition parameter.h:74
int64_t gavl_time_t
Parmeter description.
Definition parameter.h:135
bg_parameter_type_t type
Type.
Definition parameter.h:143
char * preset_path
Path for storing configuration presets.
Definition parameter.h:173
struct bg_parameter_info_s ** multi_parameters_nc
When allocating dynamically, use this instead of multi_parameters and call bg_parameter_info_set_cons...
Definition parameter.h:181
bg_parameter_value_t val_default
Default value.
Definition parameter.h:147
int flags
Mask of BG_PARAMETER_* defines.
Definition parameter.h:145
bg_parameter_value_t val_max
Maximum value (for arithmetic types)
Definition parameter.h:149
char const *const * multi_names
Names for multi option parameters (NULL terminated)
Definition parameter.h:153
char const *const * multi_descriptions
Optional descriptions (will be displayed by info buttons)
Definition parameter.h:159
char * gettext_directory
Second argument for bindtextdomain(). In an array, it's valid for subsequent entries too.
Definition parameter.h:141
struct bg_parameter_info_s const *const * multi_parameters
Parameters for each option. The name members of these MUST be unique with respect to the rest of the ...
Definition parameter.h:167
char * gettext_domain
First argument for bindtextdomain(). In an array, it's valid for subsequent entries too.
Definition parameter.h:140
char ** multi_names_nc
When allocating dynamically, use this instead of multi_names and call bg_parameter_info_set_const_ptr...
Definition parameter.h:175
bg_parameter_value_t val_min
Minimum value (for arithmetic types)
Definition parameter.h:148
char * opt
ultrashort name (optional for commandline). If missing, the name will be used.
Definition parameter.h:138
char * help_string
Help strings for tooltips or –help option.
Definition parameter.h:171
char * name
Unique name. Can contain alphanumeric characters plus underscore.
Definition parameter.h:136
char const *const * multi_labels
Optional labels for multi option parameters.
Definition parameter.h:158
char ** multi_labels_nc
When allocating dynamically, use this instead of multi_labels and call bg_parameter_info_set_const_pt...
Definition parameter.h:177
char ** multi_descriptions_nc
When allocating dynamically, use this instead of multi_descriptions and call bg_parameter_info_set_co...
Definition parameter.h:179
int num_digits
Number of digits for floating point parameters.
Definition parameter.h:169
char * long_name
Long name (for labels)
Definition parameter.h:137
Container for a parameter value.
Definition parameter.h:83
char * val_str
For BG_PARAMETER_STRING, BG_PARAMETER_STRING_HIDDEN, BG_PARAMETER_STRINGLIST, BG_PARAMETER_FONT,...
Definition parameter.h:86
double val_f
For BG_PARAMETER_FLOAT and BG_PARAMETER_SLIDER_FLOAT.
Definition parameter.h:84
gavl_time_t val_time
For BG_PARAMETER_TIME.
Definition parameter.h:88
int val_i
For BG_PARAMETER_CHECKBUTTON, BG_PARAMETER_INT and BG_PARAMETER_SLIDER_INT.
Definition parameter.h:85