VTK
vtkCollection.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCollection.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
33 #ifndef vtkCollection_h
34 #define vtkCollection_h
35 
36 #include "vtkCommonCoreModule.h" // For export macro
37 #include "vtkObject.h"
38 
39 //BTX - begin tcl exclude
40 class vtkCollectionElement //;prevents pick-up by man page generator
41 {
42  public:
43  vtkCollectionElement():Item(NULL),Next(NULL) {}
46 };
48 //ETX end tcl exclude
49 
51 
53 {
54 public:
55  vtkTypeMacro(vtkCollection,vtkObject);
56  void PrintSelf(ostream& os, vtkIndent indent);
57 
59  static vtkCollection *New();
60 
62  void AddItem(vtkObject *);
63 
67  void InsertItem(int i, vtkObject *);
68 
70  void ReplaceItem(int i, vtkObject *);
71 
77  void RemoveItem(int i);
78 
82  void RemoveItem(vtkObject *);
83 
85  void RemoveAllItems();
86 
90  int IsItemPresent(vtkObject *a);
91 
93  int GetNumberOfItems() { return this->NumberOfItems; }
94 
97  void InitTraversal() { this->Current = this->Top;};
98 
99  //BTX
101 
104  cookie = static_cast<vtkCollectionSimpleIterator>(this->Top);};
105  //ETX
107 
110  vtkObject *GetNextItemAsObject();
111 
114  vtkObject *GetItemAsObject(int i);
115 
116  //BTX
118 
120  vtkObject *GetNextItemAsObject(vtkCollectionSimpleIterator &cookie);
121  //ETX
123 
125  vtkCollectionIterator* NewIterator();
126 
128 
129  virtual void Register(vtkObjectBase* o);
130  virtual void UnRegister(vtkObjectBase* o);
131 protected:
132  vtkCollection();
133  ~vtkCollection();
135 
136  virtual void RemoveElement(vtkCollectionElement *element,
138  virtual void DeleteElement(vtkCollectionElement *);
143 
144  //BTX
145  friend class vtkCollectionIterator;
146  //ETX
147 
148  // See vtkGarbageCollector.h:
149  virtual void ReportReferences(vtkGarbageCollector* collector);
150 private:
151  vtkCollection(const vtkCollection&); // Not implemented
152  void operator=(const vtkCollection&); // Not implemented
153 };
154 
155 
157 {
158  vtkCollectionElement *elem=this->Current;
159 
160  if ( elem != NULL )
161  {
162  this->Current = elem->Next;
163  return elem->Item;
164  }
165  else
166  {
167  return NULL;
168  }
169 }
170 
172 {
173  vtkCollectionElement *elem=static_cast<vtkCollectionElement *>(cookie);
174 
175  if ( elem != NULL )
176  {
177  cookie = static_cast<void *>(elem->Next);
178  return elem->Item;
179  }
180  else
181  {
182  return NULL;
183  }
184 }
185 
186 #endif
187 
188 
189 
190 
191 
void * vtkCollectionSimpleIterator
Definition: vtkCollection.h:47
abstract base class for most VTK objects
Definition: vtkObject.h:61
virtual void Register(vtkObjectBase *o)
void InitTraversal()
Definition: vtkCollection.h:97
#define VTKCOMMONCORE_EXPORT
vtkCollectionElement * Current
Detect and break reference loops.
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual void UnRegister(vtkObjectBase *o)
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual void ReportReferences(vtkGarbageCollector *)
abstract base class for most VTK objects
Definition: vtkObjectBase.h:59
vtkCollectionElement * Bottom
iterator through a vtkCollection.
int GetNumberOfItems()
Definition: vtkCollection.h:93
create and manipulate unsorted lists of objects
Definition: vtkCollection.h:52
void InitTraversal(vtkCollectionSimpleIterator &cookie)
vtkCollectionElement * Next
Definition: vtkCollection.h:45
static vtkObject * New()
vtkObject * GetNextItemAsObject()
vtkCollectionElement * Top