VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
recursiveResourceIterator.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2004 MaK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: recRscrIter.h,v $ $Revision: 1.3 $ $State: Exp $
7 Created: 4/5/04 MEM
8 *******************************************************************************/
9 
12 
18 
19 #ifndef DtRecursiveResourceIterator_H_
20 #define DtRecursiveResourceIterator_H_
21 
22 #include "vrfutil/simResource.h"
24 #include "vrfutil/iteratorBase.h"
25 
31 #include "vrfutil/vrfutilDefines.h"
33 {
34 private:
37 
40  const DtRecursiveResourceIterator& orig);
41 
44  const DtRecursiveResourceIterator& orig);
45 
46 public:
47 
49  DtRecursiveResourceIterator(const DtList& list) :
50  DtIteratorBase<DtSimResource>(list), myChildIterator(NULL) {};
51 
53  virtual ~DtRecursiveResourceIterator() { delete myChildIterator; };
54 
57  DtSimResource* first(bool move=true)
58  {
60  }
61 
64  {
65  if (myChildIterator)
66  {
67  DtSimResource* currRep = myChildIterator->current();
68 
69  if (currRep)
70  {
71  return currRep;
72  }
73 
74  else
75  {
76  delete myChildIterator;
77  DtRecursiveResourceIterator* pRsrcIter =
79  pRsrcIter->myChildIterator = NULL;
80  }
81  }
82 
83  if (myCursor)
84  {
85  return (DtSimResource*) myCursor->data();
86  }
87 
89  return NULL;
90  }
91 
95  DtSimResource* next(bool move=true, bool recurse=false)
96  {
97  DtSimResource* currRep;
98 
100  if (myChildIterator)
101  {
102  currRep = myChildIterator->next(move,recurse);
103 
104  if (currRep)
105  {
106  return currRep;
107  }
108 
109  else
110  {
111  delete myChildIterator;
112  myChildIterator = NULL;
113  }
114  }
115 
116  else if ( recurse )
117  {
118  DtSimResource* currRep = current();
119 
120  if (!currRep)
121  {
122  return NULL;
123  }
124 
125  if (currRep->subresources() && currRep->subresources()->count())
126  {
128  myChildIterator = new DtRecursiveResourceIterator(*(currRep->subresources()));
129  if (myChildIterator)
130  {
131  return myChildIterator->first();
132  }
133 
134  else
135  {
137  return NULL;
138  }
139  }
140  }
141 
144  if (myCursor)
145  {
146  myCursor = myCursor->next();
147  }
148 
149  return current();
150  }
151 
154  void reset()
155  {
157 
158  if (myChildIterator)
159  {
160  delete myChildIterator;
161  myChildIterator = NULL;
162  }
163  }
164 
165 protected:
167 
168 };
169 
170 #endif
virtual bool reset(bool reverse=false)
Sets the cursor and the direction of this iterator over the list. If reverse is false, DtIteratorBeginning and DtIteratorForward are used, otherwise, DtIteratorEnd and DtIteratorReverse are used. Returns true unless the list is empty.
Definition: iteratorBase.h:65
DtSimResource * next(bool move=true, bool recurse=false)
moves the index to the next position and returns the object at that position in the list...
Definition: recursiveResourceIterator.h:95
const DtIteratorBase & operator=(const DtIteratorBase &orig)
Assignment Operator.
virtual T * current()
Definition: iteratorBase.h:330
DtSimResource * current() const
returns the current object. List index is unmodified.
Definition: recursiveResourceIterator.h:63
DtRecursiveResourceIterator(const DtList &list)
Constructor.
Definition: recursiveResourceIterator.h:49
DtRecursiveResourceIterator * myChildIterator
Definition: recursiveResourceIterator.h:166
Description: DtIteratorBase is the base class for iterators used to iterate over a DtList...
Definition: iteratorBase.h:32
virtual DtSimResourceList * subresources()
Accessor to this resource&#39;s subresources.
File: recRsrcIter.h.
Definition: recursiveResourceIterator.h:32
virtual T * first(bool move=true)
Definition: iteratorBase.h:331
virtual ~DtRecursiveResourceIterator()
Destructor.
Definition: recursiveResourceIterator.h:53
void reset()
sets the current pointer to the start of the list. Normally this isn&#39;t needed if you use the standard...
Definition: recursiveResourceIterator.h:154
DtSimResource is an abstract base class that can be used to create a hierarchical resource list of a ...
Definition: simResource.h:42
#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
DtSimResource * first(bool move=true)
Calls reset() if reset arg is true (useful for for() loops). Returns the first object on the list...
Definition: recursiveResourceIterator.h:57

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)