VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
rwIntrusiveList.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 1999 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
11 class DtRwIntrusiveList;
12 class DtRwListedObj;
13 
14 #include <mtl/mtl.h>
15 #include <vlutil/vlList.h>
17 
37 #include "vrfutil/vrfutilDefines.h"
39 {
40 public:
41 
44 
46  DtRwIntrusiveList(const DtString& name,
47  DtReaderWriterRegistry* parentRegistry = NULL);
49  DtReaderWriterRegistry* parentRegistry = NULL);
50 
52  DtRwIntrusiveList(const DtString& name, const DtRwIntrusiveList& orig,
53  DtReaderWriterRegistry* parentRegistry = NULL);
54  DtRwIntrusiveList(const DtSymbolString& name, const DtRwIntrusiveList& orig,
55  DtReaderWriterRegistry* parentRegistry = NULL);
56 
62  virtual ~DtRwIntrusiveList();
63 
66 
68  DtRwListedObj* firstObj() const;
69  DtRwListedObj* lastObj() const;
70 
73  DtListItem* first() const;
74  DtListItem* last() const;
75 
77  unsigned count() const;
78 
81  DtListItem* add(DtRwListedObj* data);
82 
85  DtListItem* addToStart(DtRwListedObj* data);
86 
89  DtListItem* addToEnd(DtRwListedObj* data);
90 
93  DtListItem* addBefore(DtRwListedObj* data, DtRwListedObj* before);
94 
97  DtListItem* addAfter(DtRwListedObj* data, DtRwListedObj* after);
98 
103  DtRwListedObj* remove(DtRwListedObj* data);
104 
110  virtual DtRwListedObj* remove(DtListItem* item);
111 
113  void removeAndDelete(DtRwListedObj* data);
114 
117  virtual void removeAndDelete(DtListItem* item);
118 
121  virtual void removeAll();
122 
124  virtual void removeAllAndDelete();
125 
129  DtListItem* itemLookup(DtRwListedObj* data) const;
130 
133  virtual void getSelf(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
134  const DtVariableBindingsList& variableBindings);
135 
140  virtual DtlObjPtr getData(DtlObjPtr args, const DtReaderWriter::SearchPaths& searchPaths,
141  const DtVariableBindingsList& variableBindings) = 0;
142 
146  virtual DtlObjPtr getLocalData(DtlObjPtr args);
147 
151  virtual const char* readerWriterType() const;
152 
153 protected:
154 
158 
161  virtual DtListItem* addToList(DtRwListedObj* data, DtRwListedObj* after);
162 
164  DtList myList;
165 };
166 
174 {
175 public:
176 
177  friend class DtRwIntrusiveList;
178 
179 public:
180 
182  DtRwListedObj();
183 
185  DtRwListedObj(const DtString& name,
186  DtReaderWriterRegistry* parentRegistry = NULL);
187 
189  DtReaderWriterRegistry* parentRegistry = NULL);
190 
192  DtRwListedObj(const DtRwListedObj& orig);
193 
195  virtual ~DtRwListedObj();
196 
198  DtRwListedObj& operator=(const DtRwListedObj & orig);
199 
202  DtRwListedObj* next() const;
203  DtRwListedObj* prev() const;
204 
208  DtRwListedObj* wrapNext() const;
209  DtRwListedObj* wrapPrev() const;
210 
214  virtual const char* readerWriterType() const;
215 
216 protected:
217 
218  DtList* myList;
219  DtListItem* myItem;
220 };
221 
223 
225 {
226  if (myList.first())
227  {
228  return (DtRwListedObj*) myList.first()->data();
229  }
230 
231  else
232  {
233  return 0;
234  }
235 
236 }
237 
239 {
240  if (myList.last())
241  {
242  return (DtRwListedObj*) myList.last()->data();
243  }
244 
245  else
246  {
247  return 0;
248  }
249 }
250 
251 inline DtListItem* DtRwIntrusiveList::first() const
252 {
253  return myList.first();
254 }
255 
256 inline DtListItem* DtRwIntrusiveList::last() const
257 {
258  return myList.last();
259 }
260 
261 inline unsigned DtRwIntrusiveList::count() const
262 {
263  return myList.count();
264 }
265 
267 {
268  DtListItem* last = myList.last();
269  DtRwListedObj* lastObj = 0;
270  if (last)
271  {
272  lastObj = (DtRwListedObj *)last->data();
273  }
274  return addToList(data, lastObj);
275 }
276 
278 {
279  DtRwListedObj* result =
280  (DtRwListedObj*)
281  ((myItem && myItem->next()) ? myItem->next()->data() : NULL);
282  return result;
283 }
285 {
286  DtRwListedObj* result=
287  (DtRwListedObj*)
288  ((myItem && myItem->prev()) ? myItem->prev()->data() : NULL);
289  return result;
290 }
291 
293 {
294  DtRwListedObj* result =
295  (DtRwListedObj*)
296  (next() ? next() :
297  ((myList && myList->first()) ? myList->first()->data() : NULL));
298  return result;
299 }
301 {
302  DtRwListedObj* result =
303  (DtRwListedObj*)
304  (prev() ? prev() :
305  ((myList && myList->last()) ? myList->last()->data() : NULL));
306  return result;
307 }
308 
309 inline DtListItem* DtRwIntrusiveList::add(DtRwListedObj* data)
310 {
311  return addToEnd(data);
312 }
313 
315  DtRwListedObj* after)
316 {
317  return addToList(data, after);
318 }
319 
321  DtRwListedObj* before)
322 {
323  return addToList(data, before ? before->prev() : (DtRwListedObj*) NULL);
324 }
325 
327 {
328  DtListItem* first = myList.first();
329  DtRwListedObj* firstObj = NULL;
330  if (first)
331  {
332  firstObj = (DtRwListedObj *)first->data();
333  }
334 
335  return addBefore(data, firstObj);
336 }
337 
338 inline DtListItem* DtRwIntrusiveList::itemLookup(DtRwListedObj* data) const
339 {
340  return myList.itemLookup(data);
341 }
342 
344 {
345  return remove(data->myItem);
346 }
347 
349 {
350  removeAndDelete(data->myItem);
351 }
352 
353 
354 
355 
DtList * myList
Definition: rwIntrusiveList.h:218
virtual const char * readerWriterType() const
Used to supply a string type that this reader writer type is. This can be used in place of dynamic-ca...
DtListItem * addToEnd(DtRwListedObj *data)
Add element to the end of the list. Returns the DtListItem envelope object that contains your new ele...
Definition: rwIntrusiveList.h:266
DtListItem * itemLookup(DtRwListedObj *data) const
Returns the DtListItem envelope object containing the indicated data element. This function should ne...
Definition: rwIntrusiveList.h:338
Definition: symbolString.h:20
DtListItem * last() const
Definition: rwIntrusiveList.h:256
virtual DtlObjPtr getData(DtlObjPtr args, const SearchPaths &searchPaths, const DtVariableBindingsList &variableBindings)
Deriving class overrides these to get/put class specific data.
Definition: readerWriter.h:85
unsigned count() const
Returns the number of elements in the list.
Definition: rwIntrusiveList.h:261
Definition: readerWriterRegistry.h:39
void removeAndDelete(DtRwListedObj *data)
Remove and delete an element from the list.
Definition: rwIntrusiveList.h:348
DtRwListedObj * wrapPrev() const
Definition: rwIntrusiveList.h:300
std::list< const DtRwVariableBindings * > DtVariableBindingsList
Definition: readerWriterRegistry.h:29
std::vector< DtFilename > SearchPaths
Definition: readerWriter.h:92
DtRwListedObj * remove(DtRwListedObj *data)
Remove an element from the list. Note: remove does not free memory of data associated with the item...
Definition: rwIntrusiveList.h:343
DtListItem * first() const
Return first and last item on the list. DtListItem is an envelope for your data. The data can be obta...
Definition: rwIntrusiveList.h:251
virtual void getSelf(DtlObjPtr args, const DtReaderWriter::SearchPaths &searchPaths=SearchPaths(), const DtVariableBindingsList &variableBindings=nullVariableReference())
Top level to read itself from an input stream. searchPath is passed down to all DtReaderWriter member...
virtual DtListItem * addToList(DtRwListedObj *data, DtRwListedObj *after)
Add element to the list just after the indicated item. Returns the DtListItem envelope object that co...
class DtRwIntrusiveList:
Definition: rwIntrusiveList.h:38
DtRwListedObj * next() const
Return next (previous) elements on the list, or NULL if hit the end (beginning) of the list...
Definition: rwIntrusiveList.h:277
! ! This is a base class from which elements of a DtRwIntrusiveList must be ! derived. Previous and next pointers can be obtained directly from the ! DtRwListedObj, without going through the DtRwIntrusiveList to which it has ! been added. !
Definition: rwIntrusiveList.h:173
DtListItem * addToStart(DtRwListedObj *data)
Add element to the beginning of the list. Returns the DtListItem envelope object that contains your n...
Definition: rwIntrusiveList.h:326
DtListItem * myItem
Definition: rwIntrusiveList.h:219
DtRwListedObj * wrapNext() const
Return next (previous) elements on the list, but wrap to the beginning (end) of the list when you hit...
Definition: rwIntrusiveList.h:292
DtRwListedObj * firstObj() const
Return first and last item on the list.
Definition: rwIntrusiveList.h:224
DtListItem * add(DtRwListedObj *data)
Add element to the end of the list. Returns the DtListItem envelope object that contains your new ele...
Definition: rwIntrusiveList.h:309
#define DT_DLL_vrfutil
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfutilDefines.h:34
const DtReaderWriter & operator=(const DtReaderWriter &orig)
assignment operator
DtRwListedObj * prev() const
Definition: rwIntrusiveList.h:284
DtListItem * addBefore(DtRwListedObj *data, DtRwListedObj *before)
Add element to the list just before the indicated object. Returns the DtListItem envelope object that...
Definition: rwIntrusiveList.h:320
virtual DtSymbolString name() const
Accessor for name of this readable/writable object.
DtListItem * addAfter(DtRwListedObj *data, DtRwListedObj *after)
Add element to the list just after the indicated object. Returns the DtListItem envelope object that ...
Definition: rwIntrusiveList.h:314
DtRwListedObj * lastObj() const
Definition: rwIntrusiveList.h:238
DtList myList
The actual DtList used to store the items.
Definition: rwIntrusiveList.h:164

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)