00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FXOBJECTLIST_H
00022 #define FXOBJECTLIST_H
00023
00024 #ifndef FXOBJECT_H
00025 #include "FXObject.h"
00026 #endif
00027
00028 namespace FX {
00029
00031 class FXAPI FXObjectList {
00032 protected:
00033 FXObject **ptr;
00034 public:
00035
00037 FXObjectList();
00038
00040 FXObjectList(const FXObjectList& src);
00041
00043 FXObjectList(FXObject* object);
00044
00046 FXObjectList(FXObject* object,FXint n);
00047
00049 FXObjectList(FXObject** objects,FXint n);
00050
00052 FXObjectList& operator=(const FXObjectList& orig);
00053
00055 FXint no() const { return *((FXint*)(ptr-1)); }
00056
00058 FXbool no(FXint num);
00059
00061 FXObject*& operator[](FXint i){ return ptr[i]; }
00062 FXObject* const& operator[](FXint i) const { return ptr[i]; }
00063
00065 FXObject*& at(FXint i){ return ptr[i]; }
00066 FXObject* const& at(FXint i) const { return ptr[i]; }
00067
00069 FXObject*& head(){ return ptr[0]; }
00070 FXObject* const& head() const { return ptr[0]; }
00071
00073 FXObject*& tail(){ return ptr[no()-1]; }
00074 FXObject* const& tail() const { return ptr[no()-1]; }
00075
00077 FXObject** data(){ return ptr; }
00078 FXObject *const * data() const { return ptr; }
00079
00081 void adopt(FXObjectList& orig);
00082
00084 FXbool assign(FXObject* object);
00085
00087 FXbool assign(FXObject* object,FXint n);
00088
00090 FXbool assign(FXObject** objects,FXint n);
00091
00093 FXbool assign(const FXObjectList& objects);
00094
00096 FXbool insert(FXint pos,FXObject* object);
00097
00099 FXbool insert(FXint pos,FXObject* object,FXint n);
00100
00102 FXbool insert(FXint pos,FXObject** objects,FXint n);
00103
00105 FXbool insert(FXint pos,const FXObjectList& objects);
00106
00108 FXbool prepend(FXObject* object);
00109
00111 FXbool prepend(FXObject* object,FXint n);
00112
00114 FXbool prepend(FXObject** objects,FXint n);
00115
00117 FXbool prepend(const FXObjectList& objects);
00118
00120 FXbool append(FXObject* object);
00121
00123 FXbool append(FXObject* object,FXint n);
00124
00126 FXbool append(FXObject** objects,FXint n);
00127
00129 FXbool append(const FXObjectList& objects);
00130
00132 FXbool replace(FXint pos,FXObject* object);
00133
00135 FXbool replace(FXint pos,FXint m,FXObject* object,FXint n);
00136
00138 FXbool replace(FXint pos,FXint m,FXObject** objects,FXint n);
00139
00141 FXbool replace(FXint pos,FXint m,const FXObjectList& objects);
00142
00144 FXbool erase(FXint pos);
00145
00147 FXbool erase(FXint pos,FXint n);
00148
00150 FXbool push(FXObject* object);
00151
00153 FXbool pop();
00154
00156 FXbool remove(const FXObject* object);
00157
00159 FXint find(const FXObject *object,FXint pos=0) const;
00160
00162 FXint rfind(const FXObject *object,FXint pos=2147483647) const;
00163
00165 void clear();
00166
00168 void save(FXStream& store) const;
00169
00171 void load(FXStream& store);
00172
00174 virtual ~FXObjectList();
00175 };
00176
00177
00179 template<class TYPE>
00180 class FXObjectListOf : public FXObjectList {
00181 public:
00183 FXObjectListOf(){}
00184
00186 FXObjectListOf(const FXObjectListOf<TYPE>& src):FXObjectList(src){ }
00187
00189 FXObjectListOf(TYPE* object):FXObjectList(reinterpret_cast<FXObject*>(object)){ }
00190
00192 FXObjectListOf(TYPE* object,FXint n):FXObjectList(reinterpret_cast<FXObject*>(object),n){ }
00193
00195 FXObjectListOf(TYPE** objects,FXint n):FXObjectList(reinterpret_cast<FXObject**>(objects),n){ }
00196
00198 TYPE*& operator[](FXint i){ return reinterpret_cast<TYPE*&>(ptr[i]); }
00199 TYPE *const& operator[](FXint i) const { return reinterpret_cast<TYPE*const&>(ptr[i]); }
00200
00202 TYPE*& at(FXint i){ return reinterpret_cast<TYPE*&>(ptr[i]); }
00203 TYPE *const& at(FXint i) const { return reinterpret_cast<TYPE*const&>(ptr[i]); }
00204
00206 TYPE*& head(){ return reinterpret_cast<TYPE*&>(ptr[0]); }
00207 TYPE* const& head() const { return reinterpret_cast<TYPE*const&>(ptr[0]); }
00208
00210 TYPE*& tail(){ return reinterpret_cast<TYPE*&>(ptr[no()-1]); }
00211 TYPE* const& tail() const { return reinterpret_cast<TYPE* const&>(ptr[no()-1]); }
00212
00214 TYPE** data(){ return reinterpret_cast<TYPE**>(ptr); }
00215 TYPE *const * data() const { return reinterpret_cast<TYPE*const*>(ptr); }
00216 };
00217
00218 }
00219
00220 #endif