Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

variables.h

00001 /*****************************************************************************
00002  * variables.h: variables handling
00003  *****************************************************************************
00004  * Copyright (C) 2002-2004 the VideoLAN team
00005  * $Id: variables.h 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Samuel Hocevar <[email protected]>
00008  *          Gildas Bazin <[email protected]>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00023  *****************************************************************************/
00024 
00036 typedef struct callback_entry_t callback_entry_t;
00037 
00042 struct variable_t
00043 {
00045     vlc_value_t  val;
00046 
00047     char *       psz_name; 
00048     uint32_t     i_hash;   
00049     int          i_type;   
00052     char *       psz_text;
00053 
00055     int      ( * pf_cmp ) ( vlc_value_t, vlc_value_t );
00057     void     ( * pf_dup ) ( vlc_value_t * );
00059     void     ( * pf_free ) ( vlc_value_t * );
00060 
00062     int          i_usage;
00063 
00065     vlc_value_t  min, max, step;
00066 
00069     int          i_default;
00071     vlc_list_t   choices;
00073     vlc_list_t   choices_text;
00074 
00076     vlc_bool_t   b_incallback;
00077 
00079     int                i_entries;
00081     callback_entry_t * p_entries;
00082 };
00083 
00084 /*****************************************************************************
00085  * Variable types - probably very incomplete
00086  *****************************************************************************/
00087 #define VLC_VAR_TYPE      0x00ff
00088 #define VLC_VAR_FLAGS     0xff00
00089 
00095 #define VLC_VAR_HASCHOICE 0x0100
00096 #define VLC_VAR_HASMIN    0x0200
00097 #define VLC_VAR_HASMAX    0x0400
00098 #define VLC_VAR_HASSTEP   0x0800
00099 
00100 #define VLC_VAR_ISLIST    0x1000
00101 #define VLC_VAR_ISCOMMAND 0x2000
00102 #define VLC_VAR_ISCONFIG  0x2000
00103 
00105 #define VLC_VAR_DOINHERIT 0x8000
00106 
00121 #define VLC_VAR_SETMIN              0x0010
00122 
00127 #define VLC_VAR_SETMAX              0x0011
00128 #define VLC_VAR_SETSTEP             0x0012
00129 
00135 #define VLC_VAR_SETVALUE            0x0013
00136 
00137 #define VLC_VAR_SETTEXT             0x0014
00138 #define VLC_VAR_GETTEXT             0x0015
00139 
00140 #define VLC_VAR_ADDCHOICE           0x0020
00141 #define VLC_VAR_DELCHOICE           0x0021
00142 #define VLC_VAR_CLEARCHOICES        0x0022
00143 #define VLC_VAR_SETDEFAULT          0x0023
00144 #define VLC_VAR_GETCHOICES          0x0024
00145 #define VLC_VAR_FREECHOICES         0x0025
00146 #define VLC_VAR_GETLIST             0x0026
00147 #define VLC_VAR_FREELIST            0x0027
00148 #define VLC_VAR_CHOICESCOUNT        0x0028
00149 
00150 #define VLC_VAR_INHERITVALUE        0x0030
00151 #define VLC_VAR_TRIGGER_CALLBACKS   0x0035
00152 
00154 /*****************************************************************************
00155  * Prototypes
00156  *****************************************************************************/
00157 VLC_EXPORT( int, __var_Create, ( vlc_object_t *, const char *, int ) );
00158 VLC_EXPORT( int, __var_Destroy, ( vlc_object_t *, const char * ) );
00159 
00160 VLC_EXPORT( int, __var_Change, ( vlc_object_t *, const char *, int, vlc_value_t *, vlc_value_t * ) );
00161 
00162 VLC_EXPORT( int, __var_Type, ( vlc_object_t *, const char * ) );
00163 VLC_EXPORT( int, __var_Set, ( vlc_object_t *, const char *, vlc_value_t ) );
00164 VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );
00165 
00169 #define var_Create(a,b,c) __var_Create( VLC_OBJECT(a), b, c )
00170 
00173 #define var_Destroy(a,b) __var_Destroy( VLC_OBJECT(a), b )
00174 
00178 #define var_Change(a,b,c,d,e) __var_Change( VLC_OBJECT(a), b, c, d, e )
00179 
00183 #define var_Type(a,b) __var_Type( VLC_OBJECT(a), b )
00184 
00187 #define var_Set(a,b,c) __var_Set( VLC_OBJECT(a), b, c )
00188 
00191 #define var_Get(a,b,c) __var_Get( VLC_OBJECT(a), b, c )
00192 
00193 /*****************************************************************************
00194  * Variable callbacks
00195  *****************************************************************************
00196  * int MyCallback( vlc_object_t *p_this,
00197  *                 char const *psz_variable,
00198  *                 vlc_value_t oldvalue,
00199  *                 vlc_value_t newvalue,
00200  *                 void *p_data);
00201  *****************************************************************************/
00202 VLC_EXPORT( int, __var_AddCallback, ( vlc_object_t *, const char *, vlc_callback_t, void * ) );
00203 VLC_EXPORT( int, __var_DelCallback, ( vlc_object_t *, const char *, vlc_callback_t, void * ) );
00204 
00208 #define var_AddCallback(a,b,c,d) __var_AddCallback( VLC_OBJECT(a), b, c, d )
00209 
00213 #define var_DelCallback(a,b,c,d) __var_DelCallback( VLC_OBJECT(a), b, c, d )
00214 
00215 /*****************************************************************************
00216  * helpers functions
00217  *****************************************************************************/
00218 
00226 static inline int __var_SetInteger( vlc_object_t *p_obj, const char *psz_name, int i )
00227 {
00228     vlc_value_t val;
00229     val.i_int = i;
00230     return __var_Set( p_obj, psz_name, val );
00231 }
00232 
00240 static inline int __var_SetBool( vlc_object_t *p_obj, const char *psz_name, vlc_bool_t b )
00241 {
00242     vlc_value_t val;
00243     val.b_bool = b;
00244     return __var_Set( p_obj, psz_name, val );
00245 }
00246 
00254 static inline int __var_SetTime( vlc_object_t *p_obj, const char *psz_name, int64_t i )
00255 {
00256     vlc_value_t val;
00257     val.i_time = i;
00258     return __var_Set( p_obj, psz_name, val );
00259 }
00260 
00268 static inline int __var_SetFloat( vlc_object_t *p_obj, const char *psz_name, float f )
00269 {
00270     vlc_value_t val;
00271     val.f_float = f;
00272     return __var_Set( p_obj, psz_name, val );
00273 }
00274 
00282 static inline int __var_SetString( vlc_object_t *p_obj, const char *psz_name, char *psz_string )
00283 {
00284     vlc_value_t val;
00285     val.psz_string = psz_string;
00286     return __var_Set( p_obj, psz_name, val );
00287 }
00288 
00295 static inline int __var_SetVoid( vlc_object_t *p_obj, const char *psz_name )
00296 {
00297     vlc_value_t val;
00298     val.b_bool = VLC_TRUE;
00299     return __var_Set( p_obj, psz_name, val );
00300 }
00301 
00305 #define var_SetInteger(a,b,c)   __var_SetInteger( VLC_OBJECT(a),b,c)
00306 
00309 #define var_SetBool(a,b,c)   __var_SetBool( VLC_OBJECT(a),b,c)
00310 
00314 #define var_SetTime(a,b,c)      __var_SetTime( VLC_OBJECT(a),b,c)
00315 
00318 #define var_SetFloat(a,b,c)     __var_SetFloat( VLC_OBJECT(a),b,c)
00319 
00322 #define var_SetString(a,b,c)     __var_SetString( VLC_OBJECT(a),b,c)
00323 
00326 #define var_SetVoid(a,b)        __var_SetVoid( VLC_OBJECT(a),b)
00327 
00334 static inline int __var_GetInteger( vlc_object_t *p_obj, const char *psz_name )
00335 {
00336     vlc_value_t val;
00337     if( !__var_Get( p_obj, psz_name, &val ) )
00338         return val.i_int;
00339     else
00340         return 0;
00341 }
00342 
00349 static inline int __var_GetBool( vlc_object_t *p_obj, const char *psz_name )
00350 {
00351     vlc_value_t val;
00352     if( !__var_Get( p_obj, psz_name, &val ) )
00353         return val.b_bool;
00354     else
00355         return VLC_FALSE;
00356 }
00357 
00364 static inline int64_t __var_GetTime( vlc_object_t *p_obj, const char *psz_name )
00365 {
00366     vlc_value_t val;
00367     if( !__var_Get( p_obj, psz_name, &val ) )
00368         return val.i_time;
00369     else
00370         return 0;
00371 }
00372 
00379 static inline float __var_GetFloat( vlc_object_t *p_obj, const char *psz_name )
00380 {
00381     vlc_value_t val;
00382     if( !__var_Get( p_obj, psz_name, &val ) )
00383         return val.f_float;
00384     else
00385         return 0.0;
00386 }
00387 
00394 static inline char *__var_GetString( vlc_object_t *p_obj, const char *psz_name )
00395 {
00396     vlc_value_t val;
00397     if( !__var_Get( p_obj, psz_name, &val ) )
00398         return val.psz_string;
00399     else
00400         return strdup( "" );
00401 }
00402 
00406 #define var_GetInteger(a,b)   __var_GetInteger( VLC_OBJECT(a),b)
00407 
00410 #define var_GetBool(a,b)   __var_GetBool( VLC_OBJECT(a),b)
00411 
00414 #define var_GetTime(a,b)   __var_GetTime( VLC_OBJECT(a),b)
00415 
00418 #define var_GetFloat(a,b)   __var_GetFloat( VLC_OBJECT(a),b)
00419 
00422 #define var_GetString(a,b)   __var_GetString( VLC_OBJECT(a),b)
00423 
00424 
00431 static inline int __var_CreateGetInteger( vlc_object_t *p_obj, const char *psz_name )
00432 {
00433     vlc_value_t val;
00434 
00435     __var_Create( p_obj, psz_name, VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00436     if( !__var_Get( p_obj, psz_name, &val ) )
00437         return val.i_int;
00438     else
00439         return 0;
00440 }
00441 
00448 static inline int __var_CreateGetBool( vlc_object_t *p_obj, const char *psz_name )
00449 {
00450     vlc_value_t val;
00451 
00452     __var_Create( p_obj, psz_name, VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
00453     if( !__var_Get( p_obj, psz_name, &val ) )
00454         return val.b_bool;
00455     else
00456         return VLC_FALSE;
00457 }
00458 
00465 static inline int64_t __var_CreateGetTime( vlc_object_t *p_obj, const char *psz_name )
00466 {
00467     vlc_value_t val;
00468 
00469     __var_Create( p_obj, psz_name, VLC_VAR_TIME | VLC_VAR_DOINHERIT );
00470     if( !__var_Get( p_obj, psz_name, &val ) )
00471         return val.i_time;
00472     else
00473         return 0;
00474 }
00475 
00482 static inline float __var_CreateGetFloat( vlc_object_t *p_obj, const char *psz_name )
00483 {
00484     vlc_value_t val;
00485 
00486     __var_Create( p_obj, psz_name, VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
00487     if( !__var_Get( p_obj, psz_name, &val ) )
00488         return val.f_float;
00489     else
00490         return 0.0;
00491 }
00492 
00499 static inline char *__var_CreateGetString( vlc_object_t *p_obj, const char *psz_name )
00500 {
00501     vlc_value_t val;
00502 
00503     __var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT );
00504     if( !__var_Get( p_obj, psz_name, &val ) )
00505         return val.psz_string;
00506     else
00507         return strdup( "" );
00508 }
00509 
00513 #define var_CreateGetInteger(a,b)   __var_CreateGetInteger( VLC_OBJECT(a),b)
00514 
00517 #define var_CreateGetBool(a,b)   __var_CreateGetBool( VLC_OBJECT(a),b)
00518 
00521 #define var_CreateGetTime(a,b)   __var_CreateGetTime( VLC_OBJECT(a),b)
00522 
00525 #define var_CreateGetFloat(a,b)   __var_CreateGetFloat( VLC_OBJECT(a),b)
00526 
00529 #define var_CreateGetString(a,b)   __var_CreateGetString( VLC_OBJECT(a),b)
00530 

Generated on Tue Dec 20 10:14:19 2005 for vlc-0.8.4a by  doxygen 1.4.2