]> git.sesse.net Git - vlc/blob - modules/gui/skins2/commands/cmd_callbacks.hpp
Skins2: Cut #define down to size. Should result in identical functionality.
[vlc] / modules / gui / skins2 / commands / cmd_callbacks.hpp
1 /*****************************************************************************
2  * cmd_callbacks.hpp
3  *****************************************************************************
4  * Copyright (C) 2009 the VideoLAN team
5  * $Id$
6  *
7  * Author: Erwan Tulou      <erwan10 aT videolan doT org >
8  *         JP Dinger        <jpd (at) videolan (dot) org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef CMD_CALLBACKS_HPP
26 #define CMD_CALLBACKS_HPP
27
28 #include "cmd_generic.hpp"
29 #include "../src/vlcproc.hpp"
30
31 class CmdLabeled : public CmdGeneric
32 {
33 private:
34     vlc_object_t *m_pObj;
35     vlc_value_t   m_newVal;
36 protected:
37     void execute_on( void (VlcProc::*on_label)(vlc_object_t *,vlc_value_t) )
38     {
39         if( !m_pObj )
40             return;
41
42         (VlcProc::instance( getIntf() )->*on_label)( m_pObj, m_newVal );
43
44         vlc_object_release( m_pObj );
45         m_pObj =  NULL;
46     }
47     CmdLabeled( intf_thread_t *pIntf, vlc_object_t *pObj, vlc_value_t newVal )
48               : CmdGeneric( pIntf ), m_pObj( pObj ), m_newVal( newVal )
49     {
50         if( m_pObj )
51             vlc_object_hold( m_pObj );
52     }
53 public:
54     virtual ~CmdLabeled() {
55         if( m_pObj )
56             vlc_object_release( m_pObj );
57     }
58 };
59
60 #define ADD_COMMAND( label )                                            \
61     class Cmd_##label : public CmdLabeled                               \
62     {   public:                                                         \
63         Cmd_##label( intf_thread_t *I, vlc_object_t *O, vlc_value_t V ) \
64                    : CmdLabeled (I, O, V) { }                           \
65         virtual string getType() const { return #label; }               \
66         virtual void execute() { execute_on( &VlcProc::on_##label ); }  \
67     };
68
69 ADD_COMMAND( item_current_changed )
70 ADD_COMMAND( intf_event_changed )
71 ADD_COMMAND( bit_rate_changed )
72 ADD_COMMAND( sample_rate_changed )
73 ADD_COMMAND( can_record_changed )
74
75 ADD_COMMAND( random_changed )
76 ADD_COMMAND( loop_changed )
77 ADD_COMMAND( repeat_changed )
78
79 ADD_COMMAND( volume_changed )
80
81 ADD_COMMAND( audio_filter_changed )
82
83 #undef ADD_COMMAND
84
85 #endif