]> git.sesse.net Git - vlc/blob - include/variables.h
09af78c3d20ce72cad62889493311d6849d43f90
[vlc] / include / variables.h
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 $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
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.
13  * 
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.
18  *
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  *****************************************************************************/
23
24 typedef struct callback_entry_t callback_entry_t;
25
26 /*****************************************************************************
27  * vlc_value_t is the common union for variable values; variable_t is the
28  * structure describing a variable. 
29  *****************************************************************************/
30 struct variable_t
31 {
32     /* The variable's exported value */
33     vlc_value_t  val;
34
35     /* The variable unique name, (almost) unique hashed value, and type */
36     char *       psz_name;
37     uint32_t     i_hash;
38     int          i_type;
39
40     /* The variable display name, mainly for use by the interfaces */
41     char *       psz_text;
42
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 * );
48
49     /* Creation count: we only destroy the variable if it reaches 0 */
50     int          i_usage;
51
52     /* If the variable has min/max/step values */
53     vlc_value_t  min, max, step;
54
55     /* If the variable is to be chosen in a list */
56     int          i_default;
57     vlc_list_t   choices;
58     vlc_list_t   choices_text;
59
60     /* Set to TRUE if the variable is in a callback */
61     vlc_bool_t   b_incallback;
62
63     /* Registered callbacks */
64     int                i_entries;
65     callback_entry_t * p_entries;
66 };
67
68 /*****************************************************************************
69  * Variable types - probably very incomplete
70  *****************************************************************************/
71 #define VLC_VAR_TYPE      0x00ff
72 #define VLC_VAR_FLAGS     0xff00
73
74 /* Different types */
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
88
89 /* Additive flags */
90 #define VLC_VAR_HASCHOICE 0x0100
91 #define VLC_VAR_HASMIN    0x0200
92 #define VLC_VAR_HASMAX    0x0400
93 #define VLC_VAR_HASSTEP   0x0800
94
95 #define VLC_VAR_ISLIST    0x1000
96 #define VLC_VAR_ISCOMMAND 0x2000
97 #define VLC_VAR_ISCONFIG  0x2000
98
99 /* Creation flag */
100 #define VLC_VAR_DOINHERIT 0x8000
101
102 /*****************************************************************************
103  * Variable actions
104  *****************************************************************************/
105 #define VLC_VAR_SETMIN        0x0010
106 #define VLC_VAR_SETMAX        0x0011
107 #define VLC_VAR_SETSTEP       0x0012
108
109 #define VLC_VAR_SETVALUE      0x0013
110
111 #define VLC_VAR_SETTEXT       0x0014
112 #define VLC_VAR_GETTEXT       0x0015
113
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
123
124 #define VLC_VAR_INHERITVALUE  0x0030
125
126 /*****************************************************************************
127  * Prototypes
128  *****************************************************************************/
129 VLC_EXPORT( int, __var_Create, ( vlc_object_t *, const char *, int ) );
130 VLC_EXPORT( int, __var_Destroy, ( vlc_object_t *, const char * ) );
131
132 VLC_EXPORT( int, __var_Change, ( vlc_object_t *, const char *, int, vlc_value_t *, vlc_value_t * ) );
133
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 * ) );
137
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 )
140
141 #define var_Change(a,b,c,d,e) __var_Change( VLC_OBJECT(a), b, c, d, e )
142
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 )
146
147 /*****************************************************************************
148  * Variable callbacks
149  *****************************************************************************
150  * int MyCallback( vlc_object_t *p_this,
151  *                 char const *psz_variable,
152  *                 vlc_value_t oldvalue,
153  *                 vlc_value_t newvalue,
154  *                 void *p_data);
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 * ) );
158
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 )
161