1 /*****************************************************************************
2 * variables.h: variables handling
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: variables.h,v 1.15 2003/07/23 22:01:25 gbazin Exp $
7 * Authors: Samuel Hocevar <sam@zoy.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 typedef struct callback_entry_t callback_entry_t;
26 /*****************************************************************************
27 * vlc_value_t is the common union for variable values; variable_t is the
28 * structure describing a variable.
29 *****************************************************************************/
32 /* The variable's exported value */
35 /* The variable unique name, (almost) unique hashed value, and type */
40 /* The variable display name, mainly for use by the interfaces */
43 /* A pointer to a comparison function, a duplication function, and
44 * a deallocation function */
45 int ( * pf_cmp ) ( vlc_value_t, vlc_value_t );
46 void ( * pf_dup ) ( vlc_value_t * );
47 void ( * pf_free ) ( vlc_value_t * );
49 /* Creation count: we only destroy the variable if it reaches 0 */
52 /* If the variable has min/max/step values */
53 vlc_value_t min, max, step;
55 /* If the variable is to be chosen in a list */
58 vlc_list_t choices_text;
60 /* Set to TRUE if the variable is in a callback */
61 vlc_bool_t b_incallback;
63 /* Registered callbacks */
65 callback_entry_t * p_entries;
68 /*****************************************************************************
69 * Variable types - probably very incomplete
70 *****************************************************************************/
71 #define VLC_VAR_TYPE 0x00ff
72 #define VLC_VAR_FLAGS 0xff00
75 #define VLC_VAR_VOID 0x0010
76 #define VLC_VAR_BOOL 0x0020
77 #define VLC_VAR_INTEGER 0x0030
78 #define VLC_VAR_STRING 0x0040
79 #define VLC_VAR_MODULE 0x0041
80 #define VLC_VAR_FILE 0x0042
81 #define VLC_VAR_DIRECTORY 0x0043
82 #define VLC_VAR_VARIABLE 0x0044
83 #define VLC_VAR_FLOAT 0x0050
84 #define VLC_VAR_TIME 0x0060
85 #define VLC_VAR_ADDRESS 0x0070
86 #define VLC_VAR_MUTEX 0x0080
87 #define VLC_VAR_LIST 0x0090
90 #define VLC_VAR_HASCHOICE 0x0100
91 #define VLC_VAR_HASMIN 0x0200
92 #define VLC_VAR_HASMAX 0x0400
93 #define VLC_VAR_HASSTEP 0x0800
95 #define VLC_VAR_ISLIST 0x1000
96 #define VLC_VAR_ISCOMMAND 0x2000
97 #define VLC_VAR_ISCONFIG 0x2000
100 #define VLC_VAR_DOINHERIT 0x8000
102 /*****************************************************************************
104 *****************************************************************************/
105 #define VLC_VAR_SETMIN 0x0010
106 #define VLC_VAR_SETMAX 0x0011
107 #define VLC_VAR_SETSTEP 0x0012
109 #define VLC_VAR_SETVALUE 0x0013
111 #define VLC_VAR_SETTEXT 0x0014
112 #define VLC_VAR_GETTEXT 0x0015
114 #define VLC_VAR_ADDCHOICE 0x0020
115 #define VLC_VAR_DELCHOICE 0x0021
116 #define VLC_VAR_CLEARCHOICES 0x0022
117 #define VLC_VAR_SETDEFAULT 0x0023
118 #define VLC_VAR_GETCHOICES 0x0024
119 #define VLC_VAR_FREECHOICES 0x0025
120 #define VLC_VAR_GETLIST 0x0026
121 #define VLC_VAR_FREELIST 0x0027
122 #define VLC_VAR_CHOICESCOUNT 0x0028
124 #define VLC_VAR_INHERITVALUE 0x0030
126 /*****************************************************************************
128 *****************************************************************************/
129 VLC_EXPORT( int, __var_Create, ( vlc_object_t *, const char *, int ) );
130 VLC_EXPORT( int, __var_Destroy, ( vlc_object_t *, const char * ) );
132 VLC_EXPORT( int, __var_Change, ( vlc_object_t *, const char *, int, vlc_value_t *, vlc_value_t * ) );
134 VLC_EXPORT( int, __var_Type, ( vlc_object_t *, const char * ) );
135 VLC_EXPORT( int, __var_Set, ( vlc_object_t *, const char *, vlc_value_t ) );
136 VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );
138 #define var_Create(a,b,c) __var_Create( VLC_OBJECT(a), b, c )
139 #define var_Destroy(a,b) __var_Destroy( VLC_OBJECT(a), b )
141 #define var_Change(a,b,c,d,e) __var_Change( VLC_OBJECT(a), b, c, d, e )
143 #define var_Type(a,b) __var_Type( VLC_OBJECT(a), b )
144 #define var_Set(a,b,c) __var_Set( VLC_OBJECT(a), b, c )
145 #define var_Get(a,b,c) __var_Get( VLC_OBJECT(a), b, c )
147 /*****************************************************************************
149 *****************************************************************************
150 * int MyCallback( vlc_object_t *p_this,
151 * char const *psz_variable,
152 * vlc_value_t oldvalue,
153 * vlc_value_t newvalue,
155 *****************************************************************************/
156 VLC_EXPORT( int, __var_AddCallback, ( vlc_object_t *, const char *, vlc_callback_t, void * ) );
157 VLC_EXPORT( int, __var_DelCallback, ( vlc_object_t *, const char *, vlc_callback_t, void * ) );
159 #define var_AddCallback(a,b,c,d) __var_AddCallback( VLC_OBJECT(a), b, c, d )
160 #define var_DelCallback(a,b,c,d) __var_DelCallback( VLC_OBJECT(a), b, c, d )