cmd_callbacks.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * cmd_callbacks.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2009 the VideoLAN team
00005  * $Id: 579c6fa3729ec5435be4e569b15b5f4a6cdf91f0 $
00006  *
00007  * Author: Erwan Tulou      <erwan10 aT videolan doT org >
00008  *         JP Dinger        <jpd (at) videolan (dot) org>
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 along
00021  * with this program; if not, write to the Free Software Foundation, Inc.,
00022  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef CMD_CALLBACKS_HPP
00026 #define CMD_CALLBACKS_HPP
00027 
00028 #include "cmd_generic.hpp"
00029 #include "../src/vlcproc.hpp"
00030 
00031 class CmdLabeled : public CmdGeneric
00032 {
00033 private:
00034     vlc_object_t *m_pObj;
00035     vlc_value_t   m_newVal;
00036 protected:
00037     void execute_on( void (VlcProc::*on_label)(vlc_object_t *,vlc_value_t) )
00038     {
00039         if( !m_pObj )
00040             return;
00041 
00042         (VlcProc::instance( getIntf() )->*on_label)( m_pObj, m_newVal );
00043 
00044         vlc_object_release( m_pObj );
00045         m_pObj =  NULL;
00046     }
00047     CmdLabeled( intf_thread_t *pIntf, vlc_object_t *pObj, vlc_value_t newVal )
00048               : CmdGeneric( pIntf ), m_pObj( pObj ), m_newVal( newVal )
00049     {
00050         if( m_pObj )
00051             vlc_object_hold( m_pObj );
00052     }
00053 public:
00054     virtual ~CmdLabeled() {
00055         if( m_pObj )
00056             vlc_object_release( m_pObj );
00057     }
00058 };
00059 
00060 #define ADD_COMMAND( label )                                            \
00061     class Cmd_##label : public CmdLabeled                               \
00062     {   public:                                                         \
00063         Cmd_##label( intf_thread_t *I, vlc_object_t *O, vlc_value_t V ) \
00064                    : CmdLabeled (I, O, V) { }                           \
00065         virtual string getType() const { return #label; }               \
00066         virtual void execute() { execute_on( &VlcProc::on_##label ); }  \
00067     };
00068 
00069 ADD_COMMAND( item_current_changed )
00070 ADD_COMMAND( intf_event_changed )
00071 ADD_COMMAND( bit_rate_changed )
00072 ADD_COMMAND( sample_rate_changed )
00073 ADD_COMMAND( can_record_changed )
00074 
00075 ADD_COMMAND( random_changed )
00076 ADD_COMMAND( loop_changed )
00077 ADD_COMMAND( repeat_changed )
00078 
00079 ADD_COMMAND( volume_changed )
00080 
00081 ADD_COMMAND( audio_filter_changed )
00082 
00083 ADD_COMMAND( intf_show_changed )
00084 
00085 #undef ADD_COMMAND
00086 
00087 #endif

Generated on Tue May 25 08:04:58 2010 for VLC by  doxygen 1.5.6