VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
recursiveStateRepositoryIterator.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2001 MaK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: recSRIter.h,v $ $Revision: 1.7 $ $State: Exp $
7 *******************************************************************************/
8 
11 
17 
18 #ifndef DtRecursiveStateRepositoryIterator_H_
19 #define DtRecursiveStateRepositoryIterator_H_
20 
21 #include "vrfutil/iteratorBase.h"
24 
33 class DT_DLL_vrfobjcore DtRecursiveStateRepositoryIterator : public DtIteratorBase<DtSimObjectStateRepository>
34 {
35 
36 private:
39 
43 
47 
48 public:
50  DtRecursiveStateRepositoryIterator(const DtList& list) :
51  DtIteratorBase<DtSimObjectStateRepository>(list), myChildIterator(NULL) {};
52 
54  virtual ~DtRecursiveStateRepositoryIterator() { delete myChildIterator; };
55 
58  DtSimObjectStateRepository* first(bool reset = true)
59  {
60  if (reset)
61  {
63  }
64 
66  }
67 
70  {
71  if (myChildIterator)
72  {
73  DtSimObjectStateRepository* currRep = myChildIterator->current();
74 
75  if (currRep)
76  {
77  return currRep;
78  }
79 
80  else
81  {
82  delete myChildIterator;
85  wThis->myChildIterator = NULL;
86  }
87  }
88 
89  if (myCursor)
90  {
91  return (DtSimObjectStateRepository*) myCursor->data();
92  }
93 
95  return NULL;
96  }
97 
101  {
103 
105  if (myChildIterator)
106  {
107  currRep = myChildIterator->next();
108 
109  if (currRep)
110  {
111  return currRep;
112  }
113 
114  else
115  {
116  delete myChildIterator;
117  myChildIterator = NULL;
118  }
119  }
120 
121  else
122  {
123  DtSimObjectStateRepository* currRep = current();
124 
125  if (!currRep)
126  {
127  return NULL;
128  }
129 
130  if (currRep->attachments() && currRep->attachments()->numAttachments())
131  {
133  myChildIterator = new DtRecursiveStateRepositoryIterator(currRep->attachments()->elements());
134  if (myChildIterator)
135  {
136  return myChildIterator->first();
137  }
138 
139  else
140  {
142  return NULL;
143  }
144  }
145  }
146 
149  if (myCursor)
150  {
151  myCursor = myCursor->next();
152  }
153 
154  return current();
155  }
156 
159  void reset()
160  {
162 
163  if (myChildIterator)
164  {
165  delete myChildIterator;
166  myChildIterator = NULL;
167  }
168  }
169 
170 protected:
172 };
173 
174 #endif
virtual DtAttachmentManager * attachments()
virtual bool reset(bool reverse=false)
Sets the cursor and the direction of this iterator over the list.
Definition: iteratorBase.h:65
DtRecursiveStateRepositoryIterator(const DtList &list)
Constructor.
Definition: recursiveStateRepositoryIterator.h:50
const DtIteratorBase & operator=(const DtIteratorBase &orig)
Assignment Operator.
virtual T * current()
Definition: iteratorBase.h:330
DtSimObjectStateRepository * current() const
returns the current object. List index is unmodified.
Definition: recursiveStateRepositoryIterator.h:69
DtSimObjectStateRepository * first(bool reset=true)
Calls reset() if reset arg is true (useful for for() loops).
Definition: recursiveStateRepositoryIterator.h:58
void reset()
sets the current pointer to the start of the list.
Definition: recursiveStateRepositoryIterator.h:159
virtual int numAttachments() const
Returns the number of SRs attached.
The DtSimObjectStateRepository is an abstract base class (ABC) for all state repositories.
Definition: simObjectStateRepository.h:46
File: recSRIter.h.
Definition: recursiveStateRepositoryIterator.h:33
virtual ~DtRecursiveStateRepositoryIterator()
Destructor.
Definition: recursiveStateRepositoryIterator.h:54
Description: DtIteratorBase is the base class for iterators used to iterate over a DtList...
Definition: iteratorBase.h:32
#define DT_DLL_vrfobjcore
This file is used to determine how to build.
Definition: vrfobjcoreDefines.h:24
virtual T * first(bool move=true)
Definition: iteratorBase.h:331
DtRecursiveStateRepositoryIterator * myChildIterator
Definition: recursiveStateRepositoryIterator.h:171
DtSimObjectStateRepository * next()
moves the index to the next position and returns the object at that position in the list...
Definition: recursiveStateRepositoryIterator.h:100
const DtList & elements() const
Definition: attachmentManager.h:81

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)