![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * O b j e c t L i s t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1997,2002 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************* 00022 * $Id: FXObjectList.h,v 1.16 2002/01/18 22:42:54 jeroen Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXOBJECTLIST_H 00025 #define FXOBJECTLIST_H 00026 00027 00028 /// List of pointers to objects 00029 class FXAPI FXObjectList { 00030 protected: 00031 FXObject **data; /// List of items 00032 FXint num; /// Used slots 00033 FXint max; /// Total slots 00034 public: 00035 00036 /// Default constructor 00037 FXObjectList(); 00038 00039 /// Copy constructor 00040 FXObjectList(const FXObjectList& orig); 00041 00042 /// Assignment operator 00043 FXObjectList& operator=(const FXObjectList& orig); 00044 00045 /// Return number of elements 00046 FXint no() const { return num; } 00047 00048 /// Set number of elements 00049 void no(FXint n); 00050 00051 /// Return size of list 00052 FXint size() const { return max; } 00053 00054 /// Set max number of elements 00055 void size(FXint m); 00056 00057 /// Indexing operator 00058 FXObject*& operator[](FXint i){ return data[i]; } 00059 FXObject* const& operator[](FXint i) const { return data[i]; } 00060 00061 /// Access to list 00062 FXObject*& list(FXint i){ return data[i]; } 00063 FXObject* const& list(FXint i) const { return data[i]; } 00064 00065 /// Access to content array 00066 FXObject** list() const { return data; } 00067 00068 /// Insert element at certain position 00069 void insert(FXint pos,FXObject* p); 00070 00071 /// Prepend element 00072 void prepend(FXObject* p); 00073 00074 /// Append element 00075 void append(FXObject* p); 00076 00077 /// Replace element 00078 void replace(FXint pos,FXObject* p); 00079 00080 /// Remove element at pos 00081 void remove(FXint pos); 00082 00083 /// Remove element p 00084 void remove(const FXObject* p); 00085 00086 /// Find object in list, searching forward; return position or -1 00087 FXint findf(const FXObject *p,FXint pos=0) const; 00088 00089 /// Find object in list, searching backward; return position or -1 00090 FXint findb(const FXObject *p,FXint pos=2147483647) const; 00091 00092 /// Remove all elements 00093 void clear(); 00094 00095 /// Save to a stream 00096 void save(FXStream& store) const; 00097 00098 /// Load from a stream 00099 void load(FXStream& store); 00100 00101 /// Destructor 00102 virtual ~FXObjectList(); 00103 }; 00104 00105 00106 /// Specialize list to pointers to TYPE 00107 template<class TYPE> 00108 class FXObjectListOf : public FXObjectList { 00109 public: 00110 FXObjectListOf(){} 00111 00112 /// Indexing operator 00113 TYPE*& operator[](FXint i){ return (TYPE*&)data[i]; } 00114 TYPE *const& operator[](FXint i) const { return (TYPE*const&)data[i]; } 00115 00116 /// Access to list 00117 TYPE*& list(FXint i){ return (TYPE*&)data[i]; } 00118 TYPE *const& list(FXint i) const { return (TYPE*const&)data[i]; } 00119 00120 /// Access to content array 00121 TYPE** list() const { return (TYPE**)data; } 00122 }; 00123 00124 #endif