cmd_generic.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * cmd_generic.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: a20027ce433657d467c0c21346c9f2d7e1549d13 $
00006  *
00007  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
00008  *          Olivier Teulière <ipkiss@via.ecp.fr>
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_GENERIC_HPP
00026 #define CMD_GENERIC_HPP
00027 
00028 #include <string>
00029 
00030 #include "../src/skin_common.hpp"
00031 #include "../utils/pointer.hpp"
00032 
00033 
00034 /// Macro to define the prototype of simple commands
00035 #define DEFINE_COMMAND( name, type )                           \
00036 class Cmd##name: public CmdGeneric                             \
00037 {   public:                                                    \
00038     Cmd##name( intf_thread_t *pIntf ): CmdGeneric( pIntf ) { } \
00039     virtual ~Cmd##name() { }                                   \
00040     virtual void execute();                                    \
00041     virtual string getType() const { return type; }            \
00042 };
00043 
00044 
00045 /// Macro to define a "callback" command inside a class
00046 #define DEFINE_CALLBACK( parent, action )                            \
00047 class Cmd##action: public CmdGeneric                                 \
00048 {                                                                    \
00049 public:                                                              \
00050     Cmd##action( parent *pParent ):                                  \
00051         CmdGeneric( pParent->getIntf() ), m_pParent( pParent ) { }   \
00052     virtual ~Cmd##action() { }                                       \
00053     virtual void execute();                                          \
00054     virtual string getType() const { return "Cmd" #parent #action; } \
00055 private:                                                             \
00056     parent *m_pParent;                                               \
00057 } m_cmd##action;                                                     \
00058 friend class Cmd##action;
00059 
00060 
00061 /// Base class for skins commands
00062 class CmdGeneric: public SkinObject
00063 {
00064 public:
00065     virtual ~CmdGeneric() { }
00066 
00067     /// This method does the real job of the command
00068     virtual void execute() = 0;
00069 
00070     /// Return the type of the command
00071     virtual string getType() const { return ""; }
00072 
00073     /// During queue reductions, check if we really want to remove
00074     /// this command.
00075     virtual bool checkRemove( CmdGeneric * ) const { return true; }
00076 
00077 protected:
00078     CmdGeneric( intf_thread_t *pIntf ): SkinObject( pIntf ) { }
00079 };
00080 
00081 
00082 typedef CountedPtr<CmdGeneric> CmdGenericPtr;
00083 
00084 
00085 #endif

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