1 /*****************************************************************************
2  * cmd_vars.hpp
3  *****************************************************************************
4  * Copyright (C) 2004 the VideoLAN team
5  * $Id: 73aab301053b616c3225ad0d23a1e51a1a343f87 $
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23 
24 #ifndef CMD_VARS_HPP
25 #define CMD_VARS_HPP
26 
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30 
31 #include <vlc_common.h>
32 #include <vlc_playlist.h>
33 #include <vlc_input_item.h>
34 
35 #include "cmd_generic.hpp"
36 #include "../utils/ustring.hpp"
37 
38 class EqualizerBands;
39 class EqualizerPreamp;
40 class VarText;
41 
42 /// Command to notify the playtree of an item update
43 class CmdItemUpdate: public CmdGeneric
44 {
45 public:
CmdItemUpdate(intf_thread_t * pIntf,input_item_t * pItem)46     CmdItemUpdate( intf_thread_t *pIntf, input_item_t* pItem ):
47         CmdGeneric( pIntf ), m_pItem( pItem )
48     {
49         if( pItem )
50             input_item_Hold( pItem );
51     }
~CmdItemUpdate()52     virtual ~CmdItemUpdate()
53     {
54         if( m_pItem )
55             input_item_Release( m_pItem );
56     }
57     virtual void execute();
getType() const58     virtual std::string getType() const { return "playtree update"; }
59 
60     /// Only accept removal of command if they concern the same item
61     virtual bool checkRemove( CmdGeneric * ) const;
62 
63 private:
64     /// input item changed
65     input_item_t* m_pItem;
66 };
67 
68 /// Command to notify the playtree of an item append
69 class CmdPlaytreeAppend: public CmdGeneric
70 {
71 public:
CmdPlaytreeAppend(intf_thread_t * pIntf,int i_id)72     CmdPlaytreeAppend( intf_thread_t *pIntf, int i_id ):
73         CmdGeneric( pIntf ), m_id( i_id )
74     { }
~CmdPlaytreeAppend()75     virtual ~CmdPlaytreeAppend() { }
76     virtual void execute();
getType() const77     virtual std::string getType() const { return "playtree append"; }
78 
79 private:
80     int m_id;
81 };
82 
83 /// Command to notify the playtree of an item deletion
84 class CmdPlaytreeDelete: public CmdGeneric
85 {
86 public:
CmdPlaytreeDelete(intf_thread_t * pIntf,int i_id)87     CmdPlaytreeDelete( intf_thread_t *pIntf, int i_id ):
88         CmdGeneric( pIntf ), m_id( i_id ) { }
~CmdPlaytreeDelete()89     virtual ~CmdPlaytreeDelete() { }
90     virtual void execute();
getType() const91     virtual std::string getType() const { return "playtree append"; }
92 
93 private:
94     int m_id;
95 };
96 
97 
98 /// Command to set a text variable
99 class CmdSetText: public CmdGeneric
100 {
101 public:
CmdSetText(intf_thread_t * pIntf,VarText & rText,const UString & rValue)102     CmdSetText( intf_thread_t *pIntf, VarText &rText, const UString &rValue ):
103         CmdGeneric( pIntf ), m_rText( rText ), m_value( rValue ) { }
~CmdSetText()104     virtual ~CmdSetText() { }
105     virtual void execute();
getType() const106     virtual std::string getType() const { return "set text"; }
107 
108 private:
109     /// Text variable to set
110     VarText &m_rText;
111     /// Value to set
112     const UString m_value;
113 };
114 
115 
116 /// Command to set the equalizer preamp
117 class CmdSetEqPreamp: public CmdGeneric
118 {
119 public:
CmdSetEqPreamp(intf_thread_t * I,EqualizerPreamp & P,float v)120     CmdSetEqPreamp( intf_thread_t *I, EqualizerPreamp &P, float v )
121                   : CmdGeneric( I ), m_rPreamp( P ), m_value( v ) { }
~CmdSetEqPreamp()122     virtual ~CmdSetEqPreamp() { }
123     virtual void execute();
getType() const124     virtual std::string getType() const { return "set equalizer preamp"; }
125 
126 private:
127     /// Preamp variable to set
128     EqualizerPreamp &m_rPreamp;
129     /// Value to set
130     float m_value;
131 };
132 
133 
134 /// Command to set the equalizerbands
135 class CmdSetEqBands: public CmdGeneric
136 {
137 public:
CmdSetEqBands(intf_thread_t * I,EqualizerBands & B,const std::string & V)138     CmdSetEqBands( intf_thread_t *I, EqualizerBands &B, const std::string &V )
139                  : CmdGeneric( I ), m_rEqBands( B ), m_value( V ) { }
~CmdSetEqBands()140     virtual ~CmdSetEqBands() { }
141     virtual void execute();
getType() const142     virtual std::string getType() const { return "set equalizer bands"; }
143 
144 private:
145     /// Equalizer variable to set
146     EqualizerBands &m_rEqBands;
147     /// Value to set
148     const std::string m_value;
149 };
150 
151 
152 #endif
153