![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /******************************************************************************* 00002 ** Copyright (c) 1999 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 *******************************************************************************/ 00005 00008 00009 #pragma once 00010 00011 class DtRwIntrusiveList; 00012 class DtRwListedObj; 00013 00014 #include <mtl/mtl.h> 00015 #include <vlutil/vlList.h> 00016 #include "vrfutil/rdrWritr.h" 00017 00037 #include "vrfutil/vrfutilDefines.h" 00038 class DT_DLL_vrfutil DtRwIntrusiveList : public DtReaderWriter 00039 { 00040 public: 00041 00043 DtRwIntrusiveList(); 00044 00046 DtRwIntrusiveList(const DtString& name, 00047 DtReaderWriterRegistry* parentRegistry = NULL); 00048 DtRwIntrusiveList(const DtSymbolString& name, 00049 DtReaderWriterRegistry* parentRegistry = NULL); 00050 00052 DtRwIntrusiveList(const DtString& name, const DtRwIntrusiveList& orig, 00053 DtReaderWriterRegistry* parentRegistry = NULL); 00054 DtRwIntrusiveList(const DtSymbolString& name, const DtRwIntrusiveList& orig, 00055 DtReaderWriterRegistry* parentRegistry = NULL); 00056 00062 virtual ~DtRwIntrusiveList(); 00063 00065 DtRwIntrusiveList& operator=(const DtRwIntrusiveList& orig); 00066 00068 DtRwListedObj* firstObj() const; 00069 DtRwListedObj* lastObj() const; 00070 00073 DtListItem* first() const; 00074 DtListItem* last() const; 00075 00077 unsigned count() const; 00078 00081 DtListItem* add(DtRwListedObj* data); 00082 00085 DtListItem* addToStart(DtRwListedObj* data); 00086 00089 DtListItem* addToEnd(DtRwListedObj* data); 00090 00093 DtListItem* addBefore(DtRwListedObj* data, DtRwListedObj* before); 00094 00097 DtListItem* addAfter(DtRwListedObj* data, DtRwListedObj* after); 00098 00103 DtRwListedObj* remove(DtRwListedObj* data); 00104 00110 virtual DtRwListedObj* remove(DtListItem* item); 00111 00113 void removeAndDelete(DtRwListedObj* data); 00114 00117 virtual void removeAndDelete(DtListItem* item); 00118 00121 virtual void removeAll(); 00122 00124 virtual void removeAllAndDelete(); 00125 00129 DtListItem* itemLookup(DtRwListedObj* data) const; 00130 00133 virtual void getSelf(DtlObjPtr args, const DtFilename& searchPath, 00134 const DtVariableBindingsList& variableBindings); 00135 00140 virtual DtlObjPtr getData(DtlObjPtr args, const DtFilename& searchPath, 00141 const DtVariableBindingsList& variableBindings) = 0; 00142 00146 virtual DtlObjPtr getLocalData(DtlObjPtr args); 00147 00151 virtual const char* readerWriterType() const; 00152 00153 protected: 00154 00157 DtRwIntrusiveList(const DtRwIntrusiveList& orig); 00158 00161 virtual DtListItem* addToList(DtRwListedObj* data, DtRwListedObj* after); 00162 00164 DtList myList; 00165 }; 00166 00173 class DT_DLL_vrfutil DtRwListedObj : public DtReaderWriter 00174 { 00175 public: 00176 00177 friend class DtRwIntrusiveList; 00178 00179 public: 00180 00182 DtRwListedObj(); 00183 00185 DtRwListedObj(const DtString& name, 00186 DtReaderWriterRegistry* parentRegistry = NULL); 00187 00188 DtRwListedObj(const DtSymbolString& name, 00189 DtReaderWriterRegistry* parentRegistry = NULL); 00190 00192 DtRwListedObj(const DtRwListedObj& orig); 00193 00195 virtual ~DtRwListedObj(); 00196 00198 DtRwListedObj& operator=(const DtRwListedObj & orig); 00199 00202 DtRwListedObj* next() const; 00203 DtRwListedObj* prev() const; 00204 00208 DtRwListedObj* wrapNext() const; 00209 DtRwListedObj* wrapPrev() const; 00210 00214 virtual const char* readerWriterType() const; 00215 00216 protected: 00217 00218 DtList* myList; 00219 DtListItem* myItem; 00220 }; 00221 00223 00224 inline DtRwListedObj* DtRwIntrusiveList::firstObj() const 00225 { 00226 if (myList.first()) 00227 { 00228 return (DtRwListedObj*) myList.first()->data(); 00229 } 00230 00231 else 00232 { 00233 return 0; 00234 } 00235 00236 } 00237 00238 inline DtRwListedObj* DtRwIntrusiveList::lastObj() const 00239 { 00240 if (myList.last()) 00241 { 00242 return (DtRwListedObj*) myList.last()->data(); 00243 } 00244 00245 else 00246 { 00247 return 0; 00248 } 00249 } 00250 00251 inline DtListItem* DtRwIntrusiveList::first() const 00252 { 00253 return myList.first(); 00254 } 00255 00256 inline DtListItem* DtRwIntrusiveList::last() const 00257 { 00258 return myList.last(); 00259 } 00260 00261 inline unsigned DtRwIntrusiveList::count() const 00262 { 00263 return myList.count(); 00264 } 00265 00266 inline DtListItem* DtRwIntrusiveList::addToEnd(DtRwListedObj* data) 00267 { 00268 DtListItem* last = myList.last(); 00269 DtRwListedObj* lastObj = 0; 00270 if (last) 00271 { 00272 lastObj = (DtRwListedObj *)last->data(); 00273 } 00274 return addToList(data, lastObj); 00275 } 00276 00277 inline DtRwListedObj* DtRwListedObj::next() const 00278 { 00279 DtRwListedObj* result = 00280 (DtRwListedObj*) 00281 ((myItem && myItem->next()) ? myItem->next()->data() : NULL); 00282 return result; 00283 } 00284 inline DtRwListedObj* DtRwListedObj::prev() const 00285 { 00286 DtRwListedObj* result= 00287 (DtRwListedObj*) 00288 ((myItem && myItem->prev()) ? myItem->prev()->data() : NULL); 00289 return result; 00290 } 00291 00292 inline DtRwListedObj* DtRwListedObj::wrapNext() const 00293 { 00294 DtRwListedObj* result = 00295 (DtRwListedObj*) 00296 (next() ? next() : 00297 ((myList && myList->first()) ? myList->first()->data() : NULL)); 00298 return result; 00299 } 00300 inline DtRwListedObj* DtRwListedObj::wrapPrev() const 00301 { 00302 DtRwListedObj* result = 00303 (DtRwListedObj*) 00304 (prev() ? prev() : 00305 ((myList && myList->last()) ? myList->last()->data() : NULL)); 00306 return result; 00307 } 00308 00309 inline DtListItem* DtRwIntrusiveList::add(DtRwListedObj* data) 00310 { 00311 return addToEnd(data); 00312 } 00313 00314 inline DtListItem* DtRwIntrusiveList::addAfter(DtRwListedObj* data, 00315 DtRwListedObj* after) 00316 { 00317 return addToList(data, after); 00318 } 00319 00320 inline DtListItem* DtRwIntrusiveList::addBefore(DtRwListedObj* data, 00321 DtRwListedObj* before) 00322 { 00323 return addToList(data, before ? before->prev() : (DtRwListedObj*) NULL); 00324 } 00325 00326 inline DtListItem* DtRwIntrusiveList::addToStart(DtRwListedObj* data) 00327 { 00328 DtListItem* first = myList.first(); 00329 DtRwListedObj* firstObj = NULL; 00330 if (first) 00331 { 00332 firstObj = (DtRwListedObj *)first->data(); 00333 } 00334 00335 return addBefore(data, firstObj); 00336 } 00337 00338 inline DtListItem* DtRwIntrusiveList::itemLookup(DtRwListedObj* data) const 00339 { 00340 return myList.itemLookup(data); 00341 } 00342 00343 inline DtRwListedObj* DtRwIntrusiveList::remove(DtRwListedObj* data) 00344 { 00345 return remove(data->myItem); 00346 } 00347 00348 inline void DtRwIntrusiveList::removeAndDelete(DtRwListedObj* data) 00349 { 00350 removeAndDelete(data->myItem); 00351 } 00352 00353 00354 00355