vlc_variables.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * variables.h: variables handling
00003  *****************************************************************************
00004  * Copyright (C) 2002-2004 the VideoLAN team
00005  * $Id: 927749add6df90e52b78297e9ef8b34ccf8d7a35 $
00006  *
00007  * Authors: Samuel Hocevar <sam@zoy.org>
00008  *          Gildas Bazin <gbazin@netcourrier.com>
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef VLC_VARIABLES_H
00026 #define VLC_VARIABLES_H 1
00027 
00028 /**
00029  * \file
00030  * This file defines functions and structures for dynamic variables in vlc
00031  */
00032 
00033 /**
00034  * \defgroup variables Variables
00035  *
00036  * Functions for using the object variables in vlc.
00037  *
00038  * Vlc have a very powerful "object variable" infrastructure useful
00039  * for many things.
00040  *
00041  * @{
00042  */
00043 
00044 /*****************************************************************************
00045  * Variable types - probably very incomplete
00046  *****************************************************************************/
00047 #define VLC_VAR_TYPE      0x00ff
00048 #define VLC_VAR_CLASS     0x00f0
00049 #define VLC_VAR_FLAGS     0xff00
00050 
00051 /** \defgroup var_flags Additive flags
00052  * These flags are added to the type field of the variable. Most as a result of
00053  * a var_Change() call, but some may be added at creation time
00054  * @{
00055  */
00056 #define VLC_VAR_HASCHOICE 0x0100
00057 #define VLC_VAR_HASMIN    0x0200
00058 #define VLC_VAR_HASMAX    0x0400
00059 #define VLC_VAR_HASSTEP   0x0800
00060 
00061 #define VLC_VAR_ISCOMMAND 0x2000
00062 
00063 /** Creation flag */
00064 /* If the variable is not found on the current module
00065    search all parents and finally module config until found */
00066 #define VLC_VAR_DOINHERIT 0x8000
00067 /**@}*/
00068 
00069 /**
00070  * \defgroup var_action Variable actions
00071  * These are the different actions that can be used with var_Change().
00072  * The parameters given are the meaning of the two last parameters of
00073  * var_Change() when this action is being used.
00074  * @{
00075  */
00076 
00077 /**
00078  * Set the minimum value of this variable
00079  * \param p_val The new minimum value
00080  * \param p_val2 Unused
00081  */
00082 #define VLC_VAR_SETMIN              0x0010
00083 /**
00084  * Set the maximum value of this variable
00085  * \param p_val The new maximum value
00086  * \param p_val2 Unused
00087  */
00088 #define VLC_VAR_SETMAX              0x0011
00089 #define VLC_VAR_SETSTEP             0x0012
00090 
00091 /**
00092  * Set the value of this variable without triggering any callbacks
00093  * \param p_val The new value
00094  * \param p_val2 Unused
00095  */
00096 #define VLC_VAR_SETVALUE            0x0013
00097 
00098 #define VLC_VAR_SETTEXT             0x0014
00099 #define VLC_VAR_GETTEXT             0x0015
00100 
00101 #define VLC_VAR_GETMIN              0x0016
00102 #define VLC_VAR_GETMAX              0x0017
00103 #define VLC_VAR_GETSTEP             0x0018
00104 
00105 #define VLC_VAR_ADDCHOICE           0x0020
00106 #define VLC_VAR_DELCHOICE           0x0021
00107 #define VLC_VAR_CLEARCHOICES        0x0022
00108 #define VLC_VAR_SETDEFAULT          0x0023
00109 #define VLC_VAR_GETCHOICES          0x0024
00110 #define VLC_VAR_GETLIST             0x0025
00111 #define VLC_VAR_CHOICESCOUNT        0x0026
00112 
00113 #define VLC_VAR_SETISCOMMAND        0x0040
00114 /**@}*/
00115 
00116 /** \defgroup var_GetAndSet Variable actions
00117  * These are the different actions that can be used with var_GetAndSet()
00118  * @{
00119  */
00120 enum {
00121     VLC_VAR_BOOL_TOGGLE, /**< Invert a boolean value (param ignored) */
00122     VLC_VAR_INTEGER_ADD, /**< Add parameter to an integer value */
00123     VLC_VAR_INTEGER_OR,  /**< Binary OR over an integer bits field */
00124     VLC_VAR_INTEGER_NAND,/**< Binary NAND over an integer bits field */
00125 };
00126 /**@}*/
00127 
00128 /*****************************************************************************
00129  * Prototypes
00130  *****************************************************************************/
00131 VLC_EXPORT( int, var_Create, ( vlc_object_t *, const char *, int ) );
00132 #define var_Create(a,b,c) var_Create( VLC_OBJECT(a), b, c )
00133 
00134 VLC_EXPORT( int, var_Destroy, ( vlc_object_t *, const char * ) );
00135 #define var_Destroy(a,b) var_Destroy( VLC_OBJECT(a), b )
00136 
00137 VLC_EXPORT( int, var_Change, ( vlc_object_t *, const char *, int, vlc_value_t *, vlc_value_t * ) );
00138 #define var_Change(a,b,c,d,e) var_Change( VLC_OBJECT(a), b, c, d, e )
00139 
00140 VLC_EXPORT( int, var_Type, ( vlc_object_t *, const char * ) LIBVLC_USED );
00141 #define var_Type(a,b) var_Type( VLC_OBJECT(a), b )
00142 
00143 VLC_EXPORT( int, var_Set, ( vlc_object_t *, const char *, vlc_value_t ) );
00144 #define var_Set(a,b,c) var_Set( VLC_OBJECT(a), b, c )
00145 
00146 VLC_EXPORT( int, var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );
00147 #define var_Get(a,b,c) var_Get( VLC_OBJECT(a), b, c )
00148 
00149 VLC_EXPORT( int, var_SetChecked, ( vlc_object_t *, const char *, int, vlc_value_t ) );
00150 #define var_SetChecked(o,n,t,v) var_SetChecked(VLC_OBJECT(o),n,t,v)
00151 VLC_EXPORT( int, var_GetChecked, ( vlc_object_t *, const char *, int, vlc_value_t * ) );
00152 #define var_GetChecked(o,n,t,v) var_GetChecked(VLC_OBJECT(o),n,t,v)
00153 VLC_EXPORT( int, var_GetAndSet, ( vlc_object_t *, const char *, int, vlc_value_t * ) );
00154 
00155 VLC_EXPORT( int, var_Inherit, ( vlc_object_t *, const char *, int, vlc_value_t * ) );
00156 
00157 VLC_EXPORT( int, var_Command, ( vlc_object_t *, const char *, const char *, const char *, char ** ) );
00158 #define var_Command(a,b,c,d,e) var_Command( VLC_OBJECT( a ), b, c, d, e )
00159 
00160 VLC_EXPORT( void, var_FreeList, ( vlc_value_t *, vlc_value_t * ) );
00161 
00162 
00163 /*****************************************************************************
00164  * Variable callbacks
00165  *****************************************************************************
00166  * int MyCallback( vlc_object_t *p_this,
00167  *                 char const *psz_variable,
00168  *                 vlc_value_t oldvalue,
00169  *                 vlc_value_t newvalue,
00170  *                 void *p_data);
00171  *****************************************************************************/
00172 VLC_EXPORT( int, var_AddCallback, ( vlc_object_t *, const char *, vlc_callback_t, void * ) );
00173 VLC_EXPORT( int, var_DelCallback, ( vlc_object_t *, const char *, vlc_callback_t, void * ) );
00174 VLC_EXPORT( int, var_TriggerCallback, ( vlc_object_t *, const char * ) );
00175 
00176 #define var_AddCallback(a,b,c,d) var_AddCallback( VLC_OBJECT(a), b, c, d )
00177 #define var_DelCallback(a,b,c,d) var_DelCallback( VLC_OBJECT(a), b, c, d )
00178 #define var_TriggerCallback(a,b) var_TriggerCallback( VLC_OBJECT(a), b )
00179 
00180 /*****************************************************************************
00181  * helpers functions
00182  *****************************************************************************/
00183 
00184 /**
00185  * Set the value of an integer variable
00186  *
00187  * \param p_obj The object that holds the variable
00188  * \param psz_name The name of the variable
00189  * \param i The new integer value of this variable
00190  */
00191 static inline int var_SetInteger( vlc_object_t *p_obj, const char *psz_name,
00192                                   int64_t i )
00193 {
00194     vlc_value_t val;
00195     val.i_int = i;
00196     return var_SetChecked( p_obj, psz_name, VLC_VAR_INTEGER, val );
00197 }
00198 
00199 /**
00200  * Set the value of an boolean variable
00201  *
00202  * \param p_obj The object that holds the variable
00203  * \param psz_name The name of the variable
00204  * \param b The new boolean value of this variable
00205  */
00206 static inline int var_SetBool( vlc_object_t *p_obj, const char *psz_name, bool b )
00207 {
00208     vlc_value_t val;
00209     val.b_bool = b;
00210     return var_SetChecked( p_obj, psz_name, VLC_VAR_BOOL, val );
00211 }
00212 
00213 /**
00214  * Set the value of a time variable
00215  *
00216  * \param p_obj The object that holds the variable
00217  * \param psz_name The name of the variable
00218  * \param i The new time value of this variable
00219  */
00220 static inline int var_SetTime( vlc_object_t *p_obj, const char *psz_name, int64_t i )
00221 {
00222     vlc_value_t val;
00223     val.i_time = i;
00224     return var_SetChecked( p_obj, psz_name, VLC_VAR_TIME, val );
00225 }
00226 
00227 static inline int var_SetCoords( vlc_object_t *obj, const char *name,
00228                                  int32_t x, int32_t y )
00229 {
00230     vlc_value_t val;
00231     val.coords.x = x;
00232     val.coords.y = y;
00233     return var_SetChecked (obj, name, VLC_VAR_COORDS, val);
00234 }
00235 #define var_SetCoords(o,n,x,y) var_SetCoords(VLC_OBJECT(o),n,x,y)
00236 
00237 /**
00238  * Set the value of a float variable
00239  *
00240  * \param p_obj The object that holds the variable
00241  * \param psz_name The name of the variable
00242  * \param f The new float value of this variable
00243  */
00244 static inline int var_SetFloat( vlc_object_t *p_obj, const char *psz_name, float f )
00245 {
00246     vlc_value_t val;
00247     val.f_float = f;
00248     return var_SetChecked( p_obj, psz_name, VLC_VAR_FLOAT, val );
00249 }
00250 
00251 /**
00252  * Set the value of a string variable
00253  *
00254  * \param p_obj The object that holds the variable
00255  * \param psz_name The name of the variable
00256  * \param psz_string The new string value of this variable
00257  */
00258 static inline int var_SetString( vlc_object_t *p_obj, const char *psz_name, const char *psz_string )
00259 {
00260     vlc_value_t val;
00261     val.psz_string = (char *)psz_string;
00262     return var_SetChecked( p_obj, psz_name, VLC_VAR_STRING, val );
00263 }
00264 
00265 /**
00266  * Set the value of a pointer variable
00267  *
00268  * \param p_obj The object that holds the variable
00269  * \param psz_name The name of the variable
00270  * \param ptr The new pointer value of this variable
00271  */
00272 static inline
00273 int var_SetAddress( vlc_object_t *p_obj, const char *psz_name, void *ptr )
00274 {
00275     vlc_value_t val;
00276     val.p_address = ptr;
00277     return var_SetChecked( p_obj, psz_name, VLC_VAR_ADDRESS, val );
00278 }
00279 
00280 #define var_SetInteger(a,b,c)   var_SetInteger( VLC_OBJECT(a),b,c)
00281 #define var_SetBool(a,b,c)      var_SetBool( VLC_OBJECT(a),b,c)
00282 #define var_SetTime(a,b,c)      var_SetTime( VLC_OBJECT(a),b,c)
00283 #define var_SetFloat(a,b,c)     var_SetFloat( VLC_OBJECT(a),b,c)
00284 #define var_SetString(a,b,c)    var_SetString( VLC_OBJECT(a),b,c)
00285 #define var_SetAddress(o, n, p) var_SetAddress(VLC_OBJECT(o), n, p)
00286 
00287 
00288 /**
00289  * Get an integer value
00290 *
00291  * \param p_obj The object that holds the variable
00292  * \param psz_name The name of the variable
00293  */
00294 LIBVLC_USED
00295 static inline int64_t var_GetInteger( vlc_object_t *p_obj, const char *psz_name )
00296 {
00297     vlc_value_t val;
00298     if( !var_GetChecked( p_obj, psz_name, VLC_VAR_INTEGER, &val ) )
00299         return val.i_int;
00300     else
00301         return 0;
00302 }
00303 
00304 /**
00305  * Get a boolean value
00306  *
00307  * \param p_obj The object that holds the variable
00308  * \param psz_name The name of the variable
00309  */
00310 LIBVLC_USED
00311 static inline bool var_GetBool( vlc_object_t *p_obj, const char *psz_name )
00312 {
00313     vlc_value_t val; val.b_bool = false;
00314 
00315     if( !var_GetChecked( p_obj, psz_name, VLC_VAR_BOOL, &val ) )
00316         return val.b_bool;
00317     else
00318         return false;
00319 }
00320 
00321 /**
00322  * Get a time value
00323  *
00324  * \param p_obj The object that holds the variable
00325  * \param psz_name The name of the variable
00326  */
00327 LIBVLC_USED
00328 static inline int64_t var_GetTime( vlc_object_t *p_obj, const char *psz_name )
00329 {
00330     vlc_value_t val; val.i_time = 0L;
00331     if( !var_GetChecked( p_obj, psz_name, VLC_VAR_TIME, &val ) )
00332         return val.i_time;
00333     else
00334         return 0;
00335 }
00336 
00337 static inline void var_GetCoords( vlc_object_t *obj, const char *name,
00338                                   int32_t *px, int32_t *py )
00339 {
00340     vlc_value_t val;
00341 
00342     if (likely(!var_GetChecked (obj, name, VLC_VAR_COORDS, &val)))
00343     {
00344         *px = val.coords.x;
00345         *py = val.coords.y;
00346     }
00347     else
00348         *px = *py = 0;
00349 }
00350 #define var_GetCoords(o,n,x,y) var_GetCoords(VLC_OBJECT(o),n,x,y)
00351 
00352 /**
00353  * Get a float value
00354  *
00355  * \param p_obj The object that holds the variable
00356  * \param psz_name The name of the variable
00357  */
00358 LIBVLC_USED
00359 static inline float var_GetFloat( vlc_object_t *p_obj, const char *psz_name )
00360 {
00361     vlc_value_t val; val.f_float = 0.0;
00362     if( !var_GetChecked( p_obj, psz_name, VLC_VAR_FLOAT, &val ) )
00363         return val.f_float;
00364     else
00365         return 0.0;
00366 }
00367 
00368 /**
00369  * Get a string value
00370  *
00371  * \param p_obj The object that holds the variable
00372  * \param psz_name The name of the variable
00373  */
00374 LIBVLC_USED
00375 static inline char *var_GetString( vlc_object_t *p_obj, const char *psz_name )
00376 {
00377     vlc_value_t val; val.psz_string = NULL;
00378     if( var_GetChecked( p_obj, psz_name, VLC_VAR_STRING, &val ) )
00379         return NULL;
00380     else
00381         return val.psz_string;
00382 }
00383 
00384 LIBVLC_USED
00385 static inline char *var_GetNonEmptyString( vlc_object_t *p_obj, const char *psz_name )
00386 {
00387     vlc_value_t val;
00388     if( var_GetChecked( p_obj, psz_name, VLC_VAR_STRING, &val ) )
00389         return NULL;
00390     if( val.psz_string && *val.psz_string )
00391         return val.psz_string;
00392     free( val.psz_string );
00393     return NULL;
00394 }
00395 
00396 LIBVLC_USED
00397 static inline void *var_GetAddress( vlc_object_t *p_obj, const char *psz_name )
00398 {
00399     vlc_value_t val;
00400     if( var_GetChecked( p_obj, psz_name, VLC_VAR_ADDRESS, &val ) )
00401         return NULL;
00402     else
00403         return val.p_address;
00404 }
00405 
00406 /**
00407  * Increment an integer variable
00408  * \param p_obj the object that holds the variable
00409  * \param psz_name the name of the variable
00410  */
00411 static inline int64_t var_IncInteger( vlc_object_t *p_obj, const char *psz_name )
00412 {
00413     vlc_value_t val;
00414     val.i_int = 1;
00415     var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_ADD, &val );
00416     return val.i_int;
00417 }
00418 #define var_IncInteger(a,b) var_IncInteger( VLC_OBJECT(a), b )
00419 
00420 /**
00421  * Decrement an integer variable
00422  * \param p_obj the object that holds the variable
00423  * \param psz_name the name of the variable
00424  */
00425 static inline int64_t var_DecInteger( vlc_object_t *p_obj, const char *psz_name )
00426 {
00427     vlc_value_t val;
00428     val.i_int = -1;
00429     var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_ADD, &val );
00430     return val.i_int;
00431 }
00432 #define var_DecInteger(a,b) var_DecInteger( VLC_OBJECT(a), b )
00433 
00434 static inline uint64_t var_OrInteger( vlc_object_t *obj, const char *name,
00435                                       unsigned v )
00436 {
00437     vlc_value_t val;
00438     val.i_int = v;
00439     var_GetAndSet( obj, name, VLC_VAR_INTEGER_OR, &val );
00440     return val.i_int;
00441 }
00442 #define var_OrInteger(a,b,c) var_OrInteger(VLC_OBJECT(a),b,c)
00443 
00444 static inline uint64_t var_NAndInteger( vlc_object_t *obj, const char *name,
00445                                         unsigned v )
00446 {
00447     vlc_value_t val;
00448     val.i_int = v;
00449     var_GetAndSet( obj, name, VLC_VAR_INTEGER_NAND, &val );
00450     return val.i_int;
00451 }
00452 #define var_NAndInteger(a,b,c) var_NAndInteger(VLC_OBJECT(a),b,c)
00453 
00454 /**
00455  * Create a integer variable with inherit and get its value.
00456  *
00457  * \param p_obj The object that holds the variable
00458  * \param psz_name The name of the variable
00459  */
00460 LIBVLC_USED
00461 static inline int64_t var_CreateGetInteger( vlc_object_t *p_obj, const char *psz_name )
00462 {
00463     var_Create( p_obj, psz_name, VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
00464     return var_GetInteger( p_obj, psz_name );
00465 }
00466 
00467 /**
00468  * Create a boolean variable with inherit and get its value.
00469  *
00470  * \param p_obj The object that holds the variable
00471  * \param psz_name The name of the variable
00472  */
00473 LIBVLC_USED
00474 static inline bool var_CreateGetBool( vlc_object_t *p_obj, const char *psz_name )
00475 {
00476     var_Create( p_obj, psz_name, VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
00477     return var_GetBool( p_obj, psz_name );
00478 }
00479 
00480 /**
00481  * Create a time variable with inherit and get its value.
00482  *
00483  * \param p_obj The object that holds the variable
00484  * \param psz_name The name of the variable
00485  */
00486 LIBVLC_USED
00487 static inline int64_t var_CreateGetTime( vlc_object_t *p_obj, const char *psz_name )
00488 {
00489     var_Create( p_obj, psz_name, VLC_VAR_TIME | VLC_VAR_DOINHERIT );
00490     return var_GetTime( p_obj, psz_name );
00491 }
00492 
00493 /**
00494  * Create a float variable with inherit and get its value.
00495  *
00496  * \param p_obj The object that holds the variable
00497  * \param psz_name The name of the variable
00498  */
00499 LIBVLC_USED
00500 static inline float var_CreateGetFloat( vlc_object_t *p_obj, const char *psz_name )
00501 {
00502     var_Create( p_obj, psz_name, VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
00503     return var_GetFloat( p_obj, psz_name );
00504 }
00505 
00506 /**
00507  * Create a string variable with inherit and get its value.
00508  *
00509  * \param p_obj The object that holds the variable
00510  * \param psz_name The name of the variable
00511  */
00512 LIBVLC_USED
00513 static inline char *var_CreateGetString( vlc_object_t *p_obj,
00514                                            const char *psz_name )
00515 {
00516     var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT );
00517     return var_GetString( p_obj, psz_name );
00518 }
00519 
00520 LIBVLC_USED
00521 static inline char *var_CreateGetNonEmptyString( vlc_object_t *p_obj,
00522                                                    const char *psz_name )
00523 {
00524     var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT );
00525     return var_GetNonEmptyString( p_obj, psz_name );
00526 }
00527 
00528 /**
00529  * Create an address variable with inherit and get its value.
00530  *
00531  * \param p_obj The object that holds the variable
00532  * \param psz_name The name of the variable
00533  */
00534 LIBVLC_USED
00535 static inline void *var_CreateGetAddress( vlc_object_t *p_obj,
00536                                            const char *psz_name )
00537 {
00538     var_Create( p_obj, psz_name, VLC_VAR_ADDRESS | VLC_VAR_DOINHERIT );
00539     return var_GetAddress( p_obj, psz_name );
00540 }
00541 
00542 #define var_CreateGetInteger(a,b)   var_CreateGetInteger( VLC_OBJECT(a),b)
00543 #define var_CreateGetBool(a,b)   var_CreateGetBool( VLC_OBJECT(a),b)
00544 #define var_CreateGetTime(a,b)   var_CreateGetTime( VLC_OBJECT(a),b)
00545 #define var_CreateGetFloat(a,b)   var_CreateGetFloat( VLC_OBJECT(a),b)
00546 #define var_CreateGetString(a,b)   var_CreateGetString( VLC_OBJECT(a),b)
00547 #define var_CreateGetNonEmptyString(a,b)   var_CreateGetNonEmptyString( VLC_OBJECT(a),b)
00548 #define var_CreateGetAddress(a,b)  var_CreateGetAddress( VLC_OBJECT(a),b)
00549 
00550 /**
00551  * Create a integer command variable with inherit and get its value.
00552  *
00553  * \param p_obj The object that holds the variable
00554  * \param psz_name The name of the variable
00555  */
00556 LIBVLC_USED
00557 static inline int64_t var_CreateGetIntegerCommand( vlc_object_t *p_obj, const char *psz_name )
00558 {
00559     var_Create( p_obj, psz_name, VLC_VAR_INTEGER | VLC_VAR_DOINHERIT
00560                                    | VLC_VAR_ISCOMMAND );
00561     return var_GetInteger( p_obj, psz_name );
00562 }
00563 
00564 /**
00565  * Create a boolean command variable with inherit and get its value.
00566  *
00567  * \param p_obj The object that holds the variable
00568  * \param psz_name The name of the variable
00569  */
00570 LIBVLC_USED
00571 static inline bool var_CreateGetBoolCommand( vlc_object_t *p_obj, const char *psz_name )
00572 {
00573     var_Create( p_obj, psz_name, VLC_VAR_BOOL | VLC_VAR_DOINHERIT
00574                                    | VLC_VAR_ISCOMMAND );
00575     return var_GetBool( p_obj, psz_name );
00576 }
00577 
00578 /**
00579  * Create a time command variable with inherit and get its value.
00580  *
00581  * \param p_obj The object that holds the variable
00582  * \param psz_name The name of the variable
00583  */
00584 LIBVLC_USED
00585 static inline int64_t var_CreateGetTimeCommand( vlc_object_t *p_obj, const char *psz_name )
00586 {
00587     var_Create( p_obj, psz_name, VLC_VAR_TIME | VLC_VAR_DOINHERIT
00588                                    | VLC_VAR_ISCOMMAND );
00589     return var_GetTime( p_obj, psz_name );
00590 }
00591 
00592 /**
00593  * Create a float command variable with inherit and get its value.
00594  *
00595  * \param p_obj The object that holds the variable
00596  * \param psz_name The name of the variable
00597  */
00598 LIBVLC_USED
00599 static inline float var_CreateGetFloatCommand( vlc_object_t *p_obj, const char *psz_name )
00600 {
00601     var_Create( p_obj, psz_name, VLC_VAR_FLOAT | VLC_VAR_DOINHERIT
00602                                    | VLC_VAR_ISCOMMAND );
00603     return var_GetFloat( p_obj, psz_name );
00604 }
00605 
00606 /**
00607  * Create a string command variable with inherit and get its value.
00608  *
00609  * \param p_obj The object that holds the variable
00610  * \param psz_name The name of the variable
00611  */
00612 LIBVLC_USED
00613 static inline char *var_CreateGetStringCommand( vlc_object_t *p_obj,
00614                                            const char *psz_name )
00615 {
00616     var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT
00617                                    | VLC_VAR_ISCOMMAND );
00618     return var_GetString( p_obj, psz_name );
00619 }
00620 
00621 LIBVLC_USED
00622 static inline char *var_CreateGetNonEmptyStringCommand( vlc_object_t *p_obj,
00623                                                    const char *psz_name )
00624 {
00625     var_Create( p_obj, psz_name, VLC_VAR_STRING | VLC_VAR_DOINHERIT
00626                                    | VLC_VAR_ISCOMMAND );
00627     return var_GetNonEmptyString( p_obj, psz_name );
00628 }
00629 
00630 #define var_CreateGetIntegerCommand(a,b)   var_CreateGetIntegerCommand( VLC_OBJECT(a),b)
00631 #define var_CreateGetBoolCommand(a,b)   var_CreateGetBoolCommand( VLC_OBJECT(a),b)
00632 #define var_CreateGetTimeCommand(a,b)   var_CreateGetTimeCommand( VLC_OBJECT(a),b)
00633 #define var_CreateGetFloatCommand(a,b)   var_CreateGetFloatCommand( VLC_OBJECT(a),b)
00634 #define var_CreateGetStringCommand(a,b)   var_CreateGetStringCommand( VLC_OBJECT(a),b)
00635 #define var_CreateGetNonEmptyStringCommand(a,b)   var_CreateGetNonEmptyStringCommand( VLC_OBJECT(a),b)
00636 
00637 LIBVLC_USED
00638 static inline int var_CountChoices( vlc_object_t *p_obj, const char *psz_name )
00639 {
00640     vlc_value_t count;
00641     if( var_Change( p_obj, psz_name, VLC_VAR_CHOICESCOUNT, &count, NULL ) )
00642         return 0;
00643     return count.i_int;
00644 }
00645 #define var_CountChoices(a,b) var_CountChoices( VLC_OBJECT(a),b)
00646 
00647 
00648 static inline bool var_ToggleBool( vlc_object_t *p_obj, const char *psz_name )
00649 {
00650     vlc_value_t val;
00651     var_GetAndSet( p_obj, psz_name, VLC_VAR_BOOL_TOGGLE, &val );
00652     return val.b_bool;
00653 }
00654 #define var_ToggleBool(a,b) var_ToggleBool( VLC_OBJECT(a),b )
00655 
00656 
00657 LIBVLC_USED
00658 static inline bool var_InheritBool( vlc_object_t *obj, const char *name )
00659 {
00660     vlc_value_t val;
00661 
00662     if( var_Inherit( obj, name, VLC_VAR_BOOL, &val ) )
00663         val.b_bool = false;
00664     return val.b_bool;
00665 }
00666 #define var_InheritBool(o, n) var_InheritBool(VLC_OBJECT(o), n)
00667 
00668 LIBVLC_USED
00669 static inline int64_t var_InheritInteger( vlc_object_t *obj, const char *name )
00670 {
00671     vlc_value_t val;
00672 
00673     if( var_Inherit( obj, name, VLC_VAR_INTEGER, &val ) )
00674         val.i_int = 0;
00675     return val.i_int;
00676 }
00677 #define var_InheritInteger(o, n) var_InheritInteger(VLC_OBJECT(o), n)
00678 
00679 LIBVLC_USED
00680 static inline float var_InheritFloat( vlc_object_t *obj, const char *name )
00681 {
00682     vlc_value_t val;
00683 
00684     if( var_Inherit( obj, name, VLC_VAR_FLOAT, &val ) )
00685         val.f_float = 0.;
00686     return val.f_float;
00687 }
00688 #define var_InheritFloat(o, n) var_InheritFloat(VLC_OBJECT(o), n)
00689 
00690 LIBVLC_USED LIBVLC_MALLOC
00691 static inline char *var_InheritString( vlc_object_t *obj, const char *name )
00692 {
00693     vlc_value_t val;
00694 
00695     if( var_Inherit( obj, name, VLC_VAR_STRING, &val ) )
00696         val.psz_string = NULL;
00697     else if( val.psz_string && !*val.psz_string )
00698     {
00699         free( val.psz_string );
00700         val.psz_string = NULL;
00701     }
00702     return val.psz_string;
00703 }
00704 #define var_InheritString(o, n) var_InheritString(VLC_OBJECT(o), n)
00705 
00706 static inline mtime_t var_InheritTime( vlc_object_t *obj, const char *name )
00707 {
00708     vlc_value_t val;
00709 
00710     if( var_Inherit( obj, name, VLC_VAR_TIME, &val ) )
00711         val.i_time = 0;
00712     return val.i_time;
00713 }
00714 #define var_InheritTime(o, n) var_InheritTime(VLC_OBJECT(o), n)
00715 
00716 static inline void *var_InheritAddress( vlc_object_t *obj, const char *name )
00717 {
00718     vlc_value_t val;
00719 
00720     if( var_Inherit( obj, name, VLC_VAR_ADDRESS, &val ) )
00721         val.p_address = NULL;
00722     return val.p_address;
00723 }
00724 #define var_InheritAddress(o, n) var_InheritAddress(VLC_OBJECT(o), n)
00725 
00726 VLC_EXPORT( int, var_InheritURational, ( vlc_object_t *, unsigned *num, unsigned *den, const char *var ) );
00727 #define var_InheritURational(a,b,c,d) var_InheritURational(VLC_OBJECT(a), b, c, d)
00728 
00729 #define var_GetInteger(a,b)   var_GetInteger( VLC_OBJECT(a),b)
00730 #define var_GetBool(a,b)   var_GetBool( VLC_OBJECT(a),b)
00731 #define var_GetTime(a,b)   var_GetTime( VLC_OBJECT(a),b)
00732 #define var_GetFloat(a,b)   var_GetFloat( VLC_OBJECT(a),b)
00733 #define var_GetString(a,b)   var_GetString( VLC_OBJECT(a),b)
00734 #define var_GetNonEmptyString(a,b)   var_GetNonEmptyString( VLC_OBJECT(a),b)
00735 #define var_GetAddress(a,b)  var_GetAddress( VLC_OBJECT(a),b)
00736 
00737 /**
00738  * @}
00739  */
00740 #endif /*  _VLC_VARIABLES_H */

Generated on Mon Nov 22 07:55:20 2010 for VLC by  doxygen 1.5.6