]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/utils/var_bool.hpp
Removes trailing spaces. Removes tabs.
[vlc] / modules / gui / skins2 / utils / var_bool.hpp
old mode 100755 (executable)
new mode 100644 (file)
index e24361f..5b3cab3
@@ -1,11 +1,11 @@
 /*****************************************************************************
  * var_bool.hpp
  *****************************************************************************
- * Copyright (C) 2003 VideoLAN
- * $Id: var_bool.hpp,v 1.1 2004/01/03 23:31:34 asmax Exp $
+ * Copyright (C) 2003 the VideoLAN team
+ * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
- *          Olivier Teulière <ipkiss@via.ecp.fr>
+ *          Olivier Teulière <ipkiss@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifndef VAR_BOOL_HPP
 #include "observer.hpp"
 
 
-/// Percentage variable
+/// Interface for read-only boolean variable
 class VarBool: public Variable, public Subject<VarBool>
 {
     public:
-        VarBool( intf_thread_t *pIntf );
+        /// Get the variable type
+        virtual const string &getType() const { return m_type; }
+
+        /// Get the boolean value
+        virtual bool get() const = 0;
+
+    protected:
+        VarBool( intf_thread_t *pIntf ): Variable( pIntf ) {}
         virtual ~VarBool() {}
 
+    private:
+        /// Variable type
+        static const string m_type;
+};
+
+
+/// Constant true VarBool
+class VarBoolTrue: public VarBool
+{
+    public:
+        VarBoolTrue( intf_thread_t *pIntf ): VarBool( pIntf ) {}
+        virtual ~VarBoolTrue() {}
+        virtual bool get() const { return true; }
+};
+
+
+/// Constant false VarBool
+class VarBoolFalse: public VarBool
+{
+    public:
+        VarBoolFalse( intf_thread_t *pIntf ): VarBool( pIntf ) {}
+        virtual ~VarBoolFalse() {}
+        virtual bool get() const { return false; }
+};
+
+
+/// Boolean variable implementation (read/write)
+class VarBoolImpl: public VarBool
+{
+    public:
+        VarBoolImpl( intf_thread_t *pIntf );
+        virtual ~VarBoolImpl() {}
+
+        // Get the boolean value
+        virtual bool get() const { return m_value; }
+
         /// Set the internal value
         virtual void set( bool value );
-        virtual bool get() const { return m_value; }
 
     private:
+        /// Boolean value
         bool m_value;
 };
 
+
+/// Conjunction of two boolean variables (AND)
+class VarBoolAndBool: public VarBool, public Observer<VarBool>
+{
+    public:
+        VarBoolAndBool( intf_thread_t *pIntf, VarBool &rVar1, VarBool &rVar2 );
+        virtual ~VarBoolAndBool();
+
+        // Get the boolean value
+        virtual bool get() const { return m_rVar1.get() && m_rVar2.get(); }
+
+        // Called when one of the observed variables is changed
+        void onUpdate( Subject<VarBool> &rVariable, void* );
+
+    private:
+        /// Boolean variables
+        VarBool &m_rVar1, &m_rVar2;
+};
+
+
+/// Disjunction of two boolean variables (OR)
+class VarBoolOrBool: public VarBool, public Observer<VarBool>
+{
+    public:
+        VarBoolOrBool( intf_thread_t *pIntf, VarBool &rVar1, VarBool &rVar2 );
+        virtual ~VarBoolOrBool();
+
+        // Get the boolean value
+        virtual bool get() const { return m_rVar1.get() || m_rVar2.get(); }
+
+        // Called when one of the observed variables is changed
+        void onUpdate( Subject<VarBool> &rVariable, void* );
+
+    private:
+        /// Boolean variables
+        VarBool &m_rVar1, &m_rVar2;
+};
+
+
+/// Negation of a boolean variable (NOT)
+class VarNotBool: public VarBool, public Observer<VarBool>
+{
+    public:
+        VarNotBool( intf_thread_t *pIntf, VarBool &rVar );
+        virtual ~VarNotBool();
+
+        // Get the boolean value
+        virtual bool get() const { return !m_rVar.get(); }
+
+        // Called when the observed variable is changed
+        void onUpdate( Subject<VarBool> &rVariable, void* );
+
+    private:
+        /// Boolean variable
+        VarBool &m_rVar;
+};
+
+
 #endif