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

var_tree.hpp

00001 /*****************************************************************************
00002  * var_tree.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2005 VideoLAN
00005  * $Id: var_bool.hpp 9934 2005-02-15 13:55:08Z courmisch $
00006  *
00007  * Authors: Antoine Cellerier <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 #ifndef VAR_TREE_HPP
00025 #define VAR_TREE_HPP
00026 
00027 #include <list>
00028 
00029 #include "variable.hpp"
00030 #include "observer.hpp"
00031 #include "ustring.hpp"
00032 #include "var_percent.hpp"
00033 
00035 class VarTree: public Variable, public Subject<VarTree>
00036 {
00037     public:
00038         VarTree( intf_thread_t *pIntf );
00039 
00040         VarTree( intf_thread_t *pIntf, VarTree *pParent, int id,
00041                  const UStringPtr &rcString, bool selected, bool playing,
00042                  bool expanded, void *pData );
00043 
00044         virtual ~VarTree();
00045 
00047         virtual const string &getType() const { return m_type; }
00048 
00050         virtual void add( int id, const UStringPtr &rcString, bool selected,
00051                           bool playing, bool expanded, void *pData );
00052 
00054         virtual void delSelected();
00055 
00057         virtual void clear();
00058 
00060         int m_id;
00061         UStringPtr m_cString;
00062         bool m_selected;
00063         bool m_playing;
00064         bool m_expanded;
00065         void *m_pData;
00066 
00068         int size() const { return m_children.size(); }
00069 
00071         typedef list<VarTree>::iterator Iterator;
00072         typedef list<VarTree>::const_iterator ConstIterator;
00073 
00075         Iterator begin() { return m_children.begin(); }
00076         ConstIterator begin() const { return m_children.begin(); }
00077 
00079         Iterator end() { return m_children.end(); }
00080         ConstIterator end() const { return m_children.end(); }
00081 
00083         VarTree &back() { return m_children.back(); }
00084 
00086         Iterator operator[]( int n );
00087         ConstIterator operator[]( int n ) const;
00088 
00090         VarTree *parent() { return m_pParent; }
00091         void VarTree::checkParents( VarTree *pParent );
00092 
00093         Iterator uncle();
00094 
00096         VarTree *root()
00097         {
00098             VarTree *parent = this;
00099             while( parent->parent() != NULL )
00100                 parent = parent->parent();
00101             return parent;
00102         }
00103 
00105         int depth()
00106         {
00107             VarTree *parent = this;
00108             int depth = 0;
00109             while( ( parent = parent->parent() ) != NULL )
00110                 depth++;
00111             return depth;
00112         }
00113 
00115         virtual void action( VarTree *pItem ) {}
00116 
00118         VarPercent &getPositionVar() const
00119         { return *((VarPercent*)m_cPosition.get()); }
00120 
00122         const VariablePtr &getPositionVarPtr() const { return m_cPosition; }
00123 
00125         int visibleItems();
00126 
00128         Iterator getVisibleItem( int n );
00129 
00131         Iterator getNextVisibleItem( Iterator it );
00132 
00134         Iterator findById( int id );
00135 
00136     private:
00138         list<VarTree> m_children;
00139 
00141         VarTree *m_pParent;
00142 
00144         static const string m_type;
00145 
00147         VariablePtr m_cPosition;
00148 };
00149 
00150 #endif

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