variables.h 4.83 KB
Newer Older
1 2 3 4
/*****************************************************************************
 * variables.h: variables handling
 *****************************************************************************
 * Copyright (C) 2002 VideoLAN
5
 * $Id: variables.h,v 1.6 2002/10/28 13:25:56 sam Exp $
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * Authors: Samuel Hocevar <sam@zoy.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

24
typedef struct callback_entry_t callback_entry_t;
25 26 27 28 29 30 31

/*****************************************************************************
 * vlc_value_t is the common union for variable values; variable_t is the
 * structure describing a variable. 
 *****************************************************************************/
struct variable_t
{
32 33
    /* The variable's exported value */
    vlc_value_t  val;
34

35 36 37
    /* The variable unique name, (almost) unique hashed value, and type */
    char *       psz_name;
    u32          i_hash;
38 39
    int          i_type;

40
    /* Creation count: we only destroy the variable if it reaches 0 */
41
    int          i_usage;
42

43 44 45 46 47 48 49 50
    /* Set to TRUE if the variable has min/max/step values */
    vlc_bool_t   b_min, b_max, b_step;
    vlc_value_t  min, max, step;

    /* Set to TRUE if the variable is a choice variable */
    vlc_bool_t   b_select;
    vlc_value_t *p_choice;

51 52 53 54
    /* Set to TRUE if the variable is in a callback */
    vlc_bool_t   b_incallback;

    /* Registered callbacks */
55 56
    int                i_entries;
    callback_entry_t * p_entries;
57 58
};

59 60 61 62 63 64 65 66 67 68 69 70 71 72
/*****************************************************************************
 * Variable types - probably very incomplete
 *****************************************************************************/
#define VLC_VAR_BOOL      0x0100
#define VLC_VAR_INTEGER   0x0200
#define VLC_VAR_STRING    0x0300
#define VLC_VAR_MODULE    0x0301
#define VLC_VAR_FILE      0x0302
#define VLC_VAR_FLOAT     0x0400
#define VLC_VAR_TIME      0x0500
#define VLC_VAR_ADDRESS   0x0600
#define VLC_VAR_COMMAND   0x0700
#define VLC_VAR_MUTEX     0x0800

73 74 75 76 77 78 79 80 81 82 83
/*****************************************************************************
 * Variable actions
 *****************************************************************************/
#define VLC_VAR_SETMIN        0x0010
#define VLC_VAR_SETMAX        0x0011
#define VLC_VAR_SETSTEP       0x0012

#define VLC_VAR_SETCHOICE     0x0020
#define VLC_VAR_ADDCHOICE     0x0021
#define VLC_VAR_DELCHOICE     0x0022

84 85 86
/*****************************************************************************
 * Prototypes
 *****************************************************************************/
87 88
VLC_EXPORT( int, __var_Create, ( vlc_object_t *, const char *, int ) );
VLC_EXPORT( int, __var_Destroy, ( vlc_object_t *, const char * ) );
89

90 91
VLC_EXPORT( int, __var_Change, ( vlc_object_t *, const char *, int, vlc_value_t * ) );

92
VLC_EXPORT( int, __var_Type, ( vlc_object_t *, const char * ) );
93 94 95
VLC_EXPORT( int, __var_Set, ( vlc_object_t *, const char *, vlc_value_t ) );
VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );

96 97
#define var_Create(a,b,c) __var_Create( VLC_OBJECT(a), b, c )
#define var_Destroy(a,b) __var_Destroy( VLC_OBJECT(a), b )
98

99 100
#define var_Change(a,b,c,d) __var_Change( VLC_OBJECT(a), b, c, d )

101 102 103
#define var_Type(a,b) __var_Type( VLC_OBJECT(a), b )
#define var_Set(a,b,c) __var_Set( VLC_OBJECT(a), b, c )
#define var_Get(a,b,c) __var_Get( VLC_OBJECT(a), b, c )
104

105 106 107 108 109 110 111 112 113 114 115
/*****************************************************************************
 * Variable callbacks
 *****************************************************************************
 * int MyCallback( vlc_object_t *p_this,
 *                 char const *psz_variable,
 *                 vlc_value_t oldvalue,
 *                 vlc_value_t newvalue,
 *                 void *p_data);
 *****************************************************************************/
VLC_EXPORT( int, __var_AddCallback, ( vlc_object_t *, const char *, vlc_callback_t, void * ) );
VLC_EXPORT( int, __var_DelCallback, ( vlc_object_t *, const char *, vlc_callback_t, void * ) );
116

117 118
#define var_AddCallback(a,b,c,d) __var_AddCallback( VLC_OBJECT(a), b, c, d )
#define var_DelCallback(a,b,c,d) __var_DelCallback( VLC_OBJECT(a), b, c, d )
119