VR-Link API Documentation for DIS
vlList.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 1992-2010 VT MAK
00003 ** All rights reserved.
00004 *********************************************************************/
00008 #pragma once
00009 
00010 
00011 #include "vlMachineTypes.h"
00012 #include <stddef.h>
00013 
00014 #ifdef DtUSE_UTILITIES_NAMESPACE
00015 namespace DtUSE_UTILITIES_NAMESPACE
00016 {
00017 #endif
00018 
00025 class DT_DLL_VLUTIL DtListItem 
00026 {
00027 public:
00028 
00029    friend class DtList;
00030 
00031 public:
00032 
00034    virtual ~DtListItem();
00035 
00038    DtListItem* prev() const;
00039    DtListItem* next() const;
00040 
00042    void* data() const;
00043 
00044 protected:
00045 
00047    DtListItem(void* d);
00048 
00049 protected:
00050 
00051    DtListItem* myPrev;
00052    DtListItem* myNext;
00053    void*       myData;
00054 };
00055 
00071 class DT_DLL_VLUTIL DtList 
00072 {
00073 
00074 public:
00075 
00077    DtList();
00078 
00081    virtual ~DtList();
00082 
00085    DtList(const DtList& orig);
00086 
00091    DtList& operator=(const DtList& orig);
00092 
00095    DtListItem* first() const;
00096    DtListItem* last() const;
00097 
00099    unsigned count() const;
00100 
00103    DtListItem* add(void* data);
00104 
00107    DtListItem* addToStart(void* data);
00108 
00111    DtListItem* addToEnd(void* data);
00112 
00115    DtListItem* addBefore (void* data, DtListItem* before);
00116 
00119    DtListItem* addAfter(void* data, DtListItem* after);
00120     
00126    void* remove(DtListItem* item);
00127 
00130    void removeAll();
00131     
00134    DtListItem* itemLookup(const void* data) const;
00135 
00136 protected:
00137 
00139    virtual void addToList(DtListItem* item, DtListItem* after);
00140 
00143    virtual void removeFromList(DtListItem* item);
00144 
00145 protected:
00146 
00147    DtListItem* myFirst;
00148    DtListItem* myLast;
00149    unsigned  myCount;
00150 };
00151 
00152 
00157 
00158 class DT_DLL_VLUTIL DtListedObj
00159 {  
00160 public:
00161 
00162    friend class DtIntrusiveList;
00163 
00164 public:
00165 
00167    DtListedObj();
00168 
00170    virtual ~DtListedObj();
00171 
00174    void* next() const;
00175    void* prev() const;
00176 
00180    void* wrapNext() const;
00181    void* wrapPrev() const;
00182 
00183 protected:
00184 
00185    DtList* myList;
00186    DtListItem* myItem;
00187 };
00188 
00189 
00195 
00196 class DT_DLL_VLUTIL DtIntrusiveList : public DtList
00197 {
00198 protected:
00199 
00202    virtual void addToList(DtListItem* item, DtListItem* after);
00203 
00206    virtual void removeFromList(DtListItem* item);
00207 
00209    void removeAndDelete(const DtListedObj* data);
00210 
00213    virtual void removeAndDelete(DtListItem* item);
00214 
00216    virtual void removeAllAndDelete();   
00217 };
00218 
00220 
00221 inline DtListItem* DtListItem::prev() const 
00222 {
00223    return myPrev; 
00224 }
00225 
00226 inline DtListItem* DtListItem::next() const 
00227 {
00228    return myNext; 
00229 }
00230 
00231 inline void* DtListItem::data() const 
00232 {
00233    return myData; 
00234 }
00235 
00236 inline DtListItem* DtList::first() const
00237 {
00238    return myFirst; 
00239 }
00240 
00241 inline DtListItem* DtList::last() const
00242 {
00243    return myLast;
00244 }
00245 
00246 inline unsigned DtList::count() const
00247 {
00248    return myCount;
00249 }
00250 
00251 inline DtListItem* DtList::add(void* data)  
00252 {
00253    return addAfter(data, myLast); 
00254 }
00255 
00256 inline DtListItem* DtList::addToStart(void* data)  
00257 {
00258    return addAfter(data, 0);  
00259 }
00260 
00261 inline DtListItem* DtList::addToEnd(void* data)
00262 {
00263    return addAfter(data, myLast); 
00264 }
00265 /*lint -save -e818 */
00266 inline DtListItem* DtList::addBefore (void* data, DtListItem* before) 
00267 {
00268    return addAfter(data, before ? before->myPrev : (DtListItem*) 0); 
00269 }
00270 /*lint -restore */
00271 
00272 inline void* DtListedObj::next() const 
00273 {
00274    return (myItem && myItem->next()) ? myItem->next()->data() : 0; 
00275 } 
00276 
00277 inline void* DtListedObj::prev() const 
00278 {
00279    return (myItem && myItem->prev()) ? myItem->prev()->data() : 0; 
00280 }
00281 
00282 inline void* DtListedObj::wrapNext() const 
00283 { 
00284   return next() ? next() : 
00285      ((myList && myList->first()) ? myList->first()->data() : 0);
00286 }
00287 
00288 inline void* DtListedObj::wrapPrev() const
00289 { 
00290    return prev() ? prev() : 
00291       ((myList && myList->last()) ? myList->last()->data() : 0);      
00292 }
00293 
00295 #define looplist(theData, list) \
00296 for (DtListItem* item=(list)->first();  \
00297    theData = (item ? item->data() : 0); \
00298    item = item->next())
00299 
00302 #define looptlist(theData, type, list) \
00303 for (DtListItem* item=(list)->first();  \
00304    theData = (type)(item ? item->data() : 0); \
00305    item = item->next())
00306 
00309 #define looptlist2(theData, type, list) \
00310 for (item=(list)->first();  \
00311    theData = (type)(item ? item->data() : 0); \
00312    item = item->next())
00313 
00314 #ifdef DtUSE_UTILITIES_NAMESPACE
00315 } 
00316 #endif
00317 

Document ID: Generated on Mon May 14 08:06:18 EDT 2012 from SVN revision 114750
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)