00001 /***************************************************************************** 00002 * var_list.hpp 00003 ***************************************************************************** 00004 * Copyright (C) 2003 the VideoLAN team 00005 * $Id$ 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 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 00023 *****************************************************************************/ 00024 00025 #ifndef VAR_LIST_HPP 00026 #define VAR_LIST_HPP 00027 00028 #include <list> 00029 00030 #include "variable.hpp" 00031 #include "observer.hpp" 00032 #include "ustring.hpp" 00033 #include "var_percent.hpp" 00034 00035 00036 /// List variable 00037 class VarList: public Variable, public Subject<VarList> 00038 { 00039 public: 00040 VarList( intf_thread_t *pIntf ); 00041 virtual ~VarList(); 00042 00043 /// Get the variable type 00044 virtual const string &getType() const { return m_type; } 00045 00046 /// Add a pointer on a string in the list 00047 virtual void add( const UStringPtr &rcString ); 00048 00049 /// Remove the selected elements from the list 00050 virtual void delSelected(); 00051 00052 /// Remove all the elements from the list 00053 virtual void clear(); 00054 00055 /// Get the number of items in the list 00056 int size() const { return m_list.size(); } 00057 00058 /// Type of an element in the list 00059 struct Elem_t 00060 { 00061 UStringPtr m_cString; 00062 bool m_selected; 00063 bool m_playing; 00064 00065 Elem_t( const UStringPtr &rcString, bool selected = false, bool 00066 playing = false ): 00067 m_cString( rcString ), m_selected( selected ), 00068 m_playing( playing) {} 00069 }; 00070 00071 /// Iterators 00072 typedef list<Elem_t>::iterator Iterator; 00073 typedef list<Elem_t>::const_iterator ConstIterator; 00074 00075 /// Beginning of the list 00076 Iterator begin() { return m_list.begin(); } 00077 ConstIterator begin() const { return m_list.begin(); } 00078 00079 /// End of the list 00080 Iterator end() { return m_list.end(); } 00081 ConstIterator end() const { return m_list.end(); } 00082 00083 /// Return an iterator on the n'th element of the list 00084 Iterator operator[]( int n ); 00085 ConstIterator operator[]( int n ) const; 00086 00087 /// Execute the action associated to this item 00088 virtual void action( Elem_t *pItem ) {} 00089 00090 /// Get a reference on the position variable 00091 VarPercent &getPositionVar() const 00092 { return *((VarPercent*)m_cPosition.get()); } 00093 00094 /// Get a counted pointer on the position variable 00095 const VariablePtr &getPositionVarPtr() const { return m_cPosition; } 00096 00097 protected: 00098 /// List of elements 00099 list<Elem_t> m_list; 00100 00101 private: 00102 /// Variable type 00103 static const string m_type; 00104 /// Position variable 00105 VariablePtr m_cPosition; 00106 }; 00107 00108 00109 #endif
1.5.1