1 /*****************************************************************************
2 * variables.cpp : VLC variable class
3 ****************************************************************************
4 * Copyright (C) 2009 RĂ©mi Denis-Courmont
5 * Copyright (C) 2006 the VideoLAN team
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
20 *****************************************************************************/
27 #include "variables.hpp"
29 QVLCVariable::QVLCVariable (vlc_object_t *obj, const char *varname, int type,
31 : object (obj), name (qfu(varname))
33 vlc_object_hold (object);
36 type |= VLC_VAR_DOINHERIT;
37 var_Create (object, qtu(name), type);
38 var_AddCallback (object, qtu(name), callback, this);
41 QVLCVariable::~QVLCVariable (void)
43 var_DelCallback (object, qtu(name), callback, this);
44 var_Destroy (object, qtu(name));
45 vlc_object_release (object);
48 int QVLCVariable::callback (vlc_object_t *object, const char *,
49 vlc_value_t old, vlc_value_t cur, void *data)
51 QVLCVariable *self = static_cast<QVLCVariable *>(data);
53 self->trigger (self->object, old, cur);
58 QVLCPointer::QVLCPointer (vlc_object_t *obj, const char *varname, bool inherit)
59 : QVLCVariable (obj, varname, VLC_VAR_ADDRESS, inherit)
63 void QVLCPointer::trigger (vlc_object_t *obj, vlc_value_t old, vlc_value_t cur)
65 emit pointerChanged (obj, old.p_address, cur.p_address);
66 emit pointerChanged (obj, cur.p_address);
70 QVLCInteger::QVLCInteger (vlc_object_t *obj, const char *varname, bool inherit)
71 : QVLCVariable (obj, varname, VLC_VAR_INTEGER, inherit)
75 void QVLCInteger::trigger (vlc_object_t *obj, vlc_value_t old, vlc_value_t cur)
77 emit integerChanged (obj, old.i_int, cur.i_int);
78 emit integerChanged (obj, cur.i_int);