LPtrList.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef LPtrList_H
00038 #define LPtrList_H
00039
00040 #include "LList.H"
00041
00042
00043
00044 namespace Foam
00045 {
00046
00047
00048
00049 template<class LListBase, class T> class LPtrList;
00050
00051 template<class LListBase, class T>
00052 Istream& operator>>
00053 (
00054 Istream&,
00055 LPtrList<LListBase, T>&
00056 );
00057
00058 template<class LListBase, class T>
00059 Ostream& operator<<
00060 (
00061 Ostream&,
00062 const LPtrList<LListBase, T>&
00063 );
00064
00065
00066
00067
00068
00069
00070 template<class LListBase, class T>
00071 class LPtrList
00072 :
00073 public LList<LListBase, T*>
00074 {
00075
00076
00077
00078 template<class INew>
00079 void read(Istream&, const INew& inewt);
00080
00081
00082 public:
00083
00084
00085
00086 class iterator;
00087 friend class iterator;
00088
00089 class const_iterator;
00090 friend class const_iterator;
00091
00092
00093
00094
00095
00096 LPtrList()
00097 {}
00098
00099
00100 LPtrList(T* a)
00101 :
00102 LList<LListBase, T*>(a)
00103 {}
00104
00105
00106 template<class INew>
00107 LPtrList(Istream&, const INew&);
00108
00109
00110 LPtrList(Istream&);
00111
00112
00113 LPtrList(const LPtrList&);
00114
00115
00116
00117
00118 ~LPtrList();
00119
00120
00121
00122
00123
00124
00125
00126 T& first()
00127 {
00128 return *LList<LListBase, T*>::first();
00129 }
00130
00131
00132 const T& first() const
00133 {
00134 return *LList<LListBase, T*>::first();
00135 }
00136
00137
00138 T& last()
00139 {
00140 return *LList<LListBase, T*>::last();
00141 }
00142
00143
00144 const T& last() const
00145 {
00146 return *LList<LListBase, T*>::last();
00147 }
00148
00149
00150
00151
00152
00153 bool eraseHead();
00154
00155
00156 void clear();
00157
00158
00159
00160 void transfer(LPtrList<LListBase, T>&);
00161
00162
00163
00164
00165
00166 void operator=(const LPtrList<LListBase, T>&);
00167
00168
00169
00170
00171
00172
00173 typedef T& reference;
00174
00175
00176
00177 typedef T& const_reference;
00178
00179
00180
00181
00182 typedef typename LListBase::iterator LListBase_iterator;
00183
00184
00185 class iterator
00186 :
00187 public LList<LListBase, T*>::iterator
00188 {
00189
00190 public:
00191
00192
00193 iterator
00194 (
00195 LListBase_iterator baseIter
00196 )
00197 :
00198 LList<LListBase, T*>::iterator(baseIter)
00199 {}
00200
00201
00202
00203
00204 T& operator*()
00205 {
00206 return *(LList<LListBase, T*>::iterator::operator*());
00207 }
00208
00209 T& operator()()
00210 {
00211 return operator*();
00212 }
00213 };
00214
00215
00216
00217
00218 typedef typename LListBase::const_iterator LListBase_const_iterator;
00219
00220
00221 class const_iterator
00222 :
00223 public LList<LListBase, T*>::const_iterator
00224 {
00225
00226 public:
00227
00228
00229 const_iterator
00230 (
00231 LListBase_const_iterator baseIter
00232 )
00233 :
00234 LList<LListBase, T*>::const_iterator(baseIter)
00235 {}
00236
00237
00238 const_iterator
00239 (
00240 LListBase_iterator baseIter
00241 )
00242 :
00243 LList<LListBase, T*>::const_iterator(baseIter)
00244 {}
00245
00246
00247
00248
00249 const T& operator*()
00250 {
00251 return *(LList<LListBase, T*>::const_iterator::operator*());
00252 }
00253
00254 const T& operator()()
00255 {
00256 return operator*();
00257 }
00258 };
00259
00260
00261
00262
00263 friend Istream& operator>> <LListBase, T>
00264 (
00265 Istream&,
00266 LPtrList<LListBase, T>&
00267 );
00268
00269 friend Ostream& operator<< <LListBase, T>
00270 (
00271 Ostream&,
00272 const LPtrList<LListBase, T>&
00273 );
00274 };
00275
00276
00277
00278
00279 }
00280
00281
00282
00283 #ifdef NoRepository
00284 # include "LPtrList.C"
00285 #endif
00286
00287
00288
00289 #endif
00290
00291
Copyright © 2000-2009 OpenCFD Ltd