Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

var_bool.hpp

00001 /*****************************************************************************
00002  * var_bool.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: var_bool.hpp 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Cyril Deguet     <[email protected]>
00008  *          Olivier Teulière <[email protected]>
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
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef VAR_BOOL_HPP
00026 #define VAR_BOOL_HPP
00027 
00028 #include "variable.hpp"
00029 #include "observer.hpp"
00030 
00031 
00033 class VarBool: public Variable, public Subject<VarBool>
00034 {
00035     public:
00037         virtual const string &getType() const { return m_type; }
00038 
00040         virtual bool get() const = 0;
00041 
00042     protected:
00043         VarBool( intf_thread_t *pIntf ): Variable( pIntf ) {}
00044         virtual ~VarBool() {}
00045 
00046     private:
00048         static const string m_type;
00049 };
00050 
00051 
00053 class VarBoolTrue: public VarBool
00054 {
00055     public:
00056         VarBoolTrue( intf_thread_t *pIntf ): VarBool( pIntf ) {}
00057         virtual ~VarBoolTrue() {}
00058         virtual bool get() const { return true; }
00059 };
00060 
00061 
00063 class VarBoolFalse: public VarBool
00064 {
00065     public:
00066         VarBoolFalse( intf_thread_t *pIntf ): VarBool( pIntf ) {}
00067         virtual ~VarBoolFalse() {}
00068         virtual bool get() const { return false; }
00069 };
00070 
00071 
00073 class VarBoolImpl: public VarBool
00074 {
00075     public:
00076         VarBoolImpl( intf_thread_t *pIntf );
00077         virtual ~VarBoolImpl() {}
00078 
00079         // Get the boolean value
00080         virtual bool get() const { return m_value; }
00081 
00083         virtual void set( bool value );
00084 
00085     private:
00087         bool m_value;
00088 };
00089 
00090 
00092 class VarBoolAndBool: public VarBool, public Observer<VarBool>
00093 {
00094     public:
00095         VarBoolAndBool( intf_thread_t *pIntf, VarBool &rVar1, VarBool &rVar2 );
00096         virtual ~VarBoolAndBool();
00097 
00098         // Get the boolean value
00099         virtual bool get() const { return m_rVar1.get() && m_rVar2.get(); }
00100 
00101         // Called when one of the observed variables is changed
00102         void onUpdate( Subject<VarBool> &rVariable );
00103 
00104     private:
00106         VarBool &m_rVar1, &m_rVar2;
00107 };
00108 
00109 
00111 class VarBoolOrBool: public VarBool, public Observer<VarBool>
00112 {
00113     public:
00114         VarBoolOrBool( intf_thread_t *pIntf, VarBool &rVar1, VarBool &rVar2 );
00115         virtual ~VarBoolOrBool();
00116 
00117         // Get the boolean value
00118         virtual bool get() const { return m_rVar1.get() || m_rVar2.get(); }
00119 
00120         // Called when one of the observed variables is changed
00121         void onUpdate( Subject<VarBool> &rVariable );
00122 
00123     private:
00125         VarBool &m_rVar1, &m_rVar2;
00126 };
00127 
00128 
00130 class VarNotBool: public VarBool, public Observer<VarBool>
00131 {
00132     public:
00133         VarNotBool( intf_thread_t *pIntf, VarBool &rVar );
00134         virtual ~VarNotBool();
00135 
00136         // Get the boolean value
00137         virtual bool get() const { return !m_rVar.get(); }
00138 
00139         // Called when the observed variable is changed
00140         void onUpdate( Subject<VarBool> &rVariable );
00141 
00142     private:
00144         VarBool &m_rVar;
00145 };
00146 
00147 
00148 #endif

Generated on Tue Dec 20 10:14:43 2005 for vlc-0.8.4a by  doxygen 1.4.2